Multiplayer Framework – Arma 2
Note: this page is a work-in-progress! More info to follow as soon as possible.
Introduction
- 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
- allows execution only on client where target object is local
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
- Script remExWrite.sqf is called with parameters that says: who executes, upon who, [only where local], which scripted command and parameters for scripted command on target client follow
- remExWrite.sqf writes in public variable remExField
- 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.)
- (if wanted) remExServer.sqf calls script (given as argument) on client that runs even handler
Note: remote execution executes script also on calling client (if "loc" flag not set or "loc" 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)
- In scripts or fsms call: _handler = [...] call RE; (syntax - see below; RE stands for remote execution)
Format
_nic = [nil_or_caller, nil_or_target_object,"loc", script_to_execute, par0, par1...] call RE; _nic = [nil_or_caller, nil_or_target_object,"per", script_to_execute, par0, par1...] call RE; _nic = [nil_or_caller, nil_or_target_object,"loc" + "per", script_to_execute, par0, par1...] call RE;
- RE...remote execution (short for remExWrite.sqf)
- "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
Examples
Hint on all clients currently connected to the MP game:
_nic = [nil,nil,rHINT,"Enjoy the game."] call RE;
Setting date on all clients - including JIP clients that will join later after:
_nic = [nil,nil,"per",rSETDATE,2008,9,29,11,35] call RE;
Hint on client where object miles is local:
_nic = [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:
_nic = [nil,(units group player) select 0,"loc" + "per",rHINT,"Hint."] call RE;
Implementation
- remExServer
- remExWrite
- library - should contain only scripts that mirror 1:1 the function of single non-global script commands
- custom library - enhanced functionality (eg. new parameters to scripting commands or more scripting commands triggered by one MPF call)