06.03.2010, 08:46
How to get vehicle speed in this format KMph or Mph
How can I from x, y, z get KMph ?
How can I from x, y, z get KMph ?
stock GetSpeedKM(playerid)
{
new Float:PosX;
new Float:PosY;
new Float:PosZ;
GetPlayerPos(playerid, PosX, PosY, PosZ);
new value;
new Float:PlayerSpeedDistance;
PlayerSpeedDistance = floatsqroot(floatpower(floatabs(floatsub(PosX,ReadPlayerPosition[playerid][ReadX])),2)+floatpower(floatabs(floatsub(PosY,ReadPlayerPosition[playerid][ReadY])),2)+floatpower(floatabs(floatsub(PosZ,ReadPlayerPosition[playerid][ReadZ])),2));
value = floatround(PlayerSpeedDistance * 5000);
new KPH = floatround(value/800);
return KPH;
}
//==============================================================================
stock GetSpeedMP(playerid)
{
new Float:PosX;
new Float:PosY;
new Float:PosZ;
GetPlayerPos(playerid, PosX, PosY, PosZ);
new value;
new Float:PlayerSpeedDistance;
PlayerSpeedDistance = floatsqroot(floatpower(floatabs(floatsub(PosX,ReadPlayerPosition[playerid][ReadX])),2)+floatpower(floatabs(floatsub(PosY,ReadPlayerPosition[playerid][ReadY])),2)+floatpower(floatabs(floatsub(PosZ,ReadPlayerPosition[playerid][ReadZ])),2));
value = floatround(PlayerSpeedDistance * 5000);
new MPH = floatround(value/1400);
return MPH;
}