{"name":"Arma 3: Remote Execution","title":"Arma 3: Remote Execution","type":"topic","url":"https://community.bistudio.com/wiki/Arma_3:_Remote_Execution","revid":352065,"updated":"2024-02-01T23:24:38Z","aliases":["Arma 3 Remote Execution","Remote Execution"],"markdown":"Remote Execution is one of the cornerstones of Multiplayer Scripting in Arma 3. It is primarily needed to properly use commands that have *local effect* (Local Effect) or only take *local arguments* (Local Argument) in multiplayer.\n\n### Remote Execution Framework\n\nThe Remote Execution Framework currently consists of five commands:\n- remoteExec\n- remoteExecCall\n- remoteExecutedOwner\n- isRemoteExecuted\n- isRemoteExecutedJIP\nFurthermore, the framework encompasses an optional config entry to manage security settings: CfgRemoteExec.\n\n> [!NOTE]\n> While primarily designed and used for multiplayer, remoteExec and remoteExecCall also work in singleplayer; the behaviour is the same as in multiplayer.\n\n### Use Case Example\n\nTo understand why remote execution is needed and what it is used for, consider the following use case example: Let's say we want to use hint to display an announcement to all the players in our multiplayer mission at the same time.\n\nWe already know how to use the hint command:\n\n```sqf\nhint \"You have 5 minutes left!\"; // Normal use of hint.\n```\n\nThe problem is that hint only has *local effect*. This means that only the machine where hint is executed will display our \"You have 5 minutes left!\" message.\nBut we do not want to display our message to just a single player, we want to display our message to every player.\n\nSo in order to solve this problem, we need to make use of remote execution:\n\n```sqf\n\"You have 5 minutes left!\" remoteExec [\"hint\"];        // remote execution of hint.\n\"You have 5 minutes left!\" remoteExec [\"hint\", 0];    // identical to the line above\n```\n\nNow all machines that are taking part in our multiplayer session will execute `hint \"You have 5 minutes left!\";`, which means that our message will be displayed to every player at the same time - and we have achieved our goal.\n\n> [!NOTE]\n> If it is available, information about the multiplayer behaviour of a function / command can be found at the top of the documentation page of that function / command. Look for these icons: Local Argument, Global Argument, Local Effect, Global Effect and Server Execution. Hover above the icons to view a tooltip explaining what each icon means.\n\n### Environment\n\n|  |  |  |  |\n|---|---|---|---|\n| + Execution in Scheduled Environment |  | Commands | Functions |\n| remoteExec | ✗ | ✓ |  |\n| remoteExecCall | ✗ | ✗ |  |\n\n### History\n\nPrior to Arma 3 v1.50 there was no engine based remote execution. The only officially supported way to execute code on a non-local machine was provided in the form of BIS_fnc_MP. This scripted framework suffered from several issues, mainly poor network traffic optimization and insufficient security control. The network traffic was optimized in Arma 3 v1.46, but the security issues of the scripted framework could not be fixed properly.\n\nTo fully address these issues, remote execution was implemented directly into the game engine, with Arma 3 v1.50 introducing two new script commands - remoteExec and remoteExecCall - as well as a new CfgRemoteExec, finally allowing for proper and secure remote execution from all machines.\n\nAs of Arma 3 v1.54, BIS_fnc_MP has been rewritten to internally use remoteExec and remoteExecCall, retaining full backwards compatibility and enabling it to work with the updated CfgRemoteExec. **Despite this, BIS_fnc_MP is now deprecated and should no longer be used!**\n\n### Advanced Techniques & Functionality Insight\n\n#### JIP Queue\n\nWhen a command or function is executed through remoteExec or remoteExecCall, it can be flagged as persistent. If it is flagged, the statement is stored in the JIP queue on the server (under its unique JIP ID). When a player joins a multiplayer session that has already started (JIP stands for *Join-In-Progress*), all entries stored in the JIP queue are executed on that player's machine.\n\n##### Overwriting JIP message in the queue\n\nEvery JIP message is stored in the queue. If you need to overwrite the JIP message with another message, use the same JIP id for the new message. This way the new message will be stored in the queue under the provided id and will overwrite the previously stored message that used the same id.\n\n##### Deleting JIP message from the queue\n\nTo remove a specific JIP message from the queue call the remoteExec with function/command name set to an empty string, the JIP id of the message you want to remove and no other params.\n\n```sqf\nremoteExec [\"\", \"JIPid\"];\n```\n\n#### Validity Verification\n\nThe validity of a remote execution request is verified in two steps:\n1. When the request is initiated (issued from a client machine)\n1. Before the server broadcasts the request\n\nIf the request is initialized directly from the server, step 1 is skipped (this also applies to hosted servers).\n\nA remote execution request has to meet the following criteria to be considered valid:\n1. The input parameters must be defined properly\n1. The function / command must exist on the machine\n1. The function / command must be allowed by CfgRemoteExec: Remote execution must either be fully allowed (`mode = 2`) or the particular function / command must be whitelisted.\n1. If JIP is used, JIP must be allowed by CfgRemoteExec (`jip = 1`)\n\nIf any of these conditions is not met, the remote execution request is blocked.\n\n### See Also\n\n- Multiplayer Scripting\n- Multiplayer Scripting Commands\n\nArma 3 Remote Execution","sections":[{"heading":null,"level":1,"markdown":"Remote Execution is one of the cornerstones of Multiplayer Scripting in Arma 3. It is primarily needed to properly use commands that have *local effect* (Local Effect) or only take *local arguments* (Local Argument) in multiplayer."},{"heading":"Remote Execution Framework","level":3,"markdown":"The Remote Execution Framework currently consists of five commands:\n- remoteExec\n- remoteExecCall\n- remoteExecutedOwner\n- isRemoteExecuted\n- isRemoteExecutedJIP\nFurthermore, the framework encompasses an optional config entry to manage security settings: CfgRemoteExec.\n\n> [!NOTE]\n> While primarily designed and used for multiplayer, remoteExec and remoteExecCall also work in singleplayer; the behaviour is the same as in multiplayer."},{"heading":"Use Case Example","level":3,"markdown":"To understand why remote execution is needed and what it is used for, consider the following use case example: Let's say we want to use hint to display an announcement to all the players in our multiplayer mission at the same time.\n\nWe already know how to use the hint command:\n\n```sqf\nhint \"You have 5 minutes left!\"; // Normal use of hint.\n```\n\nThe problem is that hint only has *local effect*. This means that only the machine where hint is executed will display our \"You have 5 minutes left!\" message.\nBut we do not want to display our message to just a single player, we want to display our message to every player.\n\nSo in order to solve this problem, we need to make use of remote execution:\n\n```sqf\n\"You have 5 minutes left!\" remoteExec [\"hint\"];        // remote execution of hint.\n\"You have 5 minutes left!\" remoteExec [\"hint\", 0];    // identical to the line above\n```\n\nNow all machines that are taking part in our multiplayer session will execute `hint \"You have 5 minutes left!\";`, which means that our message will be displayed to every player at the same time - and we have achieved our goal.\n\n> [!NOTE]\n> If it is available, information about the multiplayer behaviour of a function / command can be found at the top of the documentation page of that function / command. Look for these icons: Local Argument, Global Argument, Local Effect, Global Effect and Server Execution. Hover above the icons to view a tooltip explaining what each icon means."},{"heading":"Environment","level":3,"markdown":"|  |  |  |  |\n|---|---|---|---|\n| + Execution in Scheduled Environment |  | Commands | Functions |\n| remoteExec | ✗ | ✓ |  |\n| remoteExecCall | ✗ | ✗ |  |"},{"heading":"History","level":3,"markdown":"Prior to Arma 3 v1.50 there was no engine based remote execution. The only officially supported way to execute code on a non-local machine was provided in the form of BIS_fnc_MP. This scripted framework suffered from several issues, mainly poor network traffic optimization and insufficient security control. The network traffic was optimized in Arma 3 v1.46, but the security issues of the scripted framework could not be fixed properly.\n\nTo fully address these issues, remote execution was implemented directly into the game engine, with Arma 3 v1.50 introducing two new script commands - remoteExec and remoteExecCall - as well as a new CfgRemoteExec, finally allowing for proper and secure remote execution from all machines.\n\nAs of Arma 3 v1.54, BIS_fnc_MP has been rewritten to internally use remoteExec and remoteExecCall, retaining full backwards compatibility and enabling it to work with the updated CfgRemoteExec. **Despite this, BIS_fnc_MP is now deprecated and should no longer be used!**"},{"heading":"Advanced Techniques & Functionality Insight","level":3,"markdown":""},{"heading":"JIP Queue","level":4,"markdown":"When a command or function is executed through remoteExec or remoteExecCall, it can be flagged as persistent. If it is flagged, the statement is stored in the JIP queue on the server (under its unique JIP ID). When a player joins a multiplayer session that has already started (JIP stands for *Join-In-Progress*), all entries stored in the JIP queue are executed on that player's machine."},{"heading":"Overwriting JIP message in the queue","level":5,"markdown":"Every JIP message is stored in the queue. If you need to overwrite the JIP message with another message, use the same JIP id for the new message. This way the new message will be stored in the queue under the provided id and will overwrite the previously stored message that used the same id."},{"heading":"Deleting JIP message from the queue","level":5,"markdown":"To remove a specific JIP message from the queue call the remoteExec with function/command name set to an empty string, the JIP id of the message you want to remove and no other params.\n\n```sqf\nremoteExec [\"\", \"JIPid\"];\n```"},{"heading":"Validity Verification","level":4,"markdown":"The validity of a remote execution request is verified in two steps:\n1. When the request is initiated (issued from a client machine)\n1. Before the server broadcasts the request\n\nIf the request is initialized directly from the server, step 1 is skipped (this also applies to hosted servers).\n\nA remote execution request has to meet the following criteria to be considered valid:\n1. The input parameters must be defined properly\n1. The function / command must exist on the machine\n1. The function / command must be allowed by CfgRemoteExec: Remote execution must either be fully allowed (`mode = 2`) or the particular function / command must be whitelisted.\n1. If JIP is used, JIP must be allowed by CfgRemoteExec (`jip = 1`)\n\nIf any of these conditions is not met, the remote execution request is blocked."},{"heading":"See Also","level":3,"markdown":"- Multiplayer Scripting\n- Multiplayer Scripting Commands\n\nArma 3 Remote Execution"}],"categories":["Arma 3: Remote Execution","Introduced with Arma 3 version 1.50"],"groups":["Scripting"]}