Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* D_sys_network - s\init.sqf - by Sickboy (sb_at_6thSense.eu)
- * --------------------------------------------------------------
- * Enables network engine support to execute code over the network
- * or make a global say command
- *
- * Notes:
- * - This init.sqf might be executed through a global init script instead of individual XEH Init EH.
- * - Net Engine can be expanded to create individual channels per player, allowing for specific net messaging etc. etc.
- * - PublicVariableEventHandlers do not 'fire' on the computer where you PV the variable. As such we execute the functions also on the computer who calls
- *
- * Examples:
- * - If you want a unit1,unit2, unit3 to say something on every computer:
- * [ [unit1, unit2, unit3], "TestSound" ] call D_NET_fSay;
- * unit1, 2 and 3 would say "TestSound" (if it existed :p)
- *
- * - To execute sth on server:
- * [ 0, { superDebugMode = true } ] call D_NET_fSend;
- *
- * - To execute sth on all clients:
- * [ -1, { superDebugMode = true; player sideChat "Woah Sweet!!" }] call D_NET_fSend;
- *
- * - To execute sth on all clients, unit1, unit2, unit3 write something
- * [ -1, { superDebugMode = true; { _x sideChat "Woah Sweet!!" } forEach _this }, [unit1, unit2, unit3]] call D_NET_fSend;
- *
- *
- */
- // Announce the initialization of the script
- D_sys_network = false;
- // Say Engine
- D_NET_fSay = { D_PUB_SAY = _this; publicVariable "D_PUB_SAY"; {_x say (_this select 1)} forEach (_this select 0) };
- "D_PUB_SAY" addPublicVariableEventHandler { private ["_ar"]; _ar =_this select 1; {_x say (_ar select 1)} forEach (_ar select 0) };
- // Net Engine
- D_NET_fSend = { D_PUB_CMD = _this; publicVariable "D_PUB_CMD"; _this call D_NET_fExec };
- D_NET_fExec =
- {
- private ["_chan", "_cmd", "_objAr", "_ex"];
- _chan = _this select 0;
- _cmd = _this select 1;
- if (count _this > 2) then { _objAr = _this select 2 } else { _objAr = [] };
- switch _chan do
- {
- case 0: { if (isServer) then { _ex = true } };
- case -1: { if (player == player) then { _ex = true } };
- case -2: { _ex = true };
- default { _ex = false };
- };
- if (_ex) then { _objAr spawn _cmd };
- };
- "D_PUB_CMD" addPublicVariableEventHandler { (_this select 1) call D_NET_fExec };
- // Announce the completion of the initialization of the script
- D_sys_network = true;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement