Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- waituntil {!isnil "bis_fnc_init"};
- BIS_MPF_remoteExecutionServer = {
- IF ((_this SELECT 1) SELECT 2 == "JIPrequest") THEN {
- [nil,(_this SELECT 1) SELECT 0,"loc",rJIPEXEC,[any,any,"per","execVM","ca\Modules\Functions\init.sqf"]] CALL RE;
- };
- };
- BIS_Effects_Burn = {};
- server_playerLogin = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_playerLogin.sqf";
- server_playerSetup = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_playerSetup.sqf";
- server_onPlayerDisconnect = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_onPlayerDisconnect.sqf";
- server_updateObject = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_updateObject.sqf";
- server_playerDied = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_playerDied.sqf";
- server_publishObj = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_publishObject.sqf";
- server_deleteObj = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_deleteObj.sqf";
- server_swapObject = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_swapObject.sqf";
- server_publishVeh = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_publishVehicle.sqf";
- server_publishVeh2 = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_publishVehicle2.sqf";
- server_publishVeh3 = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_publishVehicle3.sqf";
- server_tradeObj = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_tradeObject.sqf";
- server_traders = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_traders.sqf";
- server_playerSync = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_playerSync.sqf";
- server_spawnCrashSite = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_spawnCrashSite.sqf";
- server_spawnEvents = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_spawnEvent.sqf";
- //server_weather = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_weather.sqf";
- fnc_plyrHit = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\fnc_plyrHit.sqf";
- server_deaths = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_playerDeaths.sqf";
- server_maintainArea = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_maintainArea.sqf";
- /* PVS/PVC - Skaronator */
- server_sendToClient = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_sendToClient.sqf";
- //onPlayerConnected {[_uid,_name] CALL server_onPlayerConnect;};
- onPlayerDisconnected {[_uid,_name] CALL server_onPlayerDisconnect;};
- server_updateNearbyObjects = {
- private["_pos"];
- _pos = _this SELECT 0;
- {
- [_x, "gear"] CALL server_updateObject;
- } COUNT nearestObjects [_pos, dayz_updateObjects, 10];
- };
- server_handleZedSpawn = {
- private["_zed"];
- _zed = _this SELECT 0;
- _zed enableSimulation FALSE;
- };
- zombie_findOwner = {
- private["_unit"];
- _unit = _this SELECT 0;
- #ifdef DZE_SERVER_DEBUG
- diag_log ("CLEANUP: DELETE UNCONTROLLED ZOMBIE: " + (typeOf _unit) + " OF: " + str(_unit) );
- #endif
- deleteVehicle _unit;
- };
- vehicle_handleInteract = {
- private["_object"];
- _object = _this SELECT 0;
- needUpdate_objects = needUpdate_objects - [_object];
- [_object, "all"] CALL server_updateObject;
- };
- array_reduceSizeReverse = {
- private["_array","_count","_num","_newarray","_startnum","_index"];
- _array = _this SELECT 0;
- _newarray = [];
- _count = _this SELECT 1;
- _num = COUNT _array;
- IF (_num > _count) THEN {
- _startnum = _num - 1;
- _index = _count - 1;
- FOR "_i" FROM 0 TO _index do {
- _newarray SET [(_index-_i),_array SELECT (_startnum - _i)];
- };
- _array = _newarray;
- };
- _array
- };
- array_reduceSize = {
- private ["_array1","_array","_count","_num"];
- _array1 = _this SELECT 0;
- _array = _array1 - ["Hatchet_Swing","Machete_Swing","Fishing_Swing","sledge_swing","crowbar_swing","CSGAS"];
- _count = _this SELECT 1;
- _num = COUNT _array;
- IF (_num > _count) THEN {
- _array resize _count;
- };
- _array
- };
- object_handleServerKilled = {
- private["_unit","_objectID","_objectUID","_killer"];
- _unit = _this SELECT 0;
- _killer = _this SELECT 1;
- _objectID = _unit getVariable ["ObjectID","0"];
- _objectUID = _unit getVariable ["ObjectUID","0"];
- [_objectID,_objectUID,_killer] CALL server_deleteObj;
- _unit removeAllMPEventHandlers "MPKilled";
- _unit removeAllEventHandlers "Killed";
- _unit removeAllEventHandlers "HandleDamage";
- _unit removeAllEventHandlers "GetIn";
- _unit removeAllEventHandlers "GetOut";
- };
- check_publishobject = {
- private["_allowed","_object","_playername"];
- _object = _this SELECT 0;
- _playername = _this SELECT 1;
- _allowed = FALSE;
- IF ((typeOf _object) IN dayz_allowedObjects) THEN {
- //diag_log format ["DEBUG: Object: %1 published by %2 is Safe",_object, _playername];
- _allowed = TRUE;
- };
- _allowed
- };
- //event Handlers
- eh_localCleanup = {
- private ["_object"];
- _object = _this SELECT 0;
- _object addEventHandler ["local", {
- IF(_this SELECT 1) THEN {
- private["_type","_unit"];
- _unit = _this SELECT 0;
- _type = typeOf _unit;
- _myGroupUnit = GROUP _unit;
- _unit removeAllMPEventHandlers "mpkilled";
- _unit removeAllMPEventHandlers "mphit";
- _unit removeAllMPEventHandlers "mprespawn";
- _unit removeAllEventHandlers "FiredNear";
- _unit removeAllEventHandlers "HandleDamage";
- _unit removeAllEventHandlers "Killed";
- _unit removeAllEventHandlers "Fired";
- _unit removeAllEventHandlers "GetOut";
- _unit removeAllEventHandlers "GetIn";
- _unit removeAllEventHandlers "Local";
- clearVehicleInit _unit;
- deleteVehicle _unit;
- IF ((COUNT (units _myGroupUnit) == 0) && (_myGroupUnit != grpNull)) THEN {
- deleteGroup _myGroupUnit;
- };
- //_unit = nil;
- // diag_log ("CLEANUP: DELETED A " + str(_type) );
- };
- }];
- };
- server_hiveWrite = {
- private["_data"];
- _data = "HiveExt" callExtension _this;
- };
- server_hiveReadWrite = {
- private["_key","_resultArray","_data"];
- _key = _this;
- _data = "HiveExt" callExtension _key;
- _resultArray = CALL compile format ["%1",_data];
- _resultArray
- };
- server_hiveReadWriteLarge = {
- private["_key","_resultArray","_data"];
- _key = _this;
- _data = "HiveExt" callExtension _key;
- _resultArray = CALL compile _data;
- _resultArray
- };
- server_checkIfTowed = {
- private ["_vehicle","_player","_attached"];
- IF (DZE_HeliLift) THEN {
- _vehicle = _this SELECT 0;
- _player = _this SELECT 2;
- _attached = _vehicle getVariable["attached",FALSE];
- IF (typeName _attached == "OBJECT") THEN {
- _player action ["eject", _vehicle];
- detach _vehicle;
- _vehicle setVariable["attached",FALSE,TRUE];
- _attached setVariable["hasAttached",FALSE,TRUE];
- };
- };
- };
- server_characterSync = {
- private ["_characterID","_playerPos","_playerGear","_playerBackp","_medical","_currentState","_currentModel","_key"];
- _characterID = _this SELECT 0;
- _playerPos = _this SELECT 1;
- _playerGear = _this SELECT 2;
- _playerBackp = _this SELECT 3;
- _medical = _this SELECT 4;
- _currentState = _this SELECT 5;
- _currentModel = _this SELECT 6;
- _key = format["CHILD:201:%1:%2:%3:%4:%5:%6:%7:%8:%9:%10:%11:%12:%13:%14:%15:%16:",_characterID,_playerPos,_playerGear,_playerBackp,_medical,FALSE,FALSE,0,0,0,0,_currentState,0,0,_currentModel,0];
- _key CALL server_hiveWrite;
- };
- IF(isnil "dayz_MapArea") THEN {
- dayz_MapArea = 10000;
- };
- IF(isnil "DynamicVehicleArea") THEN {
- DynamicVehicleArea = dayz_MapArea / 2;
- };
- // GET ALL buildings && roads ONLY once TODO: SET VARIABLES TO nil after done IF nessicary
- MarkerPosition = getMarkerPos "center";
- RoadList = MarkerPosition nearRoads DynamicVehicleArea;
- // Very taxing !!! but ONLY ON FIRST startup
- BuildingList = [];
- {
- IF (DZE_MissionLootTable) THEN {
- IF (isClass (missionConfigFile >> "CfgBuildingLoot" >> (typeOf _x))) THEN
- {
- BuildingList SET [COUNT BuildingList,_x];
- };
- } ELSE {
- IF (isClass (configFile >> "CfgBuildingLoot" >> (typeOf _x))) THEN
- {
- BuildingList SET [COUNT BuildingList,_x];
- };
- };
- } COUNT (MarkerPosition nearObjects ["building",DynamicVehicleArea]);
- spawn_vehicles = {
- private ["_random","_lastIndex","_weights","_index","_vehicle","_velimit","_qty","_isAir","_isShip","_position","_dir","_istoomany","_veh","_objPosition","_marker","_iClass","_itemTypes","_cntWeights","_itemType","_num","_allCfgLoots"];
- IF (!isDedicated) exitWith { }; //Be sure the run this
- while {COUNT AllowedVehiclesList > 0} do {
- // BIS_fnc_selectRandom replaced because the INDEX may be needed TO remove the element
- _index = FLOOR random COUNT AllowedVehiclesList;
- _random = AllowedVehiclesList SELECT _index;
- _vehicle = _random SELECT 0;
- _velimit = _random SELECT 1;
- _qty = {_x == _vehicle} COUNT serverVehicleCounter;
- // IF UNDER LIMIT allow TO proceed
- IF (_qty <= _velimit) exitWith {};
- // vehicle LIMIT reached, remove vehicle FROM list
- // since elements cannot be removed FROM an array, overwrite it WITH the LAST element && cut the LAST element OF (AS long AS ORDER IS NOT important)
- _lastIndex = (COUNT AllowedVehiclesList) - 1;
- IF (_lastIndex != _index) THEN {
- AllowedVehiclesList SET [_index, AllowedVehiclesList SELECT _lastIndex];
- };
- AllowedVehiclesList resize _lastIndex;
- };
- IF (COUNT AllowedVehiclesList == 0) THEN {
- diag_log("DEBUG: unable to find suitable vehicle to spawn");
- } ELSE {
- // ADD vehicle TO counter FOR NEXT pass
- serverVehicleCounter SET [COUNT serverVehicleCounter,_vehicle];
- // Find Vehicle TYPE TO better control spawns
- _isAir = _vehicle isKindOf "Air";
- _isShip = _vehicle isKindOf "Ship";
- IF(_isShip || _isAir) THEN {
- IF(_isShip) THEN {
- // Spawn anywhere ON coast ON water
- waitUntil{!isNil "BIS_fnc_findSafePos"};
- _position = [MarkerPosition,0,DynamicVehicleArea,10,1,2000,1] CALL BIS_fnc_findSafePos;
- //diag_log("DEBUG: spawning boat near coast " + str(_position));
- } ELSE {
- // Spawn air anywhere that IS flat
- waitUntil{!isNil "BIS_fnc_findSafePos"};
- _position = [MarkerPosition,0,DynamicVehicleArea,10,0,2000,0] CALL BIS_fnc_findSafePos;
- //diag_log("DEBUG: spawning air anywhere flat " + str(_position));
- };
- } ELSE {
- // Spawn around buildings && 50% near roads
- IF((random 1) > 0.5) THEN {
- waitUntil{!isNil "BIS_fnc_selectRandom"};
- _position = RoadList CALL BIS_fnc_selectRandom;
- _position = _position modelToWorld [0,0,0];
- waitUntil{!isNil "BIS_fnc_findSafePos"};
- _position = [_position,0,10,10,0,2000,0] CALL BIS_fnc_findSafePos;
- //diag_log("DEBUG: spawning near road " + str(_position));
- } ELSE {
- waitUntil{!isNil "BIS_fnc_selectRandom"};
- _position = BuildingList CALL BIS_fnc_selectRandom;
- _position = _position modelToWorld [0,0,0];
- waitUntil{!isNil "BIS_fnc_findSafePos"};
- _position = [_position,0,40,5,0,2000,0] CALL BIS_fnc_findSafePos;
- //diag_log("DEBUG: spawning around buildings " + str(_position));
- };
- };
- // ONLY proceed IF two params otherwise BIS_fnc_findSafePos failed && may spawn IN air
- IF ((COUNT _position) == 2) THEN {
- _dir = round(random 180);
- _istoomany = _position nearObjects ["AllVehicles",50];
- IF((COUNT _istoomany) > 0) exitWith { diag_log("DEBUG: Too many vehicles at " + str(_position)); };
- //place vehicle
- _veh = createVehicle [_vehicle, _position, [], 0, "CAN_COLLIDE"];
- _veh setdir _dir;
- _veh setpos _position;
- IF(DZEdebug) THEN {
- _marker = createMarker [str(_position) , _position];
- _marker setMarkerShape "ICON";
- _marker setMarkerType "DOT";
- _marker setMarkerText _vehicle;
- };
- // GET POSITION WITH ground
- _objPosition = getPosATL _veh;
- clearWeaponCargoGlobal _veh;
- clearMagazineCargoGlobal _veh;
- // _veh setVehicleAmmo DZE_vehicleAmmo;
- // ADD 0-3 loots TO vehicle USING random cfgloots
- _num = FLOOR(random 4);
- _allCfgLoots = ["trash","civilian","food","generic","medical","military","policeman","hunter","worker","clothes","militaryclothes","specialclothes","trash"];
- FOR "_x" FROM 1 TO _num do {
- _iClass = _allCfgLoots CALL BIS_fnc_selectRandom;
- _itemTypes = [];
- IF (DZE_MissionLootTable) THEN{
- {
- _itemTypes SET[COUNT _itemTypes, _x SELECT 0]
- } COUNT getArray(missionConfigFile >> "cfgLoot" >> _iClass);
- }
- ELSE {
- {
- _itemTypes SET[COUNT _itemTypes, _x SELECT 0]
- } COUNT getArray(configFile >> "cfgLoot" >> _iClass);
- };
- _index = dayz_CLBase find _iClass;
- _weights = dayz_CLChances SELECT _index;
- _cntWeights = COUNT _weights;
- _index = FLOOR(random _cntWeights);
- _index = _weights SELECT _index;
- _itemType = _itemTypes SELECT _index;
- _veh addMagazineCargoGlobal [_itemType,1];
- //diag_log("DEBUG: spawed loot inside vehicle " + str(_itemType));
- };
- [_veh,[_dir,_objPosition],_vehicle,TRUE,"0"] CALL server_publishVeh;
- };
- };
- };
- spawn_ammosupply = {
- private ["_position","_veh","_istoomany","_marker","_spawnveh","_WreckList"];
- IF (isDedicated) THEN {
- _WreckList = ["Supply_Crate_DZE"];
- waitUntil{!isNil "BIS_fnc_selectRandom"};
- _position = RoadList CALL BIS_fnc_selectRandom;
- _position = _position modelToWorld [0,0,0];
- waitUntil{!isNil "BIS_fnc_findSafePos"};
- _position = [_position,5,20,5,0,2000,0] CALL BIS_fnc_findSafePos;
- IF ((COUNT _position) == 2) THEN {
- _istoomany = _position nearObjects ["All",5];
- IF((COUNT _istoomany) > 0) exitWith { diag_log("DEBUG VEIN: Too many at " + str(_position)); };
- _spawnveh = _WreckList CALL BIS_fnc_selectRandom;
- IF(DZEdebug) THEN {
- _marker = createMarker [str(_position) , _position];
- _marker setMarkerShape "ICON";
- _marker setMarkerType "DOT";
- _marker setMarkerText str(_spawnveh);
- };
- _veh = createVehicle [_spawnveh,_position, [], 0, "CAN_COLLIDE"];
- _veh enableSimulation FALSE;
- _veh setDir round(random 360);
- _veh setpos _position;
- _veh setVariable ["ObjectID","1",TRUE];
- };
- };
- };
- DZE_LocalRoadBlocks = [];
- spawn_roadblocks = {
- private ["_position","_veh","_istoomany","_marker","_spawnveh","_WreckList"];
- _WreckList = ["SKODAWreck","HMMWVWreck","UralWreck","datsun01Wreck","hiluxWreck","datsun02Wreck","UAZWreck","Land_Misc_Garb_Heap_EP1","Fort_Barricade_EP1","Rubbish2"];
- waitUntil{!isNil "BIS_fnc_selectRandom"};
- IF (isDedicated) THEN {
- _position = RoadList CALL BIS_fnc_selectRandom;
- _position = _position modelToWorld [0,0,0];
- waitUntil{!isNil "BIS_fnc_findSafePos"};
- _position = [_position,0,10,5,0,2000,0] CALL BIS_fnc_findSafePos;
- IF ((COUNT _position) == 2) THEN {
- // GET POSITION WITH ground
- _istoomany = _position nearObjects ["All",5];
- IF((COUNT _istoomany) > 0) exitWith { diag_log("DEBUG: Too many at " + str(_position)); };
- waitUntil{!isNil "BIS_fnc_selectRandom"};
- _spawnveh = _WreckList CALL BIS_fnc_selectRandom;
- IF(DZEdebug) THEN {
- _marker = createMarker [str(_position) , _position];
- _marker setMarkerShape "ICON";
- _marker setMarkerType "DOT";
- _marker setMarkerText str(_spawnveh);
- };
- _veh = createVehicle [_spawnveh,_position, [], 0, "CAN_COLLIDE"];
- _veh enableSimulation FALSE;
- _veh setDir round(random 360); // Randomize placement a bit
- _veh setpos _position;
- _veh setVariable ["ObjectID","1",TRUE];
- };
- };
- };
- spawn_mineveins = {
- private ["_position","_veh","_istoomany","_marker","_spawnveh","_positions"];
- IF (isDedicated) THEN {
- _position = [getMarkerPos "center",0,(HeliCrashArea*0.75),10,0,2000,0] CALL BIS_fnc_findSafePos;
- IF ((COUNT _position) == 2) THEN {
- _positions = selectBestPlaces [_position, 500, "(1 + forest) * (1 + hills) * (1 - houses) * (1 - sea)", 10, 5];
- _position = (_positions CALL BIS_fnc_selectRandom) SELECT 0;
- // GET POSITION WITH ground
- _istoomany = _position nearObjects ["All",10];
- IF((COUNT _istoomany) > 0) exitWith { diag_log("DEBUG VEIN: Too many objects at " + str(_position)); };
- IF(isOnRoad _position) exitWith { diag_log("DEBUG VEIN: on road " + str(_position)); };
- _spawnveh = ["Iron_Vein_DZE","Iron_Vein_DZE","Iron_Vein_DZE","Iron_Vein_DZE","Iron_Vein_DZE","Silver_Vein_DZE","Silver_Vein_DZE","Silver_Vein_DZE","Gold_Vein_DZE","Gold_Vein_DZE"] CALL BIS_fnc_selectRandom;
- IF(DZEdebug) THEN {
- _marker = createMarker [str(_position) , _position];
- _marker setMarkerShape "ICON";
- _marker setMarkerType "DOT";
- _marker setMarkerText str(_spawnveh);
- };
- //diag_log("DEBUG: Spawning a crashed " + _spawnveh + " with " + _spawnloot + " at " + str(_position));
- _veh = createVehicle [_spawnveh,_position, [], 0, "CAN_COLLIDE"];
- _veh enableSimulation FALSE;
- // Randomize placement a bit
- _veh setDir round(random 360);
- _veh setpos _position;
- _veh setVariable ["ObjectID","1",TRUE];
- };
- };
- };
- IF(isnil "DynamicVehicleDamageLow") THEN {
- DynamicVehicleDamageLow = 0;
- };
- IF(isnil "DynamicVehicleDamageHigh") THEN {
- DynamicVehicleDamageHigh = 100;
- };
- IF(isnil "DynamicVehicleFuelLow") THEN {
- DynamicVehicleFuelLow = 0;
- };
- IF(isnil "DynamicVehicleFuelHigh") THEN {
- DynamicVehicleFuelHigh = 100;
- };
- IF(isnil "DZE_DiagFpsSlow") THEN {
- DZE_DiagFpsSlow = FALSE;
- };
- IF(isnil "DZE_DiagFpsFast") THEN {
- DZE_DiagFpsFast = FALSE;
- };
- IF(isnil "DZE_DiagVerbose") THEN {
- DZE_DiagVerbose = FALSE;
- };
- dze_diag_fps = {
- IF(DZE_DiagVerbose) THEN {
- diag_log format["DEBUG FPS : %1 OBJECTS: %2 : PLAYERS: %3", diag_fps,(COUNT (allMissionObjects "")),(playersNumber west)];
- } ELSE {
- diag_log format["DEBUG FPS : %1", diag_fps];
- };
- };
- // Damage generator FUNCTION
- generate_new_damage = {
- private ["_damage"];
- _damage = ((random(DynamicVehicleDamageHigh-DynamicVehicleDamageLow))+DynamicVehicleDamageLow) / 100;
- _damage;
- };
- // Damage generator fuction
- generate_exp_damage = {
- private ["_damage"];
- _damage = ((random(DynamicVehicleDamageHigh-DynamicVehicleDamageLow))+DynamicVehicleDamageLow) / 100;
- // LIMIT this TO 85% since vehicle would blow up otherwise.
- //IF(_damage >= 0.85) THEN {
- // _damage = 0.85;
- //};
- _damage;
- };
- server_getDiff = {
- private["_variable","_object","_vNew","_vOld","_result"];
- _variable = _this SELECT 0;
- _object = _this SELECT 1;
- _vNew = _object getVariable[_variable,0];
- _vOld = _object getVariable[(_variable + "_CHK"),_vNew];
- _result = 0;
- IF (_vNew < _vOld) THEN {
- //JIP issues
- _vNew = _vNew + _vOld;
- _object getVariable[(_variable + "_CHK"),_vNew];
- } ELSE {
- _result = _vNew - _vOld;
- _object setVariable[(_variable + "_CHK"),_vNew];
- };
- _result
- };
- server_getDiff2 = {
- private["_variable","_object","_vNew","_vOld","_result"];
- _variable = _this SELECT 0;
- _object = _this SELECT 1;
- _vNew = _object getVariable[_variable,0];
- _vOld = _object getVariable[(_variable + "_CHK"),_vNew];
- _result = _vNew - _vOld;
- _object setVariable[(_variable + "_CHK"),_vNew];
- _result
- };
- dayz_objectUID = {
- private["_position","_dir","_key","_object"];
- _object = _this;
- _position = getPosATL _object;
- _dir = direction _object;
- _key = [_dir,_position] CALL dayz_objectUID2;
- _key
- };
- dayz_objectUID2 = {
- private["_position","_dir","_key"];
- _dir = _this SELECT 0;
- _key = "";
- _position = _this SELECT 1;
- {
- _x = _x * 10;
- IF ( _x < 0 ) THEN { _x = _x * -10 };
- _key = _key + str(round(_x));
- } COUNT _position;
- _key = _key + str(round(_dir));
- _key
- };
- dayz_objectUID3 = {
- private["_position","_dir","_key"];
- _dir = _this SELECT 0;
- _key = "";
- _position = _this SELECT 1;
- {
- _x = _x * 10;
- IF ( _x < 0 ) THEN { _x = _x * -10 };
- _key = _key + str(round(_x));
- } COUNT _position;
- _key = _key + str(round(_dir + TIME));
- _key
- };
- dayz_recordLogin = {
- private["_key"];
- _key = format["CHILD:103:%1:%2:%3:",_this SELECT 0,_this SELECT 1,_this SELECT 2];
- _key CALL server_hiveWrite;
- };
- dayz_perform_purge = {
- IF(!isNull(_this)) THEN {
- _group = GROUP _this;
- _this removeAllMPEventHandlers "mpkilled";
- _this removeAllMPEventHandlers "mphit";
- _this removeAllMPEventHandlers "mprespawn";
- _this removeAllEventHandlers "FiredNear";
- _this removeAllEventHandlers "HandleDamage";
- _this removeAllEventHandlers "Killed";
- _this removeAllEventHandlers "Fired";
- _this removeAllEventHandlers "GetOut";
- _this removeAllEventHandlers "GetIn";
- _this removeAllEventHandlers "Local";
- clearVehicleInit _this;
- deleteVehicle _this;
- IF ((COUNT (units _group) == 0) && (_group != grpNull)) THEN {
- deleteGroup _group;
- };
- };
- };
- dayz_perform_purge_player = {
- private ["_countr","_backpack","_backpackType","_backpackWpn","_backpackMag","_objWpnTypes","_objWpnQty","_location","_dir","_holder","_weapons","_magazines"];
- diag_log ("Purging player: " + str(_this));
- IF(!isNull(_this)) THEN {
- _location = getPosATL _this;
- _dir = getDir _this;
- _holder = createVehicle ["GraveDZE", _location, [], 0, "CAN_COLLIDE"];
- _holder setDir _dir;
- _holder setPosATL _location;
- _holder enableSimulation FALSE;
- _weapons = weapons _this;
- _magazines = magazines _this;
- // find backpack
- IF(!(isNull unitBackpack _this)) THEN {
- _backpack = unitBackpack _this;
- _backpackType = typeOf _backpack;
- _backpackWpn = getWeaponCargo _backpack;
- _backpackMag = getMagazineCargo _backpack;
- _holder addBackpackCargoGlobal [_backpackType,1];
- // ADD items FROM backpack
- _objWpnTypes = _backpackWpn SELECT 0;
- _objWpnQty = _backpackWpn SELECT 1;
- _countr = 0;
- {
- _holder addWeaponCargoGlobal [_x,(_objWpnQty SELECT _countr)];
- _countr = _countr + 1;
- } COUNT _objWpnTypes;
- // ADD backpack magazine items
- _objWpnTypes = _backpackMag SELECT 0;
- _objWpnQty = _backpackMag SELECT 1;
- _countr = 0;
- {
- _holder addMagazineCargoGlobal [_x,(_objWpnQty SELECT _countr)];
- _countr = _countr + 1;
- } COUNT _objWpnTypes;
- };
- };
- // ADD weapons
- {
- _holder addWeaponCargoGlobal [_x, 1];
- } COUNT _weapons;
- // ADD mags
- {
- _holder addMagazineCargoGlobal [_x, 1];
- } COUNT _magazines;
- _group = GROUP _this;
- _this removeAllMPEventHandlers "mpkilled";
- _this removeAllMPEventHandlers "mphit";
- _this removeAllMPEventHandlers "mprespawn";
- _this removeAllEventHandlers "FiredNear";
- _this removeAllEventHandlers "HandleDamage";
- _this removeAllEventHandlers "Killed";
- _this removeAllEventHandlers "Fired";
- _this removeAllEventHandlers "GetOut";
- _this removeAllEventHandlers "GetIn";
- _this removeAllEventHandlers "Local";
- clearVehicleInit _this;
- deleteVehicle _this;
- IF ((COUNT (units _group) == 0) && (_group != grpNull)) THEN {
- deleteGroup _group;
- };
- // _this = nil;
- };
- dayz_removePlayerOnDisconnect = {
- IF(!isNull(_this)) THEN {
- _group = GROUP _this;
- _this removeAllMPEventHandlers "mphit";
- deleteVehicle _this;
- deleteGroup (GROUP _this);
- };
- };
- server_timeSync = {
- //Send request
- private ["_hour","_minute","_date","_key","_result","_outcome"];
- _key = "CHILD:307:";
- _result = _key CALL server_hiveReadWrite;
- _outcome = _result SELECT 0;
- IF(_outcome == "PASS") THEN {
- _date = _result SELECT 1;
- IF(dayz_fullMoonNights) THEN {
- _hour = _date SELECT 3;
- _minute = _date SELECT 4;
- //Force FULL moon nights
- _date = [2013,8,3,_hour,_minute];
- };
- setDate _date;
- PVDZE_plr_SetDate = _date;
- publicVariable "PVDZE_plr_SetDate";
- diag_log ("TIME SYNC: Local Time set to " + str(_date));
- };
- };
- // must spawn these
- server_spawncleanDead = {
- private ["_deathTime","_delQtyZ","_delQtyP","_qty","_allDead"];
- _allDead = allDead;
- _delQtyZ = 0;
- _delQtyP = 0;
- {
- IF (LOCAL _x) THEN {
- IF (_x isKindOf "zZombie_Base") THEN
- {
- _x CALL dayz_perform_purge;
- sleep 0.05;
- _delQtyZ = _delQtyZ + 1;
- } ELSE {
- IF (_x isKindOf "CAManBase") THEN {
- _deathTime = _x getVariable ["processedDeath", diag_tickTime];
- IF (diag_tickTime - _deathTime > 1800) THEN {
- _x CALL dayz_perform_purge_player;
- sleep 0.025;
- _delQtyP = _delQtyP + 1;
- };
- };
- };
- };
- sleep 0.025;
- } COUNT _allDead;
- IF (_delQtyZ > 0 || _delQtyP > 0) THEN {
- _qty = COUNT _allDead;
- diag_log (format["CLEANUP: Deleted %1 players && %2 zombies out of %3 dead",_delQtyP,_delQtyZ,_qty]);
- };
- };
- server_cleanupGroups = {
- IF (DZE_DYN_AntiStuck3rd > 3) THEN { DZE_DYN_GroupCleanup = nil; DZE_DYN_AntiStuck3rd = 0; };
- IF(!isNil "DZE_DYN_GroupCleanup") exitWith { DZE_DYN_AntiStuck3rd = DZE_DYN_AntiStuck3rd + 1;};
- DZE_DYN_GroupCleanup = TRUE;
- {
- IF ((COUNT (units _x) == 0) && (_x != grpNull)) THEN {
- deleteGroup _x;
- };
- sleep 0.001;
- } COUNT allGroups;
- DZE_DYN_GroupCleanup = nil;
- };
- //server_checkHackers = {
- // IF (DZE_DYN_AntiStuck2nd > 3) THEN { DZE_DYN_HackerCheck = nil; DZE_DYN_AntiStuck2nd = 0; };
- // IF(!isNil "DZE_DYN_HackerCheck") exitWith { DZE_DYN_AntiStuck2nd = DZE_DYN_AntiStuck2nd + 1;};
- // DZE_DYN_HackerCheck = TRUE;
- // {
- // IF (!((isNil "_x") || {(isNull _x)})) THEN {
- // IF(vehicle _x != _x && !(vehicle _x IN PVDZE_serverObjectMonitor) && (isPlayer _x) && !((typeOf vehicle _x) IN DZE_safeVehicle)) THEN {
- // diag_log ("CLEANUP: KILLING A HACKER " + (name _x) + " " + str(_x) + " IN " + (typeOf vehicle _x));
- // (vehicle _x) setDamage 1;
- // _x setDamage 1;
- // sleep 0.25;
- // };
- // };
- // sleep 0.001;
- // } COUNT allUnits;
- // DZE_DYN_HackerCheck = nil;
- //};
- server_spawnCleanFire = {
- private ["_delQtyFP","_qty","_delQtyNull","_missionFires"];
- _missionFires = allMissionObjects "Land_Fire_DZ";
- _delQtyFP = 0;
- {
- IF (LOCAL _x) THEN {
- deleteVehicle _x;
- sleep 0.025;
- _delQtyFP = _delQtyFP + 1;
- };
- sleep 0.001;
- } COUNT _missionFires;
- IF (_delQtyFP > 0) THEN {
- _qty = COUNT _missionFires;
- diag_log (format["CLEANUP: Deleted %1 fireplaces out of %2",_delQtyNull,_qty]);
- };
- };
- server_spawnCleanLoot = {
- private ["_created","_delQty","_nearby","_age","_keep","_qty","_missionObjs","_dateNow"];
- IF (DZE_DYN_AntiStuck > 3) THEN { DZE_DYN_cleanLoot = nil; DZE_DYN_AntiStuck = 0; };
- IF(!isNil "DZE_DYN_cleanLoot") exitWith { DZE_DYN_AntiStuck = DZE_DYN_AntiStuck + 1;};
- DZE_DYN_cleanLoot = TRUE;
- _missionObjs = allMissionObjects "ReammoBox";
- _delQty = 0;
- _dateNow = (DateToNumber DATE);
- {
- IF (!isNull _x) THEN {
- _keep = _x getVariable["permaLoot", FALSE];
- IF (!_keep) THEN {
- _created = _x getVariable["created", -0.1];
- IF (_created == -0.1) THEN{
- _x setVariable["created", _dateNow, FALSE];
- _created = _dateNow;
- }
- ELSE {
- _age = (_dateNow - _created) * 525948;
- IF (_age > 20) THEN{
- _nearby = { (isPlayer _x) && (alive _x) } COUNT(_x nearEntities[["CAManBase", "AllVehicles"], 130]);
- IF (_nearby == 0) THEN{
- deleteVehicle _x;
- sleep 0.025;
- _delQty = _delQty + 1;
- };
- };
- };
- };
- };
- sleep 0.001;
- } COUNT _missionObjs;
- IF (_delQty > 0) THEN {
- _qty = COUNT _missionObjs;
- diag_log (format["CLEANUP: Deleted %1 Loot Piles out of %2",_delQty,_qty]);
- };
- DZE_DYN_cleanLoot = nil;
- };
- server_spawnCleanAnimals = {
- private ["_pos","_delQtyAnimal","_qty","_missonAnimals","_nearby"];
- _missonAnimals = entities "CAAnimalBase";
- _delQtyAnimal = 0;
- {
- IF (LOCAL _x) THEN {
- _x CALL dayz_perform_purge;
- sleep 0.05;
- _delQtyAnimal = _delQtyAnimal + 1;
- } ELSE {
- IF (!alive _x) THEN {
- _pos = getPosATL _x;
- IF (COUNT _pos > 0) THEN {
- _nearby = {(isPlayer _x) && (alive _x)} COUNT (_pos nearEntities [["CAManBase","AllVehicles"], 130]);
- IF (_nearby==0) THEN {
- _x CALL dayz_perform_purge;
- sleep 0.05;
- _delQtyAnimal = _delQtyAnimal + 1;
- };
- };
- };
- };
- sleep 0.001;
- } COUNT _missonAnimals;
- IF (_delQtyAnimal > 0) THEN {
- _qty = COUNT _missonAnimals;
- diag_log (format["CLEANUP: Deleted %1 Animals out of %2",_delQtyAnimal,_qty]);
- };
- };
- server_logUnlockLockEvent = {
- private["_player", "_obj", "_objectID", "_objectUID", "_statusText", "_status"];
- _player = _this SELECT 0;
- _obj = _this SELECT 1;
- _status = _this SELECT 2;
- IF (!isNull(_obj)) THEN {
- _objectID = _obj getVariable["ObjectID", "0"];
- _objectUID = _obj getVariable["ObjectUID", "0"];
- _statusText = "UNLOCKED";
- IF (_status) THEN {
- [_obj, "gear"] CALL server_updateObject;
- _statusText = "LOCKED";
- };
- diag_log format["SAFE %5: ID:%1 UID:%2 BY %3(%4)", _objectID, _objectUID, (name _player), (getPlayerUID _player), _statusText];
- };
- };
Advertisement
Add Comment
Please, Sign In to add comment