04.06.2010, 17:36
Alright look, the GetPlayerSpeed function returns a value in KM/H. I wanted it in MPH, so I divide the result with 1.621 (1,621) to make it MPH. However, this gives me fucked up results like multiple millions. I know math isn't my strongest side but seriously, I thought this was simple enough?
pawn Код:
forward GetPlayerSpeed(playerid);
stock GetPlayerSpeed(playerid)
{
new Float:ST[4];
if(IsPlayerInAnyVehicle(playerid)) GetVehicleVelocity(GetPlayerVehicleID(playerid),ST[0],ST[1],ST[2]); else GetPlayerVelocity(playerid,ST[0],ST[1],ST[2]);
ST[3] = floatsqroot(floatpower(floatabs(ST[0]), 2.0) + floatpower(floatabs(ST[1]), 2.0) + floatpower(floatabs(ST[2]), 2.0)) * 253.3;
return floatround(ST[3]);
}
forward UpdateSpeed(playerid);
public UpdateSpeed(playerid)
{
new speed = GetPlayerSpeed(playerid);
new speedstring[16];
format(speedstring, sizeof speedstring, "%d MPH", speed/1.621); // Check this <--------
TextDrawSetString(SpeedoSpeed, speedstring);
}