Egal wie schnell ich fahre er bleibt auf 0 km/h
#define TACHOTIMER 250
for(new i = 0; i < MAX_PLAYERS; i++)
{
Tacho[i] = TextDrawCreate(300, 370, "Km/h:---");
TextDrawLetterSize(Tacho[i], 0.4, 1.1);
TextDrawFont(Tacho[i], 1);
TextDrawSetShadow(Tacho[i], 2);
TextDrawSetOutline(Tacho[i],1);
}
public TachoTimer()
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i))
{
new Tachostring[20];
format(Tachostring, sizeof(Tachostring), "Km/h: %0.2f", GetPlayerSpeed(i));
TextDrawSetString(Tacho[i], Tachostring);
TextDrawShowForPlayer(i, Tacho[i]);
}
else
{
TextDrawHideForPlayer(i, Tacho[i]);
}
}
return 1;
}
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)) * 179.28625;
return floatround(ST[3]);
}