2015-01-11 16:42:31 +00:00
|
|
|
/*
|
|
|
|
* Author: commy2
|
|
|
|
*
|
|
|
|
* Execute a function on a remote machine in mp.
|
|
|
|
*
|
|
|
|
* Argument:
|
|
|
|
* 0: Function arguments (Array)
|
|
|
|
* 1: Function to execute, has to be defined on the remote machine first (String)
|
|
|
|
* 2: The function will be executed where this unit is local OR the mode were this function should be executed. (Object OR Number, optional default: 2)
|
|
|
|
* Mode 0: execute on this machine only
|
|
|
|
* Mode 1: execute on server
|
|
|
|
* Mode 2: execute on all clients + server
|
|
|
|
* Mode 3: execute on dedicated only
|
|
|
|
*
|
|
|
|
* Return value:
|
|
|
|
* Nothing
|
|
|
|
*/
|
|
|
|
|
|
|
|
private ["_arguments", "_function", "_unit", "_id"];
|
|
|
|
|
|
|
|
GVAR(remoteFnc) = _this;
|
|
|
|
|
|
|
|
_arguments = _this select 0;
|
|
|
|
_function = call compile (_this select 1);
|
|
|
|
_unit = _this select 2;
|
|
|
|
|
|
|
|
if (isNil "_unit") then {
|
|
|
|
_unit = 2;
|
|
|
|
};
|
|
|
|
|
|
|
|
["Remote", [_arguments, _this select 1, _unit], {format ["%1 call %2 to: %3", _this select 0, _this select 1, _this select 2]}, false] call AGM_Debug_fnc_log;
|
|
|
|
|
|
|
|
if (typeName _unit == "SCALAR") exitWith {
|
|
|
|
switch (_unit) do {
|
|
|
|
case 0 : {
|
|
|
|
_arguments call _function;
|
|
|
|
};
|
|
|
|
case 1 : {
|
|
|
|
if (isServer) then {
|
|
|
|
_arguments call _function;
|
|
|
|
} else {
|
2015-01-11 18:20:14 +00:00
|
|
|
publicVariableServer QGVAR(remoteFnc);
|
2015-01-11 16:42:31 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
case 2 : {
|
|
|
|
_arguments call _function;
|
|
|
|
|
|
|
|
GVAR(remoteFnc) set [2, 0];
|
2015-01-11 18:20:14 +00:00
|
|
|
publicVariable QGVAR(remoteFnc);
|
2015-01-11 16:42:31 +00:00
|
|
|
};
|
|
|
|
case 3 : {
|
|
|
|
if (isDedicated) then {
|
|
|
|
_arguments call _function;
|
|
|
|
} else {
|
2015-01-11 18:20:14 +00:00
|
|
|
if (!isServer) then {publicVariableServer QGVAR(remoteFnc)};
|
2015-01-11 16:42:31 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
if (local _unit) then {
|
|
|
|
_arguments call _function;
|
|
|
|
} else {
|
|
|
|
if (isServer) then {
|
|
|
|
_id = owner _unit;
|
2015-01-11 18:20:14 +00:00
|
|
|
_id publicVariableClient QGVAR(remoteFnc);
|
2015-01-11 16:42:31 +00:00
|
|
|
} else {
|
2015-01-11 18:20:14 +00:00
|
|
|
publicVariableServer QGVAR(remoteFnc);
|
2015-01-11 16:42:31 +00:00
|
|
|
};
|
|
|
|
};
|