Global variables and multiplayer considerations?
Posted: Sat Oct 10, 2015 10:11 am
So two questions specific to multiplayer and global variables:
#1
If my init.sqf has the following line:
and in an editor placed trigger I write:
Assuming the clients aren't doing anything with the variables later, is doing the following pointless (in the trigger mentioned above)?:
#2
I was reading through the BIS wiki on variables, and there's this part in the end (Multiplayer Considerations):
#1
If my init.sqf has the following line:
Code: Select all
counterVar = 0;
Code: Select all
counterVar = counterVar +1;
Code: Select all
if (isServer) then { counterVar = counterVar +1}
I was reading through the BIS wiki on variables, and there's this part in the end (Multiplayer Considerations):
Should I be doing this with the simple global variable initialised in init.sqf above?Storing vars and functions into global vars without securing them with compileFinal is a very bad practice in MP. Basically, if you have a script installed on a server in mission file that uses functions stored in unprotected variables then hackers can overwrite that function attached to a global variable and make it execute code for everyone and do a lot of nasty stuff. So please put all of the code for each function in a SEPARATE file and initialize them like this:That way, the function can be called and spawned without it being subject to hackers that attempt to overwrite the global variable "myGlobalVarFunction".Code: Select all
myGlobalVarFunction = compileFinal preprocessFileLineNumbers "Dir\where\function\is\fnc_globalVarFunction.sqf";