SA-MP Forums Archive
Get Speed of a player. - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Get Speed of a player. (/showthread.php?tid=105694)



Get Speed of a player. - introzen - 30.10.2009

Sorry for making one of this stupid posts that everyone does but I've seen a lot of posts when player asks for a speedometer that take only speed of a player, every answer is like "Steal it from someones FS Speedo"...

I've tried...
But I just don't get it.

Now i'm asking if someone could post a function or something like:

GetPlayerSpeed(playerid)

I know that there is one already but it's infiltrated with 100 other functions in uf.inc and I've already included those functions in my GM so it gets a thousands of errors.

Could someone make a function for me please?

Begging for it...
<3


Re: Get Speed of a player. - woot - 30.10.2009

0.3 only.

pawn Код:
stock GetPlayerSpeed(playerid, bool:kmh) // by misco
{
  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.61):floatround(rtn * 100);
}



Re: Get Speed of a player. - introzen - 30.10.2009

Quote:
Originally Posted by //exora
0.3 only.

pawn Код:
stock GetPlayerSpeed(playerid, bool:kmh) // by misco
{
  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.61):floatround(rtn * 100);
}
Thanks xD

Just when I found out a way to do it on my own -.-

I got mine working,

Saved the players pos,

Took the distance to that pos 1 sec later,

multiplied the distance by 2.7 and got out a speed.

Not too realistic speed but at least something xD

Thanks anyway man