Multiplayer Framework – Arma 2

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Lou Montana moved page Multiplayer framework to Arma2: Multiplayer Framework: name standard)
m (Remove duplicates, sort ascending)
(11 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Feature arma3|This page is about {{arma2}} and doesn't apply to {{arma3}}. In {{arma3}}, use [[remoteExec]] or [[remoteExecCall]].}}
{{Feature|arma3|This page is about {{arma2}} and does not apply to {{arma3}}. In {{arma3}}, use [[remoteExec]] or [[remoteExecCall]].}}








{{SideTOC}}
{{TOC|side}}
'''Multiplayer Framework''' (MPF or MPf) is a library that helps MP mission creation, regarding some commands' locality.
'''Multiplayer Framework''' (MPF or MPf) is a library that helps MP mission creation, regarding some commands' locality.
* library of scripts that are performing non-global script commands globally on network
* library of scripts that are performing non-global script commands globally on network
Line 12: Line 12:
* allows persistent calls - are performed on JIP client even if server processed given MPF call before client connected to game ("per" switch)
* allows persistent calls - are performed on JIP client even if server processed given MPF call before client connected to game ("per" switch)


{{Important | Do '''not''' overwrite '''RE''' variable in your missions when using MPF. Do not use rHINT, rSIDECHAT etc [[Identifier]]s (see library below)}}
{{Feature | important | Do '''not''' overwrite '''RE''' variable in your missions when using MPF. Do not use rHINT, rSIDECHAT etc [[Identifier]]s (see library below)}}




Line 26: Line 26:
# (if wanted) ''remExServer.sqf'' calls script (given as argument) on client that runs even handler
# (if wanted) ''remExServer.sqf'' calls script (given as argument) on client that runs even handler


{{Informative | Remote execution executes script also on calling client (if "loc" flag set, or "loc" not set and object is local on caller client)}}
{{Feature | Informative | Remote execution executes script also on calling client (if "loc" flag set, or "loc" not set and object is local on caller client)}}


=== Usage ===
=== Usage ===
Line 33: Line 33:
* Include functions module in your mission
* Include functions module in your mission
* Wait for global variable "BIS_MPF_InitDone" to be defined (and true): <code>[[waitUntil]] { !([[isNil]] "BIS_MPF_InitDone"); };</code>
* Wait for global variable "BIS_MPF_InitDone" to be defined (and true): <code>[[waitUntil]] { !([[isNil]] "BIS_MPF_InitDone"); };</code>
* In scripts or FSMs call: {{Inline code|_handler = [...] [[call]] '''RE''';}} (syntax - see below; RE stands for remote execution)
* In scripts or FSMs call: {{ic|_handler {{=}} [...] [[call]] '''RE''';}} (syntax - see below; RE stands for remote execution)


==== Format ====
==== Format ====
Line 60: Line 60:
Multiple parameters
Multiple parameters
  [<nowiki/>[[objNull]], BIS_Rodriguez , "per", rKBADDTOPIC, "armstrongs_speech",  "kb\armstrongs_speech.bikb",  ""] [[call]] '''RE''';
  [<nowiki/>[[objNull]], BIS_Rodriguez , "per", rKBADDTOPIC, "armstrongs_speech",  "kb\armstrongs_speech.bikb",  ""] [[call]] '''RE''';
{{note | "kb\armstrongs_speech.bikb" becomes (_this select 1) in kbAddTopic.sqf library script}}
{{Feature | Informative | "kb\armstrongs_speech.bikb" here becomes {{ic|(_this [[select]] 1)}} in '''kbAddTopic.sqf''' library script.}}




Line 68: Line 68:
* remExWrite
* remExWrite
* library  
* library  
* custom library (division to library and custom library introduced in 1.03)
* custom library (division to library and custom library introduced in {{arma2}} v1.03)


=== Library + custom Library ===
=== Library + custom Library ===
Line 83: Line 83:
! Additional Information
! Additional Information
|-
|-
| move || [[move]] || rMOVE ||
| addAction || [[addAction]] || rADDACTION ||
|-
| addMagazine || [[addMagazine]] || rADDMAGAZINE ||
|-
| addMagazineCargo || [[addMagazineCargo]] || rADDMAGAZINECARGO ||
|-
|-
| moveIn || {{n/a}} || rMOVEIN || can replace [[moveInDriver]], [[moveInGunner]], [[moveInCommander]], [[moveInCargo]]
| addWeapon || [[addWeapon]] || rADDWEAPON ||
|-
|-
| land || [[land]] || rLAND ||
| addWeaponCargo || [[addWeaponCargo]] || rADDWEAPONCARGO ||
|-
|-
| addWPCur || {{n/a}} || rADDWPCUR || takes object and for his group on his local sets current WP
| addWPCur || {{n/a}} || rADDWPCUR || takes object and for his group on his local sets current WP
Line 93: Line 97:
| animate || [[animate]] || rANIMATE ||
| animate || [[animate]] || rANIMATE ||
|-
|-
| setDate || [[setDate]] || rSETDATE ||
| callVar || {{n/a}} || rCALLVAR || (1.03) - calls code that is stored in variable on client
|-
| clearMagazineCargo || [[clearMagazineCargo]] || rCLEARMAGAZINECARGO ||
|-
| clearWeaponCargo || [[clearWeaponCargo]] || rCLEARWEAPONCARGO ||
|-
|-
| playmusic || [[playMusic]] || rPLAYMUSIC ||
| createDiaryRecord || [[createDiaryRecord]] || rCREATEDIARYRECORD ||
|-
|-
| playsound || [[playSound]] || rPLAYSOUND ||
| createSimpleTask || [[createSimpleTask]] || rCREATESIMPLETASK ||
|-
|-
| switchmove || [[switchMove]] || rSWITCHMOVE ||
| createTaskSet || {{n/a}} || rCREATETASKSET ||
|-
| debugLog || [[debugLog]] || rDEBUGLOG ||
|-
|-
| playmove || [[playMove]] || rPLAYMOVE ||
| deleteWP || [[deleteWaypoint]] || rDELETEWP ||
|-
|-
| playmovenow || [[playMoveNow]] || rPLAYMOVENOW ||
| enableSimulation || [[enableSimulation]] || rENABLESIMULATION ||
|-
|-
| playAction || [[playAction]] || rPLAYACTION ||
| endMission || [[endMission]] || rENDMISSION ||
|-
|-
| playActionnow || [[playActionNow]] || rPLAYACTIONNOW ||
| execFSM || [[execFSM]] || rEXECFSM ||
|-
|-
| switchAction || [[switchAction]] || rSWITCHACTION ||
| execVM || [[execVM]] || rEXECVM ||
|-
|-
| hint || [[hint]] || rHINT ||
| fadeMusic || [[fadeMusic]] || rFADEMUSIC ||
|-
|-
| hintC || [[hintC]] || rHINTC ||
| fadeSound || [[fadeSound]] || rFADESOUND ||
|-
|-
| showCommandingMenu || [[showCommandingMenu]] || rSHOWCOMMANDINGMENU ||
| failMission || [[failMission]] || rFAILMISSION ||
|-
|-
| globalChat || [[globalChat]] || rGLOBALCHAT ||
| globalChat || [[globalChat]] || rGLOBALCHAT ||
|-
|-
| globalRadio || [[globalRadio]] || rGLOBALRADIO ||
| globalRadio || [[globalRadio]] || rGLOBALRADIO ||
|-
| sideChat || [[sideChat]] || rSIDECHAT ||
|-
| sideRadio || [[sideRadio]] || rSIDERADIO ||
|-
|-
| groupChat || [[groupChat]] || rGROUPCHAT ||
| groupChat || [[groupChat]] || rGROUPCHAT ||
Line 129: Line 135:
| groupRadio || [[groupRadio]] || rGROUPRADIO ||
| groupRadio || [[groupRadio]] || rGROUPRADIO ||
|-
|-
| kbAddTopic || [[kbAddTopic]] || rKBADDTOPIC ||
| hint || [[hint]] || rHINT ||
|-
|-
| kbRemoveTopic || [[kbRemoveTopic]] || rKBREMOVETOPIC ||
| hintC || [[hintC]] || rHINTC ||
|-
|-
| kbtell || [[kbTell]] || rKBTELL ||
| JIPexec || {{n/a}} || rJIPEXEC || custom scripting functions
|-
|-
| kbreact || [[kbReact]] || rKBREACT ||
| JIPrequest || {{n/a}} || rJIPREQUEST || requesting JIP (RE persistent commands) from server by executing this via RE (on server) - parameter: logic local on client
|-
|-
| deleteWP || [[deleteWaypoint]] || rDELETEWP ||
| kbAddTopic || [[kbAddTopic]] || rKBADDTOPIC ||
|-
|-
| setWPdesc || [[setWaypointDescription]] || rSETWPDESC ||
| kbReact || [[kbReact]] || rKBREACT ||
|-
|-
| setWPtype || [[setWaypointType]] || rSETWPTYPE ||
| kbRemoveTopic || [[kbRemoveTopic]] || rKBREMOVETOPIC ||
|-
|-
| createSimpleTask || [[createSimpleTask]] || rCREATESIMPLETASK ||
| kbTell || [[kbTell]] || rKBTELL ||
|-
|-
| taskHint || [[taskHint]] || rTASKHINT ||
| land || [[land]] || rLAND ||
|-
|-
| createDiaryRecord || [[createDiaryRecord]] || rCREATEDIARYRECORD ||
| move || [[move]] || rMOVE ||
|-
|-
| removeAllWeapons || [[removeAllWeapons]] ||rREMOVEALLWEAPONS ||
| moveIn || {{n/a}} || rMOVEIN || can replace [[moveInDriver]], [[moveInGunner]], [[moveInCommander]], [[moveInCargo]]
|-
|-
| addWeapon || [[addWeapon]] || rADDWEAPON ||
| playAction || [[playAction]] || rPLAYACTION ||
|-
|-
| addWeaponCargo || [[addWeaponCargo]] || rADDWEAPONCARGO ||
| playActionNow || [[playActionNow]] || rPLAYACTIONNOW ||
|-
|-
| addMagazine || [[addMagazine]] || rADDMAGAZINE ||
| playMove || [[playMove]] || rPLAYMOVE ||
|-
|-
| addMagazineCargo || [[addMagazineCargo]] || rADDMAGAZINECARGO ||
| playMoveNow || [[playMoveNow]] || rPLAYMOVENOW ||
|-
|-
| clearMagazineCargo || [[clearMagazineCargo]] || rCLEARMAGAZINECARGO ||
| playMusic || [[playMusic]] || rPLAYMUSIC ||
|-
|-
| clearWeaponCargo || [[clearWeaponCargo]] || rCLEARWEAPONCARGO ||
| playSound || [[playSound]] || rPLAYSOUND ||
|-
|-
| endMission || [[endMission]] || rENDMISSION ||
| removeAction || [[removeAction]] || rREMOVEACTION ||
|-
|-
| failMission || [[failMission]] || rFAILMISSION ||
| removeAllWeapons || [[removeAllWeapons]] ||rREMOVEALLWEAPONS ||
|-
| titleCut || [[titleCut]] || rTITLECUT ||
|-
| titleText || [[titleText]] || rTITLETEXT ||
|-
|-
| say || [[say]] || rSAY ||
| say || [[say]] || rSAY ||
|-
|-
| playMusic || [[playMusic]] || rPLAYMUSIC ||
| setCaptive || [[setCaptive]] || rSETCAPTIVE ||
|-
|-
| switchCamera || [[switchCamera]] || rSWITCHCAMERA ||
| setCurrentTask || [[setCurrentTask]] || rSETCURRENTTASK ||
|-
|-
| fadeMusic || [[fadeMusic]] || rFADEMUSIC ||
| setCurrentTaskArrays || {{n/a}} || rSETCURRENTTASKARRAYS ||
|-
|-
| fadeSound || [[fadeSound]] || rFADESOUND ||
| setDate || [[setDate]] || rSETDATE ||
|-
|-
| addAction || [[addAction]] || rADDACTION ||
| setDir || [[setDir]] || rSETDIR || '''caution:''' often gets overwritten by the server, tied to [[setPos]]
|-
|-
| removeAction || [[removeAction]] || rREMOVEACTION ||
| setObjectTexture || [[setObjectTexture]] || rSETOBJECTEXTURE ||
|-
|-
| setCaptive || [[setCaptive]] || rSETCAPTIVE ||
| setSimpleTaskDescription || [[setSimpleTaskDescription]] || rSETSIMPLETASKDESCRIPTION ||
|-
|-
| setDir || [[setDir]] || rSETDIR || '''caution:''' works weird (often overwritten by server, tied to [[setPos]]
| setSimpleTaskDestination || [[setSimpleTaskDestination]] || rSETSIMPLETASKDESTINATION ||
|-
|-
| setObjectTexture || [[setObjectTexture]] || rSETOBJECTEXTURE ||
| setTaskState || [[setTaskState]] || rSETTASKSTATE ||
|-
|-
| execfsm || [[execFSM]] || rEXECFSM ||
| setWPdesc || [[setWaypointDescription]] || rSETWPDESC ||
|-
|-
| execVM || [[execVM]] || rEXECVM ||
| setWPtype || [[setWaypointType]] || rSETWPTYPE ||
|-
|-
| spawn || [[spawn]] || rSPAWN ||
| showCommandingMenu || [[showCommandingMenu]] || rSHOWCOMMANDINGMENU ||
|-
|-
| JIPrequest || {{n/a}} || rJIPREQUEST || requesting JIP (RE persistent commands) from server by executing this via RE (on server) - parameter: logic local on client
| sideChat || [[sideChat]] || rSIDECHAT ||
|-
|-
| JIPexec || {{n/a}} || rJIPEXEC || custom scripting functions
| sideRadio || [[sideRadio]] || rSIDERADIO ||
|-
|-
| skiptime || [[skipTime]] || rSKIPTIME || bad
| skipTime || [[skipTime]] || rSKIPTIME || bad
|-
|-
| setSimpleTaskDescription || [[setSimpleTaskDescription]] || rSETSIMPLETASKDESCRIPTION ||
| spawn || [[spawn]] || rSPAWN ||
|-
|-
| setSimpleTaskDestination || [[setSimpleTaskDestination]] || rSETSIMPLETASKDESTINATION ||
| switchAction || [[switchAction]] || rSWITCHACTION ||
|-
|-
| setCurrentTask || [[setCurrentTask]] || rSETCURRENTTASK ||
| switchCamera || [[switchCamera]] || rSWITCHCAMERA ||
|-
|-
| setCurrentTaskArrays || {{n/a}} || rSETCURRENTTASKARRAYS ||
| switchMove || [[switchMove]] || rSWITCHMOVE ||
|-
|-
| createTaskSet || {{n/a}} || rCREATETASKSET ||
| taskHint || [[taskHint]] || rTASKHINT ||
|-
|-
| setTaskState || [[setTaskState]] || rSETTASKSTATE ||
| titleCut || [[titleCut]] || rTITLECUT ||
|-
|-
| debugLog || [[debugLog]] || rDEBUGLOG ||
| titleText || [[titleText]] || rTITLETEXT ||
|-
| enablesimulation || [[enableSimulation]] || rENABLESIMULATION ||
|-
| callVar || {{n/a}} || rCALLVAR || (1.03) - calls code that is stored in variable on client
|}
|}




[[Category:Arma 2:_Editor_Modules]]
{{GameCategory|arma2|Editor Modules}}

Revision as of 19:05, 28 March 2021

Arma 3
This page is about Arma 2 and does not apply to Arma 3. In Arma 3, use remoteExec or remoteExecCall.



Multiplayer Framework (MPF or MPf) is a library that helps MP mission creation, regarding some commands' locality.

  • library of scripts that are performing non-global script commands globally on network
  • using publicVariable + addPublicVariableEventHandler (EH that fires for each publicVariabled variable on all clients - excluding calling client) + direct call on calling client
  • easy use: R-commands match function of single non-global scripting commands (eg. MPF 'rHINT' call is doing 'hint' on clients)
  • allows execution only on client where target object is local ("loc" switch)
  • allows persistent calls - are performed on JIP client even if server processed given MPF call before client connected to game ("per" switch)
Do not overwrite RE variable in your missions when using MPF. Do not use rHINT, rSIDECHAT etc Identifiers (see library below)


Remote script execution (RE)

On all clients is public variable eventhandler that executes scripts that corresponds to less-than-100-percent-multiplayer-working script commands. One script for one commands, no string sending that will be compiled and executed for the sake of clarity and easiness of creating MP-friendly commands from the engine MP-unfriendly ones.

Function

  1. Script remExWrite.sqf is called with parameters that says: who executes, upon who, [only where local and/or persistent], which scripted command and parameters for scripted command on target client follow
  2. remExWrite.sqf writes in public variable remExField
  3. Change in remExField triggers execution of eventhandlers on all clients in the network game (initialized in init.sqf), script remExServer.sqf interpretes remExField (remExFP resp.)
  4. (if wanted) remExServer.sqf calls script (given as argument) on client that runs even handler
Remote execution executes script also on calling client (if "loc" flag set, or "loc" not set and object is local on caller client)

Usage

How-to

  • Include functions module in your mission
  • Wait for global variable "BIS_MPF_InitDone" to be defined (and true): waitUntil { !(isNil "BIS_MPF_InitDone"); };
  • In scripts or FSMs call: _handler = [...] call RE; (syntax - see below; RE stands for remote execution)

Format

[nil_or_caller, nil_or_target_object, "loc", script_to_execute, par0, par1...] call RE;
[nil_or_caller, nil_or_target_object, "per", script_to_execute, par0, par1...] call RE;
[nil_or_caller, nil_or_target_object, "loc" + "per", script_to_execute, par0, par1...] call RE;
  • "loc"...arbitrary parameter - executes remote script only on machine where nil_or_target_object is local
  • "per"...arbitrary parameter - executes remote script even on JIP client connectiong *after* this RE call was executed in MP game
  • script_to_execute - usually r + uppercase command (see available commands) e.g for hint: rHINT
  • RE...remote execution (short for remExWrite.sqf)

Examples

Hint on all clients currently connected to the MP game:

[nil, nil, rHINT, "Enjoy the game."] call RE;

Hint on all clients currently connected to the MP game + executed also on JIP client just after connection

[nil, nil, "per", rHINT, "Enjoy the game."] call RE;

Hint on client where object miles is local:

[nil, miles, "loc", rHINT, "Miles is local here."] call RE;

Hint on client where number 0 from players group is local. If JIP client connects to this slot, he got also his msg displayed:

[nil, (units group player) select 0, "loc" + "per", rHINT, "Hint."] call RE;

Multiple parameters

[objNull, BIS_Rodriguez , "per", rKBADDTOPIC, "armstrongs_speech",  "kb\armstrongs_speech.bikb",  ""] call RE;
"kb\armstrongs_speech.bikb" here becomes (_this select 1) in kbAddTopic.sqf library script.


Implementation

  • remExServer
  • remExWrite
  • library
  • custom library (division to library and custom library introduced in Arma 2 v1.03)

Library + custom Library

  • library - functionality of single non-global scripting commands
  • custom library - enhanced functionality (eg. new parameters to scripting commands or more scripting commands triggered by one MPF call)

Available Commands

name command RE equivalent Additional Information
addAction addAction rADDACTION
addMagazine addMagazine rADDMAGAZINE
addMagazineCargo addMagazineCargo rADDMAGAZINECARGO
addWeapon addWeapon rADDWEAPON
addWeaponCargo addWeaponCargo rADDWEAPONCARGO
addWPCur N/A rADDWPCUR takes object and for his group on his local sets current WP
animate animate rANIMATE
callVar N/A rCALLVAR (1.03) - calls code that is stored in variable on client
clearMagazineCargo clearMagazineCargo rCLEARMAGAZINECARGO
clearWeaponCargo clearWeaponCargo rCLEARWEAPONCARGO
createDiaryRecord createDiaryRecord rCREATEDIARYRECORD
createSimpleTask createSimpleTask rCREATESIMPLETASK
createTaskSet N/A rCREATETASKSET
debugLog debugLog rDEBUGLOG
deleteWP deleteWaypoint rDELETEWP
enableSimulation enableSimulation rENABLESIMULATION
endMission endMission rENDMISSION
execFSM execFSM rEXECFSM
execVM execVM rEXECVM
fadeMusic fadeMusic rFADEMUSIC
fadeSound fadeSound rFADESOUND
failMission failMission rFAILMISSION
globalChat globalChat rGLOBALCHAT
globalRadio globalRadio rGLOBALRADIO
groupChat groupChat rGROUPCHAT
groupRadio groupRadio rGROUPRADIO
hint hint rHINT
hintC hintC rHINTC
JIPexec N/A rJIPEXEC custom scripting functions
JIPrequest N/A rJIPREQUEST requesting JIP (RE persistent commands) from server by executing this via RE (on server) - parameter: logic local on client
kbAddTopic kbAddTopic rKBADDTOPIC
kbReact kbReact rKBREACT
kbRemoveTopic kbRemoveTopic rKBREMOVETOPIC
kbTell kbTell rKBTELL
land land rLAND
move move rMOVE
moveIn N/A rMOVEIN can replace moveInDriver, moveInGunner, moveInCommander, moveInCargo
playAction playAction rPLAYACTION
playActionNow playActionNow rPLAYACTIONNOW
playMove playMove rPLAYMOVE
playMoveNow playMoveNow rPLAYMOVENOW
playMusic playMusic rPLAYMUSIC
playSound playSound rPLAYSOUND
removeAction removeAction rREMOVEACTION
removeAllWeapons removeAllWeapons rREMOVEALLWEAPONS
say say rSAY
setCaptive setCaptive rSETCAPTIVE
setCurrentTask setCurrentTask rSETCURRENTTASK
setCurrentTaskArrays N/A rSETCURRENTTASKARRAYS
setDate setDate rSETDATE
setDir setDir rSETDIR caution: often gets overwritten by the server, tied to setPos
setObjectTexture setObjectTexture rSETOBJECTEXTURE
setSimpleTaskDescription setSimpleTaskDescription rSETSIMPLETASKDESCRIPTION
setSimpleTaskDestination setSimpleTaskDestination rSETSIMPLETASKDESTINATION
setTaskState setTaskState rSETTASKSTATE
setWPdesc setWaypointDescription rSETWPDESC
setWPtype setWaypointType rSETWPTYPE
showCommandingMenu showCommandingMenu rSHOWCOMMANDINGMENU
sideChat sideChat rSIDECHAT
sideRadio sideRadio rSIDERADIO
skipTime skipTime rSKIPTIME bad
spawn spawn rSPAWN
switchAction switchAction rSWITCHACTION
switchCamera switchCamera rSWITCHCAMERA
switchMove switchMove rSWITCHMOVE
taskHint taskHint rTASKHINT
titleCut titleCut rTITLECUT
titleText titleText rTITLETEXT