BIS fnc MP: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
(example note)
m (Text replacement - "\[\[[Cc]ategory:[ _]?Arma[ _]3:[ _]?([^|]*)]]" to "{{GameCategory|arma3|$1}}")
(41 intermediate revisions by 18 users not shown)
Line 1: Line 1:
''Function syntax in [[Take On Helicopters]] differs, see [[BIS_fnc_MP (Take On Helicopters)]] for details.''
{{Function|Comments=
____________________________________________________________________________________________


{{Function|= Comments
| arma3 |Game name=
____________________________________________________________________________________________


| arma3 |= Game name
|0.50|Game version=


|0.50|= Game version
|gr1 = Multiplayer |GROUP1=
____________________________________________________________________________________________
____________________________________________________________________________________________


| Send function for remote execution (and executes locally if conditions are met) . |= Description
| Send function for remote execution (and executes locally if conditions are met).
{{Warning|{{GVI|arma3|1.50}} This function has been replaced by [[remoteExec]] and [[remoteExecCall]]. While [[BIS_fnc_MP]] still works (to provide backwards compatibility), it is now deprecated and should no longer be used. See [[Arma 3: Remote Execution]] for more information.}}
{{Informative|Function syntax in [[Take On Helicopters]] differs, see [[BIS_fnc_MP (Take On Helicopters)]] for details.}}|Description=
____________________________________________________________________________________________
____________________________________________________________________________________________


| [params, functionName, target, isPersistent] spawn BIS_fnc_MP; |= Syntax
| [params, functionName, target, isPersistent, isCall] call BIS_fnc_MP; |Syntax=


|p1= '''params''': [[Anything]] - function arguments |=
|p1= '''params''': [[Anything]] - function arguments. Variables can be local. |Parameter 1=
|p2= '''functionName''': [[String]] - function name |=
|p2= '''functionName''': [[String]] - [[:Category:Functions|function]] or [[:Category:Scripting_Commands|scripting command]] name. |Parameter 2=
|p3= '''target''':
|p3= '''target''':
: [[Object]] - function will be executed only where unit is local [default: everyone]
* [[Object]] - the function will be executed only where unit is local [default: everyone]
: [[Array]] - array of objects
* [[String]] - the function will be executed only where object or group defined by the variable with passed name is local
: [[Boolean]] - [[true]] to execute on each machine (including the one where the function was called from), false to execute it on server only
* [[Boolean]] - [[true]] to execute on each machine (including the one where the function was called from), false to execute it on server only
: [[Number]] - function will be executed only on client with the given [[owner]] ID
* [[Number]] - function will be executed only on client with the given [[owner]] ID
: [[Side]] - function will be executed only on clients with the listed side
* [[Side]] - function will be executed only on clients where the player is on the specified side
|=
* [[Group]] - function will be executed only on clients where the player is in the specified group
|p4= '''isPersistent''': [[Boolean]] - true for persistent call (will be called now and for every JIP client) [default: false] |=
* [[Array]] - array of targets of types listed above |Parameter 3=
|p4= '''isPersistent''': [[Boolean]] - true for persistent call (will be called now and for every JIP client) [default: false] |Parameter 4=
|p5= '''isCall''': [[Boolean]] - (optional) true if function should be [[call|called]] on target machine, false to [[spawn]] it [default: false] |Parameter 5=


| [[Array]] - sent packet |= Return value
| [[Array]] - sent packet |Return value=
____________________________________________________________________________________________
____________________________________________________________________________________________
 
|x1= <code><nowiki>[</nowiki>"Imma spamming your log!","[[BIS_fnc_log]]"] spawn BIS_fnc_MP;</code>
Logs a message for every player who's currently joined.|=


|x2= <code><nowiki>[</nowiki>["Hello World"],"[[BIS_fnc_guiMessage]]",[[nil]],true] spawn BIS_fnc_MP;</code>
|x1= <code>{{cc|Logs a message for every player on the server.}}
Send a message containing "Hello World" to every player, including the ones who joins later using JIP.|=
["Imma spamming your log!", "[[BIS_fnc_log]]"] [[call]] [[BIS_fnc_MP]];</code> |Example 1=
 
|x2= <code>{{cc|Send a hint containing "Hello World" to every player, including the ones who joins later using JIP.}}
["Hello World", "[[hint]]", [[true]], [[true]]] [[call]] [[BIS_fnc_MP]];</code> |Example 2=
 
|x3= <code>{{cc|Executes ''playerConnected.sqf'' script on server every time a player joins the game.}}
<nowiki>[[[]</nowiki>,"playerConnected.sqf"], "[[BIS_fnc_execVM]]", [[false]], [[true]]] [[call]] [[BIS_fnc_MP]];</code> |Example 3=


|x3= <code><nowiki>[[[]</nowiki>,"playerConnected.sqf"],"BIS_fnc_execVM",false,true] spawn BIS_fnc_MP;</code>
|x4= <code>{{cc|Adds action to every player including JIP. "..." {{=}} further optional arguments (see [[addAction]])}}
Executes ''playerConnected.sqf'' script on server every time a player joins the game. |=
<nowiki>[[</nowiki>[[player]], ["My Action Title", "myAction.sqf", ...]], "[[addAction]]", [[true]], [[true]]] [[call]] [[BIS_fnc_MP]];</code> |Example 4=
____________________________________________________________________________________________
____________________________________________________________________________________________


| |= See also
| [[BIS_fnc_MPexec]] [[Arma_3_Remote_Execution|Remote Execution]] |See also=
 
}}
}}


Line 45: Line 51:
<dl class="command_description">
<dl class="command_description">
<!-- Note Section BEGIN -->
<!-- Note Section BEGIN -->
<dd class="notedate">Posted on 2 April, 2013
<dd class="notedate">Posted on 2 April, 2013
<dt class="note">[[User:Fireball|Fireball]]
<dt class="note">[[User:Fireball|Fireball]]
Line 56: Line 63:


You can also execute scripts remotely like this:
You can also execute scripts remotely like this:
<code><nowiki>[</nowiki>"myScript.sqf","BIS_fnc_execVM",true,true] spawn BIS_fnc_MP;</code>
<code><nowiki>[</nowiki>"myScript.sqf","[[BIS_fnc_execVM]]",[[true]],[[true]] ] [[call]] [[BIS_fnc_MP]];</code>


Or transfer code as parameter (not recommended) like that:
Or transfer code as parameter (not recommended) like that:
<code><nowiki>[</nowiki>"{hint "Hello World!";}","BIS_fnc_spawn",true,true] spawn BIS_fnc_MP;</code>
<code><nowiki>[</nowiki>{[[hint]] "Hello World!";},"[[BIS_fnc_spawn]]",[[true]],[[true]]] [[call]] [[BIS_fnc_MP]];</code>


<dd class="notedate">Posted on 5 July, 2013
<dd class="notedate">Posted on 5 July, 2013
Line 75: Line 82:
<dt class="note">[[User:Killzone_Kid|Killzone_Kid]]
<dt class="note">[[User:Killzone_Kid|Killzone_Kid]]
<dd class="note">
<dd class="note">
If you need to achieve a single global execution of an existing function on all PCs including your own, the syntax could not be any more simple than: [arguments, functionname] [[call]] [[BIS_fnc_MP]]; This is particularly useful with commands such as [[switchMove]] where the command arguments and effect are [[local]].  
If you need to achieve a single global execution of an existing function on all PCs including your own, the syntax could not be any more simple than: [arguments, functionname] [[call]] [[BIS_fnc_MP]]; This is particularly useful with commands such as [[switchMove]] where the command effect is [[local]].  


For example to make sure animation is played on every PC, first define a global function on every PC (maybe inside init.sqf):
For example to make sure animation is played on every PC, first define a global function on every PC (maybe inside init.sqf):


<code>switchMoveEverywhere = [[compileFinal]] "
<code>switchMoveEverywhere = [[compileFinal]] "
_this [[select]] 0 [[switchMove]] (_this select 1);
_this [[select]] 0 [[switchMove]] (_this [[select]] 1);
";</code>
";</code>
Then execute this function everywhere:
Then execute [[BIS_fnc_MP]] on only one PC which will in return execute ''switchMoveEverywhere'' function everywhere:


<code>[
<code>[
Line 93: Line 100:




<dd class="notedate">Posted on May 23, 2015 - 21:47 (UTC)</dd>
<dt class="note">[[User:Waffle SS.|Waffle SS.]]</dt>
<dd class="note">
Adding onto what Killzone_Kid said, a custom function isn't necessary when using only a single command.
<code>[
[ [[player]],"AmovPercMstpSrasWrflDnon_AadjPpneMstpSrasWrflDleft"],
"[[switchMove]]"
] [[call]] [[BIS_fnc_MP]];</code></dd>
<dd class="notedate">Posted on June 8, 2015 - 12:08 (UTC)</dd>
<dt class="note">[[User:Warka|Warka]]</dt>
<dd class="note">
{{GVI|arma3|1.50}}
* From version 1.50 the function bis_fnc_mp will use the engine based remote execution.
* This will positively affect its performance, namely processing speed and amount of transferred data.
* The syntax and functionality of bis_fnc_mp will remain same to retain the backward compatibility.
* To prevent abusing of the remoteExec and remoteExecCall commands the bis_fnc_mp will use, the content authors will be able to define the operation modes as well as white-lists for commands/functions for clients and server separately.
* White-lists defined in ''[[CfgRemoteExecCommands]]'' and ''[[CfgRemoteExecFunctions]]'' won't be supported from 1.48 as they will be replaced by the new structure more powerful and detailed structure: [[CfgRemoteExec]].
</dd>
<dd class="notedate">Posted on July 20, 2015 - 21:07 (UTC)</dd>
<dt class="note">[[User:Waffle SS.|Waffle SS.]]</dt>
<dd class="note">
Pay close attention to where and when you call '''BIS_fnc_MP'''. If you use it on the server during init, it will probably run before the player is loaded into the server, and the player behaves more like a JIP. Either waiting for the briefing to end ([[time]] > 0), or using the JIP parameter in '''BIS_fnc_MP''' are two ways of getting around this issue.
</dd>


<!-- Note Section END -->
<!-- Note Section END -->
Line 98: Line 130:


<h3 style="display:none">Bottom Section</h3>
<h3 style="display:none">Bottom Section</h3>
[[Category:Functions|{{uc:MP}}]]


[[Category:Arma 3:_Functions|mp]]
[[Category:{{Name|tkoh}}: Functions|{{uc:MP}}]]
[[Category:Function Group: Debug|mp]]
[[Category:{{Name|arma3}}: Functions|{{uc:MP}}]]
{{GameCategory|arma3| Remote Execution}}

Revision as of 02:31, 5 January 2021

Hover & click on the images for description

Description

Description:
Send function for remote execution (and executes locally if conditions are met).
Arma 3 logo black.png1.50 This function has been replaced by remoteExec and remoteExecCall. While BIS_fnc_MP still works (to provide backwards compatibility), it is now deprecated and should no longer be used. See Arma 3: Remote Execution for more information.
Function syntax in Take On Helicopters differs, see BIS_fnc_MP (Take On Helicopters) for details.
Execution:
call
Groups:
Multiplayer

Syntax

Syntax:
[params, functionName, target, isPersistent, isCall] call BIS_fnc_MP;
Parameters:
params: Anything - function arguments. Variables can be local.
functionName: String - function or scripting command name.
target:
  • Object - the function will be executed only where unit is local [default: everyone]
  • String - the function will be executed only where object or group defined by the variable with passed name is local
  • Boolean - true to execute on each machine (including the one where the function was called from), false to execute it on server only
  • Number - function will be executed only on client with the given owner ID
  • Side - function will be executed only on clients where the player is on the specified side
  • Group - function will be executed only on clients where the player is in the specified group
  • Array - array of targets of types listed above
isPersistent: Boolean - true for persistent call (will be called now and for every JIP client) [default: false]
isCall: Boolean - (optional) true if function should be called on target machine, false to spawn it [default: false]
Return Value:
Array - sent packet

Examples

Example 1:
// Logs a message for every player on the server. ["Imma spamming your log!", "BIS_fnc_log"] call BIS_fnc_MP;
Example 2:
// Send a hint containing "Hello World" to every player, including the ones who joins later using JIP. ["Hello World", "hint", true, true] call BIS_fnc_MP;
Example 3:
// Executes playerConnected.sqf script on server every time a player joins the game. [[[],"playerConnected.sqf"], "BIS_fnc_execVM", false, true] call BIS_fnc_MP;
Example 4:
// Adds action to every player including JIP. "..." = further optional arguments (see addAction) [[player, ["My Action Title", "myAction.sqf", ...]], "addAction", true, true] call BIS_fnc_MP;

Additional Information

See also:
BIS_fnc_MPexec Remote Execution

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note

Notes

Posted on 2 April, 2013
Fireball
Note that the function you provide as argument is *not* transferred to the remote client or server. You will have to use either
  1. functions defined in global namespace
  2. functions defined depending on where you want to execute them; in server or/and client code if you separate it using conditions on isServer or local player
  3. pre-defined BIS functions
You can also execute scripts remotely like this: ["myScript.sqf","BIS_fnc_execVM",true,true ] call BIS_fnc_MP; Or transfer code as parameter (not recommended) like that: [{hint "Hello World!";},"BIS_fnc_spawn",true,true] call BIS_fnc_MP;
Posted on 5 July, 2013
kylania
"One key note when designing a mission/script is to limit the amount of use you make of the isPersistent parameter. It is not recommended to use it often for vehicle creation, object creation, etc. Each time you use the isPersistent parameter it adds to a BIS Logic which is used to sync all clients and new clients that join, excessive use of the command will make the logic build up and eventually you will cause the server to desync out because of the massive amount of data it has to send to all clients and JIP clients to try to keep them in sync. It is highly recommended to make as little use as possible of the isPersistent option unless you have to for network performance sake." -Tonic
Posted on 10 December, 2013
Killzone_Kid
If you need to achieve a single global execution of an existing function on all PCs including your own, the syntax could not be any more simple than: [arguments, functionname] call BIS_fnc_MP; This is particularly useful with commands such as switchMove where the command effect is local. For example to make sure animation is played on every PC, first define a global function on every PC (maybe inside init.sqf): switchMoveEverywhere = compileFinal " _this select 0 switchMove (_this select 1); "; Then execute BIS_fnc_MP on only one PC which will in return execute switchMoveEverywhere function everywhere: [ [ player, "AmovPercMstpSrasWrflDnon_AadjPpneMstpSrasWrflDleft" ], "switchMoveEverywhere" ] call BIS_fnc_MP;
Posted on May 23, 2015 - 21:47 (UTC)
Waffle SS.
Adding onto what Killzone_Kid said, a custom function isn't necessary when using only a single command. [ [ player,"AmovPercMstpSrasWrflDnon_AadjPpneMstpSrasWrflDleft"], "switchMove" ] call BIS_fnc_MP;
Posted on June 8, 2015 - 12:08 (UTC)
Warka
Arma 3 logo black.png1.50
  • From version 1.50 the function bis_fnc_mp will use the engine based remote execution.
  • This will positively affect its performance, namely processing speed and amount of transferred data.
  • The syntax and functionality of bis_fnc_mp will remain same to retain the backward compatibility.
  • To prevent abusing of the remoteExec and remoteExecCall commands the bis_fnc_mp will use, the content authors will be able to define the operation modes as well as white-lists for commands/functions for clients and server separately.
  • White-lists defined in CfgRemoteExecCommands and CfgRemoteExecFunctions won't be supported from 1.48 as they will be replaced by the new structure more powerful and detailed structure: CfgRemoteExec.
Posted on July 20, 2015 - 21:07 (UTC)
Waffle SS.
Pay close attention to where and when you call BIS_fnc_MP. If you use it on the server during init, it will probably run before the player is loaded into the server, and the player behaves more like a JIP. Either waiting for the briefing to end (time > 0), or using the JIP parameter in BIS_fnc_MP are two ways of getting around this issue.

Bottom Section