18.04.2009, 05:08
I was in the midst of making an accurate speedometer for getting exact top speeds of vehicles with or without NOS, for anti speed hack purposes.
I started with a timer, that checked every 500 milliseconds (half second) for the current position. With that I used the 3D coordinate distance formula of:
To measure exactly how long 1 San Andreas Measuring Unit (SAMU) was I teleported a friend to be 1 SAMU west of me and we measured the distance between heads. Conclusive of about 3.5 feet.
So 'D' * 3.5 was our answer to Feet per/Half Second. I multiplied that by 7200 (2 Halfs of a second times 60 seconds in a minute times 60 minutes in an hour) and divided that by 5280 (feet per mile). What I discovered was the CJ ran an average of about 17 MPH! That just barely beats the human sustained speed record (over 4 hours). The NRG at full speed clocked at around a normal (but surprisingly slow) 105 MPH average.
When my friend clocked it however, he was driving at 200+ MPH. I assumed it was due to the lag (server is on my laptop). So I made a formula to go to OnPlayerUpdate instead of per Half Second. What I did was:
the [1000 / (GetTickCount() - OldTickCount)] should be how many ticks it would have taken to reach 1 second times the 3600 (60 seconds per minute times 60 minutes per hour).
What I had instead of accurate speedometer was a crazed speedometer reading number far over and changing at spastic speeds.
Anyone have any ideas what happened?
I started with a timer, that checked every 500 milliseconds (half second) for the current position. With that I used the 3D coordinate distance formula of:
Код:
D = SquareRootOf( [(X2-X)*(X2-X)] + [(Y2-Y)*(Y2-Y)] + [(Z2-Z)*(Z2-Z)] )
So 'D' * 3.5 was our answer to Feet per/Half Second. I multiplied that by 7200 (2 Halfs of a second times 60 seconds in a minute times 60 minutes in an hour) and divided that by 5280 (feet per mile). What I discovered was the CJ ran an average of about 17 MPH! That just barely beats the human sustained speed record (over 4 hours). The NRG at full speed clocked at around a normal (but surprisingly slow) 105 MPH average.
When my friend clocked it however, he was driving at 200+ MPH. I assumed it was due to the lag (server is on my laptop). So I made a formula to go to OnPlayerUpdate instead of per Half Second. What I did was:
Код:
(D * 3.5) * [1000 / (GetTickCount() - OldTickCount)] * 3600
What I had instead of accurate speedometer was a crazed speedometer reading number far over and changing at spastic speeds.
Anyone have any ideas what happened?