#1

Greedings,how can i make detect how many kilometers players passed.
Reply
#2

Distance = speed * time.

Set a 1 second timer (easiest). In the timer get the current speed. If it's in km/h then You need to get it down to either km/s or m/s depending on whether you store kilometers or meters. To get km/s divide speed by 3600. To get m/s multiple multiply speed by 1000 to get meters per hour and then divide by 3600.

Then you still need to multiply the end result by the timer interval (in seconds). But since a * 1 = a that step can be skipped if the interval is one second.
Reply
#3

Quote:
Originally Posted by Vince
Посмотреть сообщение
Distance = speed / time.

Set a 1 second timer (easiest). In the timer get the current speed. If it's in km/h then You need to get it down to either km/s or m/s depending on whether you store kilometers or meters. To get km/s divide speed by 3600. To get m/s multiple multiply speed by 1000 to get meters per hour and then divide by 3600.

Then you still need to multiply the end result by the timer interval (in seconds). But since a * 1 = a that step can be skipped if the interval is one second.
"Distans дr ett mеtt pе hur lеngt ifrеn varandra tvе objekt дr."

English translation: "Distance is a scantling of how far away two objects is."

Wouldn't it be better to compare the distance from coordinates A to B? Like, set a 1000 MS timer and save the coordinates as "old", then subtract the old coordinates with the current coordinations and add the X and Y together, leaving a 2D distance traveled.


Not sure whatever is better and more optimized but yeah, just a thought.
Reply
#4

Quote:
Originally Posted by Vince
Посмотреть сообщение
Distance = speed / time.

Set a 1 second timer (easiest). In the timer get the current speed. If it's in km/h then You need to get it down to either km/s or m/s depending on whether you store kilometers or meters. To get km/s divide speed by 3600. To get m/s multiple multiply speed by 1000 to get meters per hour and then divide by 3600.

Then you still need to multiply the end result by the timer interval (in seconds). But since a * 1 = a that step can be skipped if the interval is one second.
Sorry but i cant understand it...My skills in pawno are very poor,can u explain it on code ??.It will be more simple to me.Thank you.
Reply
#5

I think here's what you looking for https://sampforum.blast.hk/showthread.php?tid=91815
next time better use "search" tool before posting threads.
Reply
#6

@Debjit it is the include forum -_-. A better link would be https://sampforum.blast.hk/showthread.php?tid=404367

@Meller good idea.

@IchNAr Also read Distance Speed Time because is related to the answer of Vince
PS: The formula is Distance = Speed * Time
Reply
#7

Quote:
Originally Posted by Meller
Посмотреть сообщение
"Distans дr ett mеtt pе hur lеngt ifrеn varandra tvе objekt дr."

English translation: "Distance is a scantling of how far away two objects is."

Wouldn't it be better to compare the distance from coordinates A to B? Like, set a 1000 MS timer and save the coordinates as "old", then subtract the old coordinates with the current coordinations and add the X and Y together, leaving a 2D distance traveled.


Not sure whatever is better and more optimized but yeah, just a thought.
Perhaps, but if there already is a GetPlayerSpeed timer somewhere in the gamemode then you might as well use that since it's only one extra division as opposed to storing six extra variables. Which one's more accurate, I'll leave in the middle. The coordinate method calculates the distance in a straight line while the GetPlayerSpeed method does not. For example if a player is going through a 90° curve: if the timer ticks at the start of the curve and then again at the end of the curve then the measured distance will be shorter (approx. 45° diagonal) than the actual distance traveled.

Quote:
Originally Posted by IchNar
Посмотреть сообщение
Sorry but i cant understand it...My skills in pawno are very poor,can u explain it on code ??.It will be more simple to me.Thank you.
No, sorry. If I had to explain it all I'd need to write a tutorial and I'm sorry to say, but I don't really have the motivation to do that right now. Also I am against handing out ready-made pieces of code. It encourages copy-pasting instead of actual learning and understanding.
Reply
#8

Quote:
Originally Posted by Debjit
Посмотреть сообщение
I think here's what you looking for https://sampforum.blast.hk/showthread.php?tid=91815
next time better use "search" tool before posting threads.
Download link doesnt work..
Reply
#9

Use this one provided by 10MIN -> https://sampforum.blast.hk/showthread.php?tid=404367
Quote:
Originally Posted by 10MIN
Посмотреть сообщение
@Debjit it is the include forum -_-. A better link would be https://sampforum.blast.hk/showthread.php?tid=404367
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)