Distance Travelled.
#1

How can I get the distance travelled by a player? all help is appreciated, thanks
Reply
#2

You could make a timer that contineu's everytime the player moves (using getplayerpos), so lets say every second is 1 meter, you could convert the seconds to meters (if he ran for 60 seconds it means its 60 meters) this is how ever not accurate offcourse , its just a idea, GL!
Reply
#3

Is there any other ways, due to me using that method already and it's not suffice for me. It doesn't calculate them correctly.

I've seen a few servers with "Distance travelled: %d km", how would they get it? It seems so accurate!
Reply
#4

Imagine it this way:

If you're travelling 100 kilometers per hour, you travel 27,8 meters per second.
If you divide 27,8 by 100, you'll get 0,278.
Therefore, if you drive 1km/h, it's 0,278 meters more for your counter.

If your speed is 55km/h:

55km/h * 0,278 = 15,29 m/s.

This is pseudocode but you'll realize the idea

pawn Код:
SetTimer Distance 1000 1

public Distance()
{
  new Float: speed = float(player's current speed in km/h);
  Float: playerdistance+=0,278*speed;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)