From 96a52a6e1949799657ea9027b5ca077fee155b5c Mon Sep 17 00:00:00 2001 From: worldwidesorrow Date: Wed, 12 Feb 2020 01:07:58 -0600 Subject: [PATCH 1/3] Moving bear trap monitor to the server scheduler. --- SQF/dayz_server/system/server_monitor.sqf | 40 ----------------------- 1 file changed, 40 deletions(-) diff --git a/SQF/dayz_server/system/server_monitor.sqf b/SQF/dayz_server/system/server_monitor.sqf index 14b788320..827bf7d20 100644 --- a/SQF/dayz_server/system/server_monitor.sqf +++ b/SQF/dayz_server/system/server_monitor.sqf @@ -361,46 +361,6 @@ allowConnection = true; sm_done = true; publicVariable "sm_done"; -// Trap loop -[] spawn { - private ["_array","_array2","_array3","_script","_armed"]; - _array = str dayz_traps; - _array2 = str dayz_traps_active; - _array3 = str dayz_traps_trigger; - - while {1 == 1} do { - if ((str dayz_traps != _array) || (str dayz_traps_active != _array2) || (str dayz_traps_trigger != _array3)) then { - _array = str dayz_traps; - _array2 = str dayz_traps_active; - _array3 = str dayz_traps_trigger; - //diag_log "DEBUG: traps"; - //diag_log format["dayz_traps (%2) -> %1", dayz_traps, count dayz_traps]; - //diag_log format["dayz_traps_active (%2) -> %1", dayz_traps_active, count dayz_traps_active]; - //diag_log format["dayz_traps_trigger (%2) -> %1", dayz_traps_trigger, count dayz_traps_trigger]; - //diag_log "DEBUG: end traps"; - }; - - { - if (isNull _x) then { - dayz_traps = dayz_traps - [_x]; - _armed = false; - _script = {}; - } else { - _armed = _x getVariable ["armed", false]; - _script = call compile getText (configFile >> "CfgVehicles" >> typeOf _x >> "script"); - }; - - if (_armed) then { - if !(_x in dayz_traps_active) then {["arm", _x] call _script;}; - } else { - if (_x in dayz_traps_active) then {["disarm", _x] call _script;}; - }; - uiSleep 0.01; - } forEach dayz_traps; - uiSleep 1; - }; -}; - execVM "\z\addons\dayz_server\system\lit_fireplaces.sqf"; "PVDZ_sec_atp" addPublicVariableEventHandler { From c02414114034bb83bdca76cc60e8debaaac22ee6 Mon Sep 17 00:00:00 2001 From: worldwidesorrow Date: Wed, 12 Feb 2020 01:10:22 -0600 Subject: [PATCH 2/3] Add bear trap monitor to scheduler. --- SQF/dayz_server/system/scheduler/sched_init.sqf | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/SQF/dayz_server/system/scheduler/sched_init.sqf b/SQF/dayz_server/system/scheduler/sched_init.sqf index 0495ef2f8..1ced93f40 100644 --- a/SQF/dayz_server/system/scheduler/sched_init.sqf +++ b/SQF/dayz_server/system/scheduler/sched_init.sqf @@ -5,6 +5,7 @@ call compile preprocessFileLineNumbers (PATH+"sched_lootpiles.sqf"); call compile preprocessFileLineNumbers (PATH+"sched_sync.sqf"); call compile preprocessFileLineNumbers (PATH+"sched_safetyVehicle.sqf"); call compile preprocessFileLineNumbers (PATH+"sched_event.sqf"); +call compile preprocessFileLineNumbers (PATH+"sched_traps.sqf"); [ // period offset code <-> ctx init code ->ctx @@ -14,7 +15,8 @@ call compile preprocessFileLineNumbers (PATH+"sched_event.sqf"); [ 6, 340, sched_lootpiles ], [ 900, 0, sched_sync ], [ 120, 48, sched_safetyVehicle ], - [ 360, 480, sched_fps ] + [ 360, 480, sched_fps ], + [ 30, 60, sched_traps, sched_traps_init ] ] execFSM ("z\addons\dayz_code\system\scheduler\scheduler.fsm"); //diag_log [ __FILE__, "Scheduler started"]; From c533529f705f794ca482fb70fd75b6e0255bb293 Mon Sep 17 00:00:00 2001 From: worldwidesorrow Date: Wed, 12 Feb 2020 01:12:22 -0600 Subject: [PATCH 3/3] Add files via upload --- .../system/scheduler/sched_traps.sqf | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 SQF/dayz_server/system/scheduler/sched_traps.sqf diff --git a/SQF/dayz_server/system/scheduler/sched_traps.sqf b/SQF/dayz_server/system/scheduler/sched_traps.sqf new file mode 100644 index 000000000..f3fd18424 --- /dev/null +++ b/SQF/dayz_server/system/scheduler/sched_traps.sqf @@ -0,0 +1,49 @@ +/* + This scheduled task checks for changes in the number of bear traps set by players. + It is set to run every 30 seconds by default in sched_init. + For each of the traps, it gets the "armed" variable and calls the appropriate script + to arm or disarm the bear trap. Lazy eval has been added so that the function evaluates + quickly. Bear traps are not a popular feature in DayZ Epoch. +*/ + +sched_traps_init = { + //diag_log("Bear Trap Monitor Started"); + [str dayz_traps,str dayz_traps_active,str dayz_traps_trigger] +}; + +sched_traps = { + private ["_array","_array2","_array3","_script","_armed"]; + _array = _this select 0; + _array2 = _this select 1; + _array3 = _this select 2; + + if ((str dayz_traps != _array) || {str dayz_traps_active != _array2} || {str dayz_traps_trigger != _array3}) then { + _array = str dayz_traps; + _array2 = str dayz_traps_active; + _array3 = str dayz_traps_trigger; + //diag_log "DEBUG: traps"; + //diag_log format["dayz_traps (%2) -> %1", dayz_traps, count dayz_traps]; + //diag_log format["dayz_traps_active (%2) -> %1", dayz_traps_active, count dayz_traps_active]; + //diag_log format["dayz_traps_trigger (%2) -> %1", dayz_traps_trigger, count dayz_traps_trigger]; + //diag_log "DEBUG: end traps"; + }; + + { + if (isNull _x) then { + dayz_traps = dayz_traps - [_x]; + _armed = false; + _script = {}; + } else { + _armed = _x getVariable ["armed", false]; + _script = call compile getText (configFile >> "CfgVehicles" >> typeOf _x >> "script"); + }; + + if (_armed) then { + if !(_x in dayz_traps_active) then {["arm", _x] call _script;}; + } else { + if (_x in dayz_traps_active) then {["disarm", _x] call _script;}; + }; + } forEach dayz_traps; + + [_array,_array2,_array3] +};