Posts: 101
Threads: 31
Joined: Sep 2013
Reputation:
0
The title is my question. I have noticed, that alot of scripts, on the forums, are keeping from using OnPlayerKeyStateChange.
Posts: 104
Threads: 2
Joined: Dec 2010
Reputation:
0
The only issue I can see with this is that a lot of checking would be taking place when a player presses a key affected by the callback in some way. Don't refrain from using this callback however, if your coding plan demands it necessary.
Posts: 1,781
Threads: 13
Joined: Sep 2009
Reputation:
0
a) imagine you have a stunt server with 200 players online, and each player wants to have a nitro + jump +flip key assigned. using timers (or better: 1 timer only) at a certain interval, will need to check all keystates each 200*(1000/interval in ms) times per second. multiply that with 3 for the amout of keys, and you have an excellent lagging script (at least a script which reacts too slowly).
b) imagine the OnPlayerKeyStateChange() callback used, taking advantage of the playerid and KeyValues already provided... not a single timer required, and it reacts instantly (assuming the ping could be 0 lol).
save CPU time whenever its possible, and USE the callbacks provided, they are there for a reason. (tip: B)