SA-MP Forums Archive
getting player speed in kmh [++Rep] - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: getting player speed in kmh [++Rep] (/showthread.php?tid=579798)



getting player speed in kmh [++Rep] - simo0000 - 30.06.2015

hello guys
is that functions gets player speed in kph or mph

pawn Код:
stock GetPlayerSpeed(playerid, bool:kmh)
{
  new Float:Vx, Float:Vy, Float:Vz, Float:rtn;
  if(IsPlayerInAnyVehicle(playerid)) GetVehicleVelocity(GetPlayerVehicleID(playerid), Vx, Vy, Vz); else GetPlayerVelocity(playerid, Vx, Vy, Vz);
  rtn = floatsqroot(floatabs(floatpower(Vx + Vy + Vz, 2)));

  return kmh?floatround(rtn * 100 * 1.55):floatround(rtn * 100);
}
pawn Код:
forward Float: ReturnVehicleSpeed(playerid);
public Float: ReturnVehicleSpeed(playerid)
{
    new Float: fVelocity[3];
    GetVehicleVelocity(GetPlayerVehicleID(playerid), fVelocity[0], fVelocity[1], fVelocity[2]);
    return floatsqroot((fVelocity[0] * fVelocity[0]) + (fVelocity[1] * fVelocity[1]) + (fVelocity[2] * fVelocity[2]) + (fVelocity[1] * fVelocity[1]) + (fVelocity[2] * fVelocity[2])) * 140;
}
sorry for my bad englsih


Re: getting player speed in kmh [++Rep] - MohammedZ - 30.06.2015

I Think KPH


Re: getting player speed in kmh [++Rep] - Suicidal.Banana - 30.06.2015

First is kilometers, second is prolly miles. (going by how the first one mentions kmh)

That said, nobody actually seems sure about the best way to calculate speed, be it KM/H or MP/H, a good example of that can be found in this thread, a whole bunch of people sharing bits of code they claim works best.


Re: getting player speed in kmh [++Rep] - baba1234 - 30.06.2015

This is mph becouse in that formula u multiply the speed with 140 in that second code the best multiply is for kmh 225 or 220 I tested it o my server. The infernus will be going like 280km/h it pretty fair speed for that car.