SA-MP Forums Archive
While pressing space? - 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: While pressing space? (/showthread.php?tid=611657)



New problem; Best callback to have this on? - Luicy. - 09.07.2016

How can I repeat a function without a timer, as long as the player is pressing space?
Like:

While pressing space: repeat untill not holding it anymore.
I need to know this for a fuel system..


New problem;
The same gamemode I'm working on, it's restricted to Palomino with a mapping revamp, But I'd like to check when ever someone get's out the XY that I can get, He should be TPed to inside with some XYZ I got, But the problem is that, OnPlayerUpdate is way too much called, Heard around40 times a second, So how is the best way to call this thing on?
Which callback, or should I create a timer?


Re: While pressing space? - Vince - 09.07.2016

You're going to need a timer anyway. Start timer on key press, kill timer on key release.


Re: While pressing space? - F1N4L - 09.07.2016

Quote:
Originally Posted by Vince
Посмотреть сообщение
You're going to need a timer anyway. Start timer on key press, kill timer on key release.
Or more optmized, use GetTime/GetTickCount for this...


Re: While pressing space? - Vince - 09.07.2016

Ehm no, if something has to update (textdraw, I imagine) while holding the key (e.g. pumping fuel) then you really have no other choice but timers. If you only want to calculate the time the key was held then yes, gettime will work.


Re: While pressing space? - F1N4L - 09.07.2016

Quote:
Originally Posted by Vince
Посмотреть сообщение
Ehm no, if something has to update (textdraw, I imagine) while holding the key (e.g. pumping fuel) then you really have no other choice but timers. If you only want to calculate the time the key was held then yes, gettime will work.
Really, I have not read the full post :/


Re: While pressing space? - Luicy. - 09.07.2016

How many millisecswould you suggest?


Re: While pressing space? - Sjn - 09.07.2016

I think, it depends on what kind of system you have. Set to 1000ms, if it takes too long for the process to be complete then you can reduce it. But don't use bellow 500ms I'd say.


Re: While pressing space? - Luicy. - 09.07.2016

Updated thread for a new problem, thought if I'd create a new one I'd just get pm's about spam posting.


Re: While pressing space? - Sjn - 09.07.2016

I didn't really understand what you mean by that. Are you talking about, if a player leaves Palomino Creek, they will be teleported back in? If so, use streamer plugin to create dynamic areas, then you can use OnPlayerLeaveDynamicArea callback.


Re: While pressing space? - Luicy. - 09.07.2016

Oh, didn't knew it exists. Thanks.