getting player speed in kmh [++Rep]
#1

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
Reply
#2

I Think KPH
Reply
#3

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.
Reply
#4

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)