Remote command execution

By Spooner and Mandoble

There are two ways to execute commands, whenever required, on other machines:

  • Monitor a publicVariable for command requests. The key weakness of this method is that it could be possible that if two commands were received at exactly the same time, that is, more than one per frame, then only one of them would be detected and executed.
  • Create a game-logic specifically to send commands across the network (technique similar to that described above). This has the advantages that all commands are guaranteed to be executed and that there is no script continually polling a value to see if a command has been requested, but has the disadvantage that JIP players will always have the last command requested run when they first connect. If necessary, this limitation could be overcome by resetting the init to "" after setting and running the init code.

Both techniques have advantages and disadvantages, but, since the former is more generally appropriate, it will be assumed that the publicVariable technique, as described below, is being used in all future examples.

On every machine, there is a script continually looking to see if a global command has been requested:

global_command = ""

@ global_command != ""
call compile global_command
global_command = ""
goto check_global_command
global_command = "";

while {true} do
waitUntil {global_command != ""};
call compile global_command;
global_command = "";

On the machine wishing to murder every player:

global_command = "player setDamage 1";
publicVariable "global_command";

If multiple commands are being sent at the same time, then either seperate them by semi-colons, or call a function.

Another way to execute remote commands is via dynamically created triggers, which action is executed everywhere :

_trigger = createTrigger ["EmptyDetector", [0, 0, 0]];
   _trigger setTriggerActivation ["NONE", "PRESENT", false];
   _trigger setTriggerArea [0, 0, 0, false];
   _trigger setTriggerType "NONE";
   _trigger setTriggerTimeout [0, 0, 0, false ];
   _trigger setTriggerStatements ["true", "YOUR COMMANDS HERE", ""];
   Sleep 6;
   deleteVehicle _trigger