29.11.2010, 04:12
Alright, so, I hate asking for help sometimes.. but I don't know what's happening.
I'm using this stock (credits to who made it) and Im' trying to make a simple speedo;
However, in game, I get xx.00000000 KM/H. If someone could tell me how to limit the 0's, that'd be really fantastic! Thanks
pawn Код:
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)) * 180;
return floatround(ST[3]);
}
pawn Код:
new Float:speed = GetPlayerSpeed(playerid);
format(string,sizeof(string), "%f KM/H", speed);
TextDrawSetString(Speed[playerid], string);