Hoping this makes anyone new to BIS scripting more aware of the relationships between
Local, Global, Player and Server
First thing
Game logics are
"Only" local on the server, be it a player/server or a dedicated server
as an unwritten standard, most mission makers create a gamelogic and name it "Server"
when you are running the code
?(local server):what you are actually stating is
Is the game logic named "server" local on this machine, if so, run the code that follows on from ":"
Typical switches arefor .sqs?(local server):hint "I am the server machine"
?!(local server):hint "I am not the server machine"
? (local player):hint "I am a player machine"
?! (local player):hint "I am a dedicated server machine"
for .sqfif (local server) then {hint "I am the server machine"};
if (! local server) then {hint "I am not the server machine"};
if (local player) then {hint "I am a player machine"};
if (! local player) then {hint "I am a dedicated server machine"};
Where and when to use these, is dependant on what code you are running and where you want the code to run
More often than not you will see the following at the very start of a script
?(Local server): exit
if(local server)then{exit};
?(local player): exit
if(local player)then{exit};
These lines are used to stop the script from being run on certain machines
or, you can also initiate a script on either clients or server by using something like the following
?(Local server): [] exec "myscript.sqs
?(local player): [] exec "myscript.sqs
or more correctly with arma, functions
?(Local server): [] execVM "myscript.sqf;
?(local player): [] execVM "myscript.sqf;
Certain commands are local or globalGlobal commands are commands that when run on 1 machine, every other machine is sent / receives that data
Local commands are commands that do not send data to other machines.
setpos, is actually a global command, which means only 1 machine needs to run this code, as all the other machines will receive the data of the objects new position and reposition it
If you run this code on all machines, then every machine will tell every ,machine where to setpos the object, and the last machine that runs the code, will be the one that overwrites the rest
"
setdir" is local, meaning if you setdir an object on 1 machine, the others wont see it placed in the new direction, until some other code updates it
It takes time, but eventually you will discover which commands are local and which arent and the workarounds to create a global from a local
Eg, to make setdir into a global command, first setdir the object then setpos it, the setpos sends the direction of the object, thus setdir has been sent globally.
A new command that comes in both Global and local flavours is the
setmarkerpos, with it's local varient
SetmarkerposLocalI hope that gives you a better understanding of the relationship between player/server/global/local
NB>> Up too and including the present version (1.05) "setpos" will not work with static objects, eg ammo crates etc, this i believe is a big and will be rectified in some future patch