Is it bad to use alot of OnPlayerKeyStateChange's?
#1

The title is my question. I have noticed, that alot of scripts, on the forums, are keeping from using OnPlayerKeyStateChange.
Reply
#2

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.
Reply
#3

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)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)