rendered paste bodypublic 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)," ~y~%dMPH",floatround(value/1600));
}
else{
format(string,sizeof(string)," ~y~%dKM/H",floatround(value/1000));
}
SavePlayerPos[i][LastX] = x;
SavePlayerPos[i][LastY] = y;
SavePlayerPos[i][LastZ] = z;
} // End is-player-connected
} // End for-loop
} // eind UpdateSpeed function
new SpeedTimer;
///////////////////////////////////////////////////////////////////////////////////////////////////
public CheckFuel(playerid)
{
new Ptmess[32];
new Float:distance,value,string[256];
value = floatround(distance * 3600);
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),"~y~%d %", Petrol[Vi]);
format(string, sizeof(string), "~y~%d% %dKM/H", Petrol[Vi],floatround(value/1000));
GameTextForPlayer(i, string,10000,6);
}
else
{
RemovePlayerFromVehicle(i);
SendClientMessage(i, COLOR_RED, "Your vehicle ran out of petrol");
if(Petrol[Vi] < 0)
{
Petrol[Vi] = 0;
}
}
if(Petrol[i] >= 51)
{
format(Ptmess, sizeof(Ptmess),"~y~%d %", Petrol[Vi]);
format(string, sizeof(string), "~y~%d% %dKM/H", Petrol[Vi],floatround(value/1000));
GameTextForPlayer(i, string,10000,6);
}
}
}
}
}