mirror of
https://github.com/EpochModTeam/DayZ-Epoch.git
synced 2025-12-13 19:52:38 +03:00
Merge pull request #2060 from worldwidesorrow/master
Move bear trap monitor to the server scheduler.
This commit is contained in:
@@ -5,6 +5,7 @@ call compile preprocessFileLineNumbers (PATH+"sched_lootpiles.sqf");
|
|||||||
call compile preprocessFileLineNumbers (PATH+"sched_sync.sqf");
|
call compile preprocessFileLineNumbers (PATH+"sched_sync.sqf");
|
||||||
call compile preprocessFileLineNumbers (PATH+"sched_safetyVehicle.sqf");
|
call compile preprocessFileLineNumbers (PATH+"sched_safetyVehicle.sqf");
|
||||||
call compile preprocessFileLineNumbers (PATH+"sched_event.sqf");
|
call compile preprocessFileLineNumbers (PATH+"sched_event.sqf");
|
||||||
|
call compile preprocessFileLineNumbers (PATH+"sched_traps.sqf");
|
||||||
|
|
||||||
[
|
[
|
||||||
// period offset code <-> ctx init code ->ctx
|
// period offset code <-> ctx init code ->ctx
|
||||||
@@ -14,7 +15,8 @@ call compile preprocessFileLineNumbers (PATH+"sched_event.sqf");
|
|||||||
[ 6, 340, sched_lootpiles ],
|
[ 6, 340, sched_lootpiles ],
|
||||||
[ 900, 0, sched_sync ],
|
[ 900, 0, sched_sync ],
|
||||||
[ 120, 48, sched_safetyVehicle ],
|
[ 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");
|
] execFSM ("z\addons\dayz_code\system\scheduler\scheduler.fsm");
|
||||||
|
|
||||||
//diag_log [ __FILE__, "Scheduler started"];
|
//diag_log [ __FILE__, "Scheduler started"];
|
||||||
|
|||||||
49
SQF/dayz_server/system/scheduler/sched_traps.sqf
Normal file
49
SQF/dayz_server/system/scheduler/sched_traps.sqf
Normal file
@@ -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]
|
||||||
|
};
|
||||||
@@ -361,46 +361,6 @@ allowConnection = true;
|
|||||||
sm_done = true;
|
sm_done = true;
|
||||||
publicVariable "sm_done";
|
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";
|
execVM "\z\addons\dayz_server\system\lit_fireplaces.sqf";
|
||||||
|
|
||||||
"PVDZ_sec_atp" addPublicVariableEventHandler {
|
"PVDZ_sec_atp" addPublicVariableEventHandler {
|
||||||
|
|||||||
Reference in New Issue
Block a user