19.04.2011, 11:27
GetVehicleVelocity just doesn't work like that. You need to parse them together to get a usable result (speed).
Use this function to determine the speed of a vehicle:
Use:
For km/h: new speed = GetPlayerSpeed(playerid);
for mph: new speed = GetPlayerSpeed(playerid, false);
Use this function to determine the speed of a vehicle:
pawn Код:
stock GetPlayerSpeed(playerid, bool:kmh = true)
{
new
Float:xx,
Float:yy,
Float:zz,
Float:pSpeed;
if(IsPlayerInAnyVehicle(playerid))
{
GetVehicleVelocity(GetPlayerVehicleID(playerid),xx,yy,zz);
}
else
{
GetPlayerVelocity(playerid,xx,yy,zz);
}
pSpeed = floatsqroot((xx * xx) + (yy * yy) + (zz * zz));
return kmh ? floatround((pSpeed * 195.12)) : floatround((pSpeed * 121.9));
}
For km/h: new speed = GetPlayerSpeed(playerid);
for mph: new speed = GetPlayerSpeed(playerid, false);