24.03.2018, 20:08
Hello. I have a question about best anticheat checks that are placed inside foreach loops. I need precise and correct answer for usage of variables, since I don't know is it better to use one variable created on top of timer of anticheat and then used for each player to check if they are cheating or not. So the variable's value will be changed ~300 times in loop and loop needs to be finished asap efficiently. I've seen that I've created a stock function where the new variable is being declared in that stock.
CODE:
and I've replaced it to:
Which code is more efficient and why?
CODE:
Код:
stock Checksomething( playerid ) { new x; // using x here } public anticheat() { foreach ( new i : Player ) { Checksomething( i ); } }
Код:
public anticheat() { new x; foreach ( new i : Player ) { // CODE USING x VARIABLE THAT'S DECLARED IN THIS TIMER, NOT IN FUNCTION. } }