30.06.2015, 00:51
hello guys
is that functions gets player speed in kph or mph
sorry for my bad englsih
is that functions gets player speed in kph or mph
pawn Код:
stock GetPlayerSpeed(playerid, bool:kmh)
{
new Float:Vx, Float:Vy, Float:Vz, Float:rtn;
if(IsPlayerInAnyVehicle(playerid)) GetVehicleVelocity(GetPlayerVehicleID(playerid), Vx, Vy, Vz); else GetPlayerVelocity(playerid, Vx, Vy, Vz);
rtn = floatsqroot(floatabs(floatpower(Vx + Vy + Vz, 2)));
return kmh?floatround(rtn * 100 * 1.55):floatround(rtn * 100);
}
pawn Код:
forward Float: ReturnVehicleSpeed(playerid);
public Float: ReturnVehicleSpeed(playerid)
{
new Float: fVelocity[3];
GetVehicleVelocity(GetPlayerVehicleID(playerid), fVelocity[0], fVelocity[1], fVelocity[2]);
return floatsqroot((fVelocity[0] * fVelocity[0]) + (fVelocity[1] * fVelocity[1]) + (fVelocity[2] * fVelocity[2]) + (fVelocity[1] * fVelocity[1]) + (fVelocity[2] * fVelocity[2])) * 140;
}