The public variant of setVariable (alternative syntax with third parameter set to true) is under certain circumstances not JIP compatible. If the value was set to a unit and then the unit respawns, JIP clients will no longer have the value restored upon connecting.
- Legacy ID
- Create a mission with 2 playable slots. Add these entries to the description.ext:
enableDebugConsole = 2;
respawn = 3;
- Start the mission as host (H) in LAN and connect a second instance as client (C).
- Look as C at H and execute
cursorTarget setVariable ["test", 33, true];
via debug console.
cursorTarget getVariable ["test", -1];
on C via debug console.
It returns 33.
player getVariable ["test", -1];
Also returns 33 as expected.
- Leave the game with C. Reconnect as JIP.
- Repeat step 4. Both machines return 33 as expected.
- As C kill H. H respawns.
- Repeat step 4. Both machines return 33 as expected (the public version of setVariable is persistent after respawning)
- Leave the game with C. Reconnect as JIP. (Same as step 5.)
- Repeat step 4. On H the variable will still be 33. On C it will return -1 instead. The variable is gone on the JIP client.
The issue here is that setVariable is not JIP persistent IF the unit respawned after setVariable was used. If setVariable is used after the unit respawns or the unit never respawns at all, the value gets restored for JIP clients.