All pastes #484628 Raw Edit

Anonymous

public text v1 · immutable
·published 2007-05-12 10:21 UTC
rendered paste body
// Aight, create the main function
public UpdateSpeed(){
new Float:x,Float:y,Float:z;
new Float:distance,value,string[256];
for(new i=0; i<SLOTS; i++){
if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i)){
GetPlayerPos(i, x, y, z);
distance = floatsqroot(floatpower(floatabs(floatsub(x,SavePlayerPos[i][LastX])),2)+floatpower(floatabs(floatsub(y,SavePlayerPos[i][LastY])),2)+floatpower(floatabs(floatsub(z,SavePlayerPos[i][LastZ])),2));
    // Distance: meters in the last second
value = floatround(distance * 3600);
if(UpdateSeconds > 1){
value = floatround(value / UpdateSeconds);
}
// meters an hour
if(SpeedMode){
format(string,sizeof(string),"~r~%d MPH",floatround(value/1600));
GameTextForPlayer(i, string, 1100, 4);
}
else{
format(string,sizeof(string),"~r~%d KPH",floatround(value/1000));
GameTextForPlayer(i, string, 1100, 4);
}
SavePlayerPos[i][LastX] = x;
SavePlayerPos[i][LastY] = y;
SavePlayerPos[i][LastZ] = z;
} // End is-player-connected
} // End for-loop
} // eind UpdateSpeed function


//Fuel check function
public CheckFuel(playerid)
{
new Ptmess[32];
for(new i=0;i<MAX_PLAYERS;i++)

 {
  if(IsPlayerConnected(i) == 1 && IsPlayerInAnyVehicle(i) == 1)
   {
   if(GetPlayerState(i) == 2)
    {
	 new Vi;
     Vi = GetPlayerVehicleID(i);
     Petrol[Vi]--;

     if(Petrol[Vi] >= 1)
 {
      format(Ptmess, sizeof(Ptmess), "~n~~n~~n~~n~~n~~r~Benzine %d", Petrol[Vi]);
      GameTextForPlayer(i, Ptmess, 5300, 5);
      }
      else
      {
      RemovePlayerFromVehicle(i);
      SendClientMessage(i, COLOR_RED, "Je auto heeft geen bezine meer!");
      if(Petrol[Vi] < 0)
	   {
	   Petrol[Vi] = 0;
	   }
      }

      if(Petrol[i] >= 51)
       {
       format(Ptmess, sizeof(Ptmess), "~n~~n~~n~~n~~n~~r~Benzine %d", Petrol[Vi]);
       GameTextForPlayer(i, Ptmess, 5300, 5);
       }

	 }
    }
 }
}