Question about vehicle speedometer.
#1

Hey everyone, I am curious about this one little question: Is it better to make a Timer, which will calculate your speed and update the string, or add this code under the OnPlayerUpdate ? In this way, I will need no timer. Will this improve the performance, or not? Because, its more accurate than the timer.
Reply
#2

I think a timer would be fine. OnPlayerUpdate is called for everything you do, not only a vehicle update - run a 1-second timer instead.
Reply
#3

Quote:
Originally Posted by Jochemd
Посмотреть сообщение
I think a timer would be fine. OnPlayerUpdate is called for everything you do, not only a vehicle update - run a 1-second timer instead.
Hmm... Alright, but what if I would do this check:

Код:
if( GetPlayerState(playerid) == PLAYER_STATE_DRIVER && vehDB[GetPLayerVehicleID(playerid)][engine] == 1)
In that case, it would not execute when not needed?
Reply
#4

Use a timer, OnPlayerUpdate calls to many times, Also remember GetPlayerVelocity!
Reply
#5

i got mine under OnPlayerUpdate becouse if there were 500 players and i run a 1 seconds TimerEx for all of these players there would be increase in CPU and lag.
as under OnPlayerUpdate will not cause the same problem becouse is allredy being called !
Reply
#6

i will use function with global timer... onplayerupdate is the fastes, but isnt so good for souch things, use OnPlayerUpdate only for AntiCheat or something similarly...
Reply
#7

Hmm... Okay, thank you for your answers! I'll try to figure something out.
Reply
#8

Also there are ton loads of Speedometers on the forum, just take a look at a simple one, or tow.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)