Fuel and mileage timers - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Fuel and mileage timers (
/showthread.php?tid=477278)
Fuel and mileage timers -
dusk - 23.11.2013
Hello, this has been on my mind for a while now... As I'm writing a gamemode I currently need to add Fuel,Speedometer update and Mileage to vehicles. And I'm looking for tips about it.
Speeomdeter,Mileage - Where would you put the update code for it? I'm currently thinking about OnPlayerUpdate or a ~1second(or less) timer. I guess mileage should be updated as often as speed...
Fuel - As this is going to be updated not as often as speed, I'm planning to put it under 1min timer(I have a 1min timer for every player started in OnPlayerConnect, I use it for main stuff).
An other idea I have is creating a global timer which would loop trough all vehicles and decrease their fuel.
So if you have any ideas,experiences or anything concerning this, please share
Re: Fuel and mileage timers -
ikbenremco - 23.11.2013
I suggest you to add your speedo on your onplayerupdate so it doens't got any delay about your speed/fuel ect.
Re: Fuel and mileage timers -
JimmyCh - 23.11.2013
I'd say create a one second timer for the speedo, 32 times a second(OnPlayerUpdate) is too much(I think that was the value).
As for the fuel, just put a 5 seconds timer to check for the fuel, since it's not needed often, but to lower the value of it(Like 1%), make that every minute I guess, it would be good.
Hope this helps.
Re: Fuel and mileage timers -
dusk - 23.11.2013
Thank you both. What do you think about fuel should it be in the speedos function(but called les frequently) or a different global timer?
Re: Fuel and mileage timers -
ikbenremco - 23.11.2013
Fuel should be at a different global timer.