30.12.2010, 20:24
How to convert vehicle velocity to KPH? (kilometers per hour)
I know you gotta divide and floatround but whats the numbers?
I know you gotta divide and floatround but whats the numbers?
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;
}
floatmul(floatsqroot(floatpower( Pos X ,2) + floatpower( Pos Y ,2) + floatpower(Pos Z ,2)), 200);
new Float:x,Float:y,Float:z;
GetVehicleVelocity(vehicleid,x,y,z);
YourSpeedInkmph=floatsqroot((x*x)+(y*y)+(z*z))*198;
YourSpeedInMPH=YourSpeedInkmph*0.621371192;
new Float:x,Float:y,Float:z;
GetVehicleVelocity(vehicleid,x,y,z);
YourSpeedInkmph=floatsqroot((x*x)+(y*y)+(z*z))*198;
YourSpeedInMPH=YourSpeedInkmph*0.621371192;