17.12.2010, 12:23
How can i set my d-board (gtarp) to show the speed in km/h. It says that it's in km/h but it's in miles.
if (strcmp(cmd, "/speed", true) == 0)
{
if(IsPlayerConnected(playerid))
{
new giveplayerid;
tmp = strtok(cmdtext, idx);
new string[256];
new Float:pos[4],Float:speed[2], final[2]; //Where [0] == MPH and [1] == KPH
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "[ERROR]USAGE: /speed [playerid/PartOfName]");
return 1;
}
//giveplayerid = strval(tmp);
giveplayerid = ReturnUser(tmp);
if(IsPlayerConnected(giveplayerid))
{
if(giveplayerid != INVALID_PLAYER_ID)
{
if(IsPlayerInAnyVehicle(giveplayerid))GetVehicleVelocity(GetPlayerVehicleID(giveplayerid),pos[1],pos[2],pos[3]);
else GetPlayerVelocity(giveplayerid,pos[1],pos[2],pos[3]);
speed[0] = floatmul(floatsqroot(floatpower(pos[1],2)+floatpower(pos[2],2)+floatpower([pos[3],2)),125); //MPH
speed[1] = floatmul(floatsqroot(floatpower(pos[1],2)+floatpower(pos[2],2)+floatpower(pos[3],2)),200); //KPH
final[0] = floatround(speed[0]);
final[1] = floatround(speed[1]);
format(string, sizeof(string), " AdmCmd: %s has a speed of %d MPH and %d KPH", GetPlayerNameEx(giveplayerid), final[0], final[1]);
SendClientMessage(playerid, COLOR_YELLOW, string);
}
else SendClientMessage(playerid, COLOR_WHITE, "[ERROR]No Such Player");
}
else SendClientMessage(playerid, COLOR_WHITE, "[ERROR]Player Not Connected");
}
return 1;
}