2015-01-11 16:42:31 +00:00
|
|
|
/*
|
|
|
|
* Author: commy2
|
|
|
|
* Execute a function on a remote machine in mp.
|
|
|
|
*
|
2015-09-20 18:25:25 +00:00
|
|
|
* Arguments:
|
|
|
|
* 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. (default: 2) <OBJECT, NUMBER>
|
|
|
|
* 0 = execute on this machine only
|
|
|
|
* 1 = execute on server
|
|
|
|
* 2 = execute on all clients + server
|
|
|
|
* 3 = execute on dedicated only
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Public: No
|
2015-01-11 16:42:31 +00:00
|
|
|
*
|
2015-09-20 18:25:25 +00:00
|
|
|
* Deprecated
|
2015-01-11 16:42:31 +00:00
|
|
|
*/
|
2015-01-13 19:56:02 +00:00
|
|
|
#include "script_component.hpp"
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2016-01-19 14:54:59 +00:00
|
|
|
ACE_DEPRECATED("ace_common_fnc_execRemoteFnc","3.7.0","ace_common_fnc_globalEvent");
|
2016-01-08 14:56:32 +00:00
|
|
|
|
2015-01-11 16:42:31 +00:00
|
|
|
GVAR(remoteFnc) = _this;
|
|
|
|
|
2015-09-20 18:25:25 +00:00
|
|
|
params ["_arguments", "_function", ["_unit", 2]];
|
2015-10-04 02:34:46 +00:00
|
|
|
TRACE_3("params", _arguments, _function, _unit);
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2015-09-20 18:25:25 +00:00
|
|
|
_function = call compile _function;
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2015-11-20 17:40:31 +00:00
|
|
|
if (_unit isEqualType 0) exitWith {
|
2015-05-14 18:06:06 +00:00
|
|
|
switch (_unit) do {
|
|
|
|
case 0 : {
|
|
|
|
_arguments call _function;
|
|
|
|
};
|
|
|
|
case 1 : {
|
|
|
|
if (isServer) then {
|
|
|
|
_arguments call _function;
|
|
|
|
} else {
|
|
|
|
publicVariableServer QGVAR(remoteFnc);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
case 2 : {
|
|
|
|
_arguments call _function;
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2015-05-14 18:06:06 +00:00
|
|
|
GVAR(remoteFnc) set [2, 0];
|
|
|
|
publicVariable QGVAR(remoteFnc);
|
|
|
|
};
|
|
|
|
case 3 : {
|
|
|
|
if (isDedicated) then {
|
|
|
|
_arguments call _function;
|
|
|
|
} else {
|
|
|
|
if (!isServer) then {publicVariableServer QGVAR(remoteFnc)};
|
|
|
|
};
|
|
|
|
};
|
2015-01-11 16:42:31 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
if (local _unit) then {
|
2015-05-14 18:06:06 +00:00
|
|
|
_arguments call _function;
|
2015-01-11 16:42:31 +00:00
|
|
|
} else {
|
2015-05-14 18:06:06 +00:00
|
|
|
if (isServer) then {
|
2015-09-20 18:25:25 +00:00
|
|
|
(owner _unit) publicVariableClient QGVAR(remoteFnc);
|
2015-05-14 18:06:06 +00:00
|
|
|
} else {
|
|
|
|
publicVariableServer QGVAR(remoteFnc);
|
|
|
|
};
|
2015-01-11 16:42:31 +00:00
|
|
|
};
|