SA-MP Forums Archive
Keystatechange Updating without a timer? - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Keystatechange Updating without a timer? (/showthread.php?tid=264908)



Keystatechange Updating without a timer? - 0ne - 28.06.2011

Hello,
I was wondering if someone know how to code this thing.
How could I keep updating the bar without timers when a player is holding the button? I know its possible but can't think of a way on that, can anyone help me?


Re: Keystatechange Updating without a timer? - Mauzen - 28.06.2011

You can check if it is pressed in OnPlayerUpdate, and then use tickcount() to find out how long it is pressed/how long since the last OnPlayerUpdate, if needed.


Re: Keystatechange Updating without a timer? - playbox12 - 28.06.2011

Also timers are not such a bad thing at all. It all depends on HOW you use it. Looking for certain keys like Up Down Left Right(those cannot be checked with OnPlayerKeyStateChange), I would recommend a timer (or OnPlayerUpdate but then I'd schedule it so it only checks every 250ms or something). Savings accounts would be a bad example of using a timer for.