Get Speed of a player.
#1

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

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);
}
Reply
#3

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)