This commit is contained in:
2022-04-21 16:15:41 +03:00
commit 9d4fc88901
601 changed files with 66252 additions and 0 deletions

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,119 @@
private ["_aiPosition","_divisor","_playerUID","_clientKey","_playerPos","_activatingPlayer","_exitReason","_aiArea","_aiCount","_aiBags","_aiRandomWep","_aiSkill","_aiAssault","_aiMachine","_aiSniper","_weaponandmag","_weapon","_magazine","_aiItems","_aiTools","_unitGroup","_unit","_deadai","_banditSkin","_heroSkin","_killer"];
EAT_BanditorHero = _this select 0;
_aiArea = _this select 1;
_aiCount = _this select 2;
_divisor = _this select 3;
_aiPosition = _this select 4;
_activatingPlayer = _this select 5;
_playerPos = _this select 6;
_clientKey = _this select 7;
_playerUID = getPlayerUID _activatingPlayer;
_exitReason = [_this,"EAT_AiSpawn",_playerPos,_clientKey,_playerUID,_activatingPlayer] call server_verifySender;
if (_exitReason != "") exitWith {diag_log _exitReason};
if (!(_playerUID in EAT_adminList)) exitWith {diag_log format["Unauthorized player (%1 - %2) trying to spawn AI",_activatingPlayer,_playerUID];};
_aiSkill = [["aimingAccuracy",0.60],["aimingShake",0.60],["aimingSpeed",0.60],["endurance",1.00],["spotDistance",0.60],["spotTime",0.60],["courage",1.00],["reloadSpeed",1.00],["commanding",1.00],["general",1.00]];
_aiAssault = [["M16A4_ACOG_DZ","30Rnd_556x45_Stanag"],["Sa58V_RCO_EP1","30Rnd_762x39_AK47"],["SCAR_L_STD_Mk4CQT","30Rnd_556x45_Stanag"],["M8_sharpshooter","30Rnd_556x45_Stanag"],["M4A1_Holo_MFL_DZ","30Rnd_556x45_Stanag"],["SCAR_L_STD_HOLO","30Rnd_556x45_Stanag"],["M4A1_CCO_DZ","30Rnd_556x45_Stanag"],["G36C_ACOG_DZ","30Rnd_556x45_G36"],["AKM_Kobra_DZ","30Rnd_762x39_AK47"],["SA58_Holo_DZ","30Rnd_762x39_SA58"],["m8_carbine","30Rnd_556x45_Stanag"],["L85A2_CCO_FL_DZ","30Rnd_556x45_Stanag"],["AK74_GL_PSO1_DZ","30Rnd_545x39_AK"]];
_aiMachine = [["RPK74_Kobra_DZ","75Rnd_545x39_RPK"],["Mk48_CCO_DZ","100Rnd_762x51_M240"],["M249_DZ","200Rnd_556x45_M249"],["Pecheneg_DZ","100Rnd_762x54_PK"],["M240_DZ","100Rnd_762x51_M240"]];
_aiSniper = [["M14_Holo_DZ","20Rnd_762x51_DMR"],["SCAR_H_LNG_Sniper_SD","20Rnd_762x51_SB_SCAR"],["M110_NVG_EP1","20rnd_762x51_B_SCAR"],["SVD_PSO1_Gh_DZ","10Rnd_762x54_SVD"],["VSS_Vintorez","20Rnd_9x39_SP5_VSS"],["DMR_DZ","20Rnd_762x51_DMR"],["M40A3_DZ","5Rnd_762x51_M24"]];
_aiRandomWep = [_aiAssault,_aiAssault,_aiAssault,_aiSniper,_aiMachine];
_aiBags = ["DZ_Czech_Vest_Pouch","DZ_ALICE_Pack_EP1","DZ_TK_Assault_Pack_EP1","DZ_British_ACU","DZ_GunBag_EP1","DZ_CivilBackpack_EP1","DZ_Backpack_EP1","DZ_LargeGunBag_EP1"];
_banditSkin = ["Ins_Soldier_GL_DZ","TK_INS_Soldier_EP1_DZ","TK_INS_Warlord_EP1_DZ","GUE_Commander_DZ","GUE_Soldier_Sniper_DZ","GUE_Soldier_MG_DZ","GUE_Soldier_Crew_DZ","GUE_Soldier_2_DZ","GUE_Soldier_CO_DZ","BanditW1_DZ","BanditW2_DZ","Bandit1_DZ","Bandit2_DZ"];
_heroSkin = ["Soldier_Sniper_PMC_DZ","FR_OHara_DZ","Soldier_Bodyguard_AA12_PMC_DZ","FR_R_DZ","FR_Sapper_DZ","FR_Marksman_DZ","FR_Assault_R_DZ","UN_CDF_Soldier_Guard_EP1_DZ","UN_CDF_Soldier_EP1_DZ","BAF_Soldier_N_MTP_DZ"];
_weaponandmag = (_aiRandomWep call BIS_fnc_selectRandom) call BIS_fnc_selectRandom;
_weapon = _weaponandmag select 0;
_magazine = _weaponandmag select 1;
_aiItems = ["ItemBandage","ItemAntibiotic","ItemPainkiller","ItemAntibacterialWipe","ItemMorphine","ItemEpinephrine","FoodCanBakedBeans","FoodCanPotatoes","ItemSodaMtngreen","ItemSodaLemonade"];
_aiTools = ["ItemKnife","ItemMap","ItemMatchbox","ItemHatchet","ItemToolbox","ItemCrowbar"];
EAT_unitWaypoints = {
private ["_wp","_pos_x","_pos_y","_pos_z","_unitGroup","_position","_waypoint"];
_unitGroup = _this select 0;
_position = _this select 1;
_pos_x = _position select 0;
_pos_y = _position select 1;
_pos_z = _position select 2;
_waypoint = _this select 2;
{
_wp = _unitGroup addWaypoint [_x,10];
_wp setWaypointType "MOVE";
} count [[_pos_x,(_pos_y+_waypoint),0],[(_pos_x+_waypoint),_pos_y,0],[_pos_x,(_pos_y-_waypoint),0],[(_pos_x-_waypoint),_pos_y,0]];
_wp = _unitGroup addWaypoint [[_pos_x,_pos_y,0],_waypoint];
_wp setWaypointType "CYCLE";
};
_unitGroup = createGroup EAST;
for "_x" from 1 to (_aiCount/_divisor) do {
if (EAT_BanditorHero == "Hero") then {
_unit = _unitGroup createUnit [(_heroSkin call BIS_fnc_selectRandom),_aiPosition,[],(_aiArea/2),"CAN COLLIDE"];
} else {
_unit = _unitGroup createUnit [(_banditSkin call BIS_fnc_selectRandom),_aiPosition,[],(_aiArea/2),"CAN COLLIDE"];
};
[_unit] joinSilent _unitGroup;
//_unit setVariable ["Bandit",true];
_unit enableAI "TARGET";
_unit enableAI "AUTOTARGET";
_unit enableAI "MOVE";
_unit enableAI "ANIM";
_unit enableAI "FSM";
_unit setCombatMode "YELLOW";
_unit setBehaviour "COMBAT";
removeAllWeapons _unit;
removeAllItems _unit;
if (sunOrMoon != 1) then {
_unit addweapon "NVGoggles";
};
_i = 0;
_j = 0;
// Magazine count 3
for "_i" from 1 to 3 do {
_unit addMagazine _magazine;
};
_unit addweapon _weapon;
_unit selectWeapon _weapon;
_unit addBackpack (_aiBags call BIS_fnc_selectRandom);
_unit addWeapon (_aiTools call BIS_fnc_selectRandom);
for "_j" from 1 to 3 do {
_unit addMagazine (_aiItems call BIS_fnc_selectRandom);
};
{
_unit setSkill [(_x select 0),(_x select 1)]
} count _aiSkill;
_unit addEventHandler ["Killed",{
_deadai = _this select 0;
_killer = _this select 1;
_deadai setVariable ["bodyName","unknown",false];
[_deadai,_killer] spawn {
private ["_humanity","_humankills","_banditkills","_player"];
_player = _this select 1;
if (isPlayer _player) then {
_humanity = _player getVariable["humanity",0];
if (EAT_BanditorHero == "Hero") then {
_humankills = _player getVariable["humanKills",0];
_player setVariable ["humanKills",(_humankills + 1),true];
_player setVariable ["humanity",(_humanity - EAT_HumanityGainLoss),true];
} else {
_banditkills = _player getVariable ["banditKills", 0];
_player setVariable ["banditKills",(_banditkills + 1),true];
_player setVariable ["humanity",(_humanity + EAT_HumanityGainLoss),true];
};
};
uiSleep EAT_aiDeleteTimer; deleteVehicle (_this select 0);};}];
};
_unitGroup setFormation "ECH LEFT";
_unitGroup selectLeader ((units _unitGroup) select 0);
[_unitGroup, _aiPosition, _aiArea] spawn EAT_unitWaypoints;

View File

@ -0,0 +1,23 @@
private ["_exitReason","_playerUID","_clientKey","_vehtospawn","_worldspace","_pos","_dir","_veh","_activatingPlayer"];
_vehtospawn = _this select 0;
_worldspace = _this select 1;
_activatingPlayer = _this select 2;
_clientKey = _this select 3;
_playerUID = getPlayerUID _activatingPlayer;
_dir = _worldspace select 0;
_pos = _worldspace select 1;
_exitReason = [_this,"EAT_vehSpawn",_pos,_clientKey,_playerUID,_activatingPlayer] call server_verifySender;
if (_exitReason != "") exitWith {diag_log _exitReason};
if (!(_playerUID in EAT_adminModList)) exitWith {diag_log format["Unauthorized player (%1 - %2) trying to spawn vehicles",_activatingPlayer,_playerUID];};
_veh = _vehtospawn createVehicle _pos;
//_veh setDir _dir;
_veh setVariable ["ObjectID", "1", true];
_veh setVariable ["ObjectUID", "1", true];
_veh setVariable ["EAT_Veh",1,true];
clearMagazineCargoGlobal _veh;
clearWeaponCargoGlobal _veh;

View File

@ -0,0 +1,32 @@
// KK_Functions
//
// by KillZoneKid (http://killzonekid.com/)
//
//
// Precise positioning functions.
KK_fnc_floatToString = {
private "_arr";
if (abs (_this - _this % 1) == 0) exitWith { str _this };
_arr = toArray str abs (_this % 1);
_arr set [0, 32];
toString (toArray str (
abs (_this - _this % 1) * _this / abs _this
) + _arr - [32])
};
KK_fnc_positionToString = {
format [
"[%1,%2,%3]",
_this select 0 call KK_fnc_floatToString,
_this select 1 call KK_fnc_floatToString,
_this select 2 call KK_fnc_floatToString
]
};
AN_fnc_formatWorldspace = {
private "_ws";
_ws = toArray str _this;
format ["[%1,%2%3]", _this select 0 call KK_fnc_floatToString, _this select 1 call KK_fnc_positionToString, toString ([_ws, (_ws find 93) + 1, count _ws - 2] call BIS_fnc_subSelect)]
};

View File

@ -0,0 +1,54 @@
server_queryVehicle = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\garage\server_queryVehicle.sqf";
server_spawnVehicle = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\garage\server_spawnVehicle.sqf";
server_storeVehicle = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\garage\server_storeVehicle.sqf";
server_maintainGarage = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\garage\server_maintainVehicles.sqf";
"PVDZE_queryVehicle" addPublicVariableEventHandler {(_this select 1) spawn server_queryVehicle};
"PVDZE_spawnVehicle" addPublicVariableEventHandler {(_this select 1) spawn server_spawnVehicle};
"PVDZE_storeVehicle" addPublicVariableEventHandler {(_this select 1) spawn server_storeVehicle};
"PVDZE_maintainGarage" addPublicVariableEventHandler {(_this select 1) spawn server_maintainGarage};
// Thanks to icomrade/DayZ Epoch for this code: https://github.com/EpochModTeam/DayZ-Epoch/commit/8035df0ba0cd928b84085e288c5cb88260870a3e#diff-ad0636fc2328a27bd80bad9f46126307
VG_RandomizeMyKey = {
_randomInput = toArray "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890";
_return = [];
for "_i" from 0 to (_this) do {
_return set [count _return, (_randomInput call BIS_fnc_selectRandom)];
};
_return;
};
vg_serverKey = toString (8 call VG_RandomizeMyKey);
vg_alreadySpawned = [];
VG_ClearTurrets = {
//By denvdmj (probably, I found it on the biki)
private ["_weaponArray","_findRecurse","_class","_obj","_turret","_mags"];
_obj = _this;
_weaponArray = [];
_weaponArray set [count _weaponArray,[-1]];
_findRecurse = {
private ["_root", "_class", "_path", "_currentPath", "_thisThis"];
_root = (_this select 0);
_path = +(_this select 1);
_thisThis = _this select 2;
for "_i" from 0 to count _root -1 do {
_class = _root select _i;
if (isClass _class) then {
_currentPath = _path + [_i];
{_weaponArray set [count _weaponArray, _currentPath];} count getArray (_class >> "weapons");
_class = _class >> "turrets";
if (isClass _class) then {[_class, _currentPath, _thisThis] call _findRecurse;};
};
};
};
[configFile >> "CfgVehicles" >> typeOf (_obj) >> "turrets", [], _this] call _findRecurse;
{
_turret = _x;
_mags = _obj magazinesTurret _turret;
{_obj removeMagazinesTurret[_x,_turret];} count _mags;
} forEach _weaponArray;
};

View File

@ -0,0 +1,9 @@
private ["_player","_playerUID","_key","_message"];
_player = _this select 0;
_playerUID = if (count _this > 1) then {_this select 1} else {getPlayerUID _player};
_key = format["CHILD:803:%1:",_playerUID];
_key call server_hiveWrite;
_message = format["GARAGE: %1 (%2) maintained vehicles linked to UID: %3 @%4 %5",if (alive _player) then {name _player} else {"DeadPlayer"},getPlayerUID _player,_playerUID,mapGridPosition _player,getPosATL _player];
diag_log _message;

View File

@ -0,0 +1,12 @@
private ["_player","_query","_result","_clientID","_playerUID"];
_player = _this select 0;
_clientID = owner _player;
_playerUID = if (count _this > 1) then {_this select 1} else {getPlayerUID _player};
_key = format["CHILD:800:%1:%2:",_playerUID,vg_sortColumn];
_result = _key call server_hiveReadWrite;
PVDZE_queryVehicleResult = _result;
if (!isNull _player) then {_clientID publicVariableClient "PVDZE_queryVehicleResult";};

View File

@ -0,0 +1,112 @@
private ["_isAir","_VG_ObjID","_characterID","_class","_clientID","_clrinit","_clrinit2","_colour","_colour2","_dam","_damage","_dir","_fuel","_hitpoints","_id","_inventory","_key","_location","_message","_object","_oid","_outcome","_player","_result","_selection","_serverKey","_uid","_worldSpace"];
_worldSpace = _this select 0;
_player = _this select 1;
_id = _this select 2;
_dir = _worldSpace select 0;
_location = _worldSpace select 1;
_worldSpace = [_dir,_location];
_uid = _worldSpace call dayz_objectUID2;
_key = str formatText["CHILD:801:%1:%2:%3:",_id,_worldSpace,_uid];
_result = _key call server_hiveReadWrite;
_outcome = _result select 0;
if (_outcome != "PASS") exitWith {diag_log("HIVE VIRTUAL GARAGE SPAWN VEHICLE FAILED TO EXECUTE: " + _key);};
_class = _result select 1;
_characterID = _result select 2;
_inventory = _result select 3;
_hitpoints = _result select 4;
_fuel = _result select 5;
_damage = _result select 6;
_colour = _result select 7;
_colour2 = _result select 8;
_serverKey = _result select 9;
_VG_ObjID = _result select 10;
_clientID = owner _player;
if (_VG_ObjID in vg_alreadySpawned) exitWith {
diag_log format["VG ERROR: Vehicle with VGObjID = %1 has already been spawned and will not be spawned again. PlayerUID: %2", _VG_ObjID, (getPlayerUID _player)];
};
_key = format["CHILD:388:%1:",_uid];
#ifdef OBJECT_DEBUG
diag_log ("HIVE: WRITE: "+ str(_key));
#endif
_result = _key call server_hiveReadWrite;
_outcome = _result select 0;
if (_outcome != "PASS") then {
diag_log("CUSTOM: failed to get id for : " + str(_uid));
} else {
_VG_ObjID = (toString (18 call VG_RandomizeMyKey)); //new ID
vg_alreadySpawned set [(count vg_alreadySpawned), _VG_ObjID];
_oid = _result select 1;
#ifdef OBJECT_DEBUG
diag_log("CUSTOM: Selected " + str(_oid));
#endif
_object = _class createVehicle _location;
if (surfaceIsWater _location && {({_x != _object} count (_location nearEntities ["Ship",8])) == 0}) then {
_object setPos _location;
};
_object addEventHandler ["HandleDamage",{false}];
clearWeaponCargoGlobal _object;
clearMagazineCargoGlobal _object;
if (vg_clearAmmo && {vg_serverKey == _serverKey}) then {_object call VG_ClearTurrets;};
_object setFuel _fuel;
_object setDamage _damage;
[_inventory select 0,_inventory select 1,_inventory select 2,_object] call fn_addCargo;
_object setVariable ["ObjectID", _oid, true];
_object setVariable ["lastUpdate",diag_tickTime];
_object setVariable ["VGObjectID",_VG_ObjID, false];
if (_colour != "0") then {
_object setVariable ["Colour",_colour,true];
_clrinit = format ["#(argb,8,8,3)color(%1)",_colour];
_object setVehicleInit "this setObjectTexture [0,"+str _clrinit+"];";
};
if (_colour2 != "0") then {
_object setVariable ["Colour2",_colour2,true];
_clrinit2 = format ["#(argb,8,8,3)color(%1)",_colour2];
_object setVehicleInit "this setObjectTexture [1,"+str _clrinit2+"];";
};
processInitCommands;
_characterID = str(_characterID);
_object setVariable ["CharacterID", _characterID, true];
if (_characterID != "0" && !(_object isKindOf "Bicycle")) then {_object setVehicleLock "LOCKED";};
_isAir = _object isKindOf "Air";
{
_selection = _x select 0;
_dam = _x select 1;
_dam = [_x select 1,(_x select 1) min 0.8] select (!_isAir && {_selection in dayZ_explosiveParts});
[_object,_selection,_dam] call fnc_veh_setFixServer;
} forEach _hitpoints;
dayz_serverObjectMonitor set [count dayz_serverObjectMonitor,_object];
_object call fnc_veh_ResetEH;
{if (_object isKindOf _x) exitWith {_object disableTIEquipment true;}} count vg_disableThermal;
PVDZE_veh_Init = _object;
publicVariable "PVDZE_veh_Init";
PVDZE_spawnVehicleResult = _characterID;
if (!isNull _player) then {_clientID publicVariableClient "PVDZE_spawnVehicleResult";};
_message = format["%1 (%2) retrieved %3 @%4 %5",if (alive _player) then {name _player} else {"DeadPlayer"},getPlayerUID _player,_class,mapGridPosition _player,getPosATL _player];
diag_log _message;
};

View File

@ -0,0 +1,92 @@
private ["_damageVeh","_VGobjID","_array","_backPack","_backPackCount","_charID","_class","_clientID","_colour","_colour2","_damage","_displayName","_fnc_sanitizeInput","_fuel","_gearCount","_hit","_hitpoints","_index","_inventory","_inventoryCount","_key","_magazine","_magazineCount","_message","_name","_objectID","_objectUID","_player","_playerUID","_selection","_vehicle","_weapons","_weaponsCount","_woGear"];
_vehicle = _this select 0;
_player = _this select 1;
_woGear = _this select 2;
_clientID = owner _player;
_playerUID = if (count _this > 3) then {_this select 3} else {getPlayerUID _player};
_gearCount = {
private ["_counter"];
_counter = 0;
{_counter = _counter + _x;} count _this;
_counter;
};
_fnc_sanitizeInput = {
private ["_input","_badChars"];
_input = _this;
_input = toArray (_input);
_badChars = [60,62,38,123,125,91,93,59,58,39,96,126,44,46,47,63,124,92,34];
{
_input = _input - [_x];
} forEach _badChars;
_input = toString (_input);
_input
};
_class = typeOf _vehicle;
_displayName = (getText(configFile >> "cfgVehicles" >> _class >> "displayName")) call _fnc_sanitizeInput;
_name = if (alive _player) then {(name _player) call _fnc_sanitizeInput;} else {"unknown player";};
_charID = _vehicle getVariable ["CharacterID","0"];
_objectID = _vehicle getVariable ["ObjectID","0"];
_objectUID = _vehicle getVariable ["ObjectUID","0"];
_VGobjID = _vehicle getVariable ["VGObjectID","0"];
if (_VGobjID == "0") then {
_VGobjID = (toString (18 call VG_RandomizeMyKey)); //normally spawned vehicle
} else {
_index = vg_alreadySpawned find _VGobjID;
if (_index >= 0) then {
vg_alreadySpawned = vg_alreadySpawned - [_VGobjID];
} else {
diag_log format["VG Error: Could not find vehicle with VGobjUID = %1 in vg_alreadySpawned array (server_storeVehicle.sqf) - possible duplicate vehicle being stored. PlayerUID: %2", _VGobjID, (getPlayerUID _player)];
};
};
_damageVeh = damage _vehicle;
_fuel = fuel _vehicle;
_colour = _vehicle getVariable ["Colour","0"];
_colour2 = _vehicle getVariable ["Colour2","0"];
_array = [];
_inventory = [[[],[]],[[],[]],[[],[]]];
_inventoryCount = [0,0,0];
if (isNil "_colour") then {_colour = "0";};
if (isNil "_colour2") then {_colour2 = "0";};
_hitpoints = _vehicle call vehicle_getHitpoints;
{
_hit = [_vehicle,_x] call object_getHit;
_damage = _hit select 0;
_selection = getText (configFile >> "CfgVehicles" >> _class >> "HitPoints" >> _x >> "name");
if (_damage > 0) then {_array set [count _array,[_selection,_damage]]};
} count _hitpoints;
if (!_woGear) then {
_weapons = getWeaponCargo _vehicle;
_magazine = getMagazineCargo _vehicle;
_backPack = getBackpackCargo _vehicle;
_weaponsCount = (_weapons select 1) call _gearCount;
_magazineCount = (_magazine select 1) call _gearCount;
_backPackCount = (_backPack select 1) call _gearCount;
_inventory = [_weapons, _magazine, _backPack];
_inventoryCount = [_weaponsCount, _magazineCount, _backPackCount];
};
_key = str formatText["CHILD:802:%1:%2:%3:%4:%5:%6:%7:%8:%9:%10:%11:%12:%13:%14:",_playerUID,_name,_displayName,_class,_charID,_inventory,_array,_fuel,_damageVeh,_colour,_colour2,vg_serverKey,_VGobjID,_inventoryCount];
_key call server_hiveWrite;
PVDZE_storeVehicleResult = true;
[_objectID,_objectUID,_vehicle] call server_deleteObjDirect;
deleteVehicle _vehicle;
if (!isNull _player) then {_clientID publicVariableClient "PVDZE_storeVehicleResult";};
_message = format["GARAGE: %1 (%2) stored %3 @%4 %5",_name,_playerUID,_class,mapGridPosition _player,getPosATL _player];
diag_log _message;

View File

@ -0,0 +1,78 @@
/*
changeCode - Safe, Lockbox and Door code changing script by salival (https://github.com/oiad)
*/
private ["_backpacks","_charID","_characterID","_clientID","_coins","_dir","_holder","_inventory","_key","_lockedClass","_magazines","_message","_name","_object","_objectID","_objectUID","_ownerID","_ownerPUID","_player","_playerUID","_pos","_typeOf","_vector","_weapons","_worldSpace","_clientKey","_exitReason"];
if (count _this < 4) exitWith {diag_log "server_changeCode error: Improper parameter format";};
_player = _this select 0;
_object = _this select 1;
_characterID = _this select 2;
_clientKey = _this select 3;
_typeOf = typeOf _object;
if !(_typeOf in DZE_unlockedStorage) exitWith {diag_log "server_changeCode called with invalid storage object!"};
_lockedClass = getText (configFile >> "CfgVehicles" >> _typeOf >> "lockedClass");
_pos = _object getVariable ["OEMPos",getPosATL _object];
_dir = getDir _object;
_vector = [vectorDir _object, vectorUp _object];
_charID = _object getVariable ["CharacterID","0"];
_objectID = _object getVariable ["ObjectID","0"];
_objectUID = _object getVariable ["ObjectUID","0"];
_ownerID = _object getVariable ["ownerPUID","0"];
_name = ["unknown player",name _player] select (alive _player);
_clientID = owner _player;
_playerUID = getPlayerUID _player;
if (isNull _player) then {diag_log "ERROR: server_changeCode called with Null player object";};
if (isNull _object) exitWith {diag_log format["ERROR: server_changeCode called with Null object by %1 (%2).",_name,_playerUID];};
_exitReason = [_this,"changeCode",_pos,_clientKey,_PlayerUID,_player] call server_verifySender;
if (_exitReason != "") exitWith {diag_log _exitReason};
_weapons = getWeaponCargo _object;
_magazines = getMagazineCargo _object;
_backpacks = getBackpackCargo _object;
if (Z_singleCurrency) then {_coins = _object getVariable ["cashMoney",0];};
[_objectID,_objectUID,_object] call server_deleteObjDirect;
_holder = _lockedClass createVehicle [0,0,0];
_holder setDir _dir;
_holder setVariable ["memDir",_dir,true];
_holder setVectorDirAndUp _vector;
_holder setPosATL _pos;
_holder setVariable ["CharacterID",_characterID,true];
_holder setVariable ["OEMPos",_pos,true];
if (DZE_permanentPlot) then {
_ownerPUID = if (_charID == "0000" || _charID == "10000") then {_playerUID} else {_ownerID};
_worldSpace = [_dir,_pos,_ownerPUID,_vector];
_holder setVariable ["ownerPUID",_ownerPUID,true];
} else {
_worldSpace = [_dir,_pos];
};
if (Z_singleCurrency) then {_holder setVariable ["cashMoney",_coins,true];};
_objectUID = _worldSpace call dayz_objectUID2;
_holder setVariable ["ObjectUID",_objectUID,true];
deleteVehicle _object;
_inventory = [_weapons,_magazines,_backpacks];
_holder setVariable ["WeaponCargo",_weapons,false];
_holder setVariable ["MagazineCargo",_magazines,false];
_holder setVariable ["BackpackCargo",_backpacks,false];
[_characterID,_holder,_worldSpace,_inventory,_player,_clientKey] call server_publishObj;
if (Z_singleCurrency) then {
_key = format["CHILD:309:%1:",_objectUID] + str _inventory + ":" + str _coins + ":";
_key call server_hiveWrite;
};
_message = format ["CHANGE CODE: %1 (%2) changed the code for %3 to %4 @%5 %6",_name,_playerUID,_lockedClass,_characterID,mapGridPosition _player,_pos];
diag_log _message;

View File

@ -0,0 +1,13 @@
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];
};
};

View File

@ -0,0 +1,38 @@
/*
[_objectID,_objectUID,_activatingPlayer,_objPos,dayz_authKey] call server_deleteObj;
For PV calls from the client use this function, otherwise if calling directly from the server use server_deleteObjDirect
*/
private["_id","_uid","_key","_activatingPlayer","_objPos","_clientKey","_exitReason","_PlayerUID","_processDelete"];
if (count _this < 5) exitWith {diag_log "Server_DeleteObj error: Improper parameter format";};
_id = _this select 0;
_uid = _this select 1;
_activatingPlayer = _this select 2;
_objPos = _this select 3; //Can be object or position if _processDelete is false
_clientKey = _this select 4;
_processDelete = [true,_this select 5] select (count _this > 5);
_PlayerUID = getPlayerUID _activatingPlayer;
_exitReason = [_this,"DeleteObj",_objPos,_clientKey,_PlayerUID,_activatingPlayer] call server_verifySender;
if (_exitReason != "") exitWith {diag_log _exitReason};
if (isServer) then {
if (_processDelete) then {deleteVehicle _objPos};
if (typeName _objPos != "ARRAY") then {
_objPos = typeof _objPos;
};
//remove from database
if (parseNumber _id > 0) then {
//Send request
_key = format["CHILD:304:%1:",_id];
_key call server_hiveWrite;
diag_log format["DELETE: Player %1(%2) deleted %4 with ID: %3",(_activatingPlayer call fa_plr2str), _PlayerUID, _id, _objPos];
} else {
//Send request
_key = format["CHILD:310:%1:",_uid];
_key call server_hiveWrite;
diag_log format["DELETE: Player %1(%2) deleted %4 with UID: %3",(_activatingPlayer call fa_plr2str), _PlayerUID, _uid, _objPos];
};
};

View File

@ -0,0 +1,23 @@
/*
[_objectID,_objectUID,_obj] call server_deleteObjDirect;
*/
private ["_id","_uid","_key","_obj"];
_id = _this select 0;
_uid = _this select 1;
_obj = ["Object",typeof (_this select 2)] select (count _this > 2);
if (isServer) then {
//remove from database
if (parseNumber _id > 0) then {
//Send request
_key = format["CHILD:304:%1:",_id];
_key call server_hiveWrite;
diag_log format["DELETE DIRECT: SERVER deleted %2 with ID: %1", _id, _obj];
} else {
//Send request
_key = format["CHILD:310:%1:",_uid];
_key call server_hiveWrite;
diag_log format["DELETE DIRECT: SERVER deleted %2 with UID: %1", _uid, _obj];
};
};

View File

@ -0,0 +1,171 @@
private ["_exitReason","_clientKey","_backpacks","_charID","_clientID","_dir","_holder","_lockCode","_lockedClass","_magazines","_name","_obj","_objectID","_objectUID","_ownerID","_packedClass","_player","_playerUID","_pos","_status","_statusText","_type","_unlockedClass","_vector","_weapons","_message","_suppliedCode","_damage","_coins","_wealth"];
_player = _this select 0;
_obj = _this select 1;
_status = _this select 2;
_name = ["Dead Player",name _player] select (alive _player);
_type = typeOf _obj;
_pos = _obj getVariable ["OEMPos",getPosATL _obj];
_dir = direction _obj;
_vector = [vectorDir _obj, vectorUp _obj];
_charID = _obj getVariable ["CharacterID","0"];
_objectID = _obj getVariable ["ObjectID","0"];
_objectUID = _obj getVariable ["ObjectUID","0"];
_ownerID = _obj getVariable ["ownerPUID","0"];
_lockCode = _charID;
_suppliedCode = [_charID,_this select 3] select (count _this > 3);
_exitReason = "";
if (_status != 3 && {_status != 6}) then {_lockCode = _suppliedCode;};
// Player may have disconnected or died before message send. Attempt lock/unlock/pack/save procedure anyway
if (isNull _player) then {diag_log "ERROR: server_handleSafeGear called with Null player object";};
_clientID = owner _player;
_playerUID = getPlayerUID _player;
_statusText = call {
if (_status == 0) exitwith {"UNLOCKED"}; // unlock safe/lockbox
if (_status == 1) exitwith {"LOCKED"}; // lock safe/lockbox
if (_status == 5) exitwith {"UNLOCKED"}; // unlock door
if (_status == 4) exitwith {_lockCode = _charID; "LOCKED"}; // lock door
if (_status == 3) exitwith {"FAILED unlocking"}; // failed unlock safe/lockbox
if (_status == 6) exitwith {"FAILED unlocking"}; // failed unlocking door
if (_status == 2) exitwith {"PACKED"}; // pack safe/lockbox
};
if (isNull _obj) exitWith {
diag_log format["ERROR: server_handleSafeGear called with Null object by %1 (%2). %3 attempt failed.",_name,_playerUID,_statusText];
if (_status < 3) then {
dze_waiting = "fail";
_clientID publicVariableClient "dze_waiting";
};
};
if !(_type in DZE_DoorsLocked) then {
_clientKey = _this select 4;
_exitReason = [_this,_statusText,(getPosATL _obj),_clientKey,_playerUID,_player] call server_verifySender;
};
if (_exitReason != "") exitWith {diag_log _exitReason};
call {
if (_status == 0) exitwith { //Unlocking
_unlockedClass = getText (configFile >> "CfgVehicles" >> _type >> "unlockedClass");
_weapons = _obj getVariable ["WeaponCargo",[]];
_magazines = _obj getVariable ["MagazineCargo",[]];
_backpacks = _obj getVariable ["BackpackCargo",[]];
if (Z_singleCurrency) then {_coins = _obj getVariable ["cashMoney",0];};
_damage = damage _obj;
// Create new unlocked safe, then delete old locked safe
_holder = _unlockedClass createVehicle [0,0,0];
_holder setDir _dir;
_holder setVariable ["memDir",_dir,true];
_holder setVectorDirAndUp _vector;
_holder setPosATL _pos;
_holder setVariable ["CharacterID",_charID,true];
_holder setVariable ["ObjectID",_objectID,true];
_holder setVariable ["ObjectUID",_objectUID,true];
_holder setVariable ["OEMPos",_pos,true];
_holder setDamage _damage;
if (DZE_permanentPlot) then {_holder setVariable ["ownerPUID",_ownerID,true];};
if (Z_singleCurrency) then {_holder setVariable ["cashMoney",_coins,true];};
deleteVehicle _obj;
[_weapons,_magazines,_backpacks,_holder] call fn_addCargo;
};
if (_status == 1) exitwith { //Locking
_lockedClass = getText (configFile >> "CfgVehicles" >> _type >> "lockedClass");
// Save to database (also happens if a player is within 10m in server_playerSync and server_onPlayerDisconnect)
[_obj,"gear"] call server_updateObject;
_weapons = getWeaponCargo _obj;
_magazines = getMagazineCargo _obj;
_backpacks = getBackpackCargo _obj;
if (Z_singleCurrency) then {_coins = _obj getVariable ["cashMoney",0];};
_damage = damage _obj;
// Create new locked safe, then delete old unlocked safe
_holder = _lockedClass createVehicle [0,0,0];
_holder setDir _dir;
_holder setVariable ["memDir",_dir,true];
_holder setVectorDirAndUp _vector;
_holder setPosATL _pos;
_holder setVariable ["CharacterID",_charID,true];
_holder setVariable ["ObjectID",_objectID,true];
_holder setVariable ["ObjectUID",_objectUID,true];
_holder setVariable ["OEMPos",_pos,true];
_holder setDamage _damage;
if (DZE_permanentPlot) then {_holder setVariable ["ownerPUID",_ownerID,true];};
if (Z_singleCurrency) then {_holder setVariable ["cashMoney",_coins,true];};
deleteVehicle _obj;
// Local setVariable gear onto new locked safe for easy access on next unlock
// Do not send big arrays over network! Only server needs these
_holder setVariable ["WeaponCargo",_weapons,false];
_holder setVariable ["MagazineCargo",_magazines,false];
_holder setVariable ["BackpackCargo",_backpacks,false];
};
if (_status == 2) exitwith { //Packing
_packedClass = getText (configFile >> "CfgVehicles" >> _type >> "packedClass");
if (_packedClass == "") exitWith {diag_log format["Server_HandleSafeGear Error: invalid object type: %1",_type];};
_weapons = getWeaponCargo _obj;
_magazines = getMagazineCargo _obj;
_backpacks = getBackpackCargo _obj;
if (Z_singleCurrency) then {_coins = _obj getVariable ["cashMoney",0];};
_holder = _packedClass createVehicle [0,0,0];
deleteVehicle _obj;
_holder setDir _dir;
_holder setPosATL _pos;
_holder addMagazineCargoGlobal [getText(configFile >> "CfgVehicles" >> _packedClass >> "seedItem"),1];
[_weapons,_magazines,_backpacks,_holder] call fn_addCargo;
if (Z_singleCurrency && {_coins > 0}) then {
private "_displayName";
_displayName = getText (configFile >> "CfgVehicles" >> _type >> "displayName");
_wealth = _player getVariable [(["cashMoney","globalMoney"] select Z_persistentMoney),0];
_player setVariable [(["cashMoney","globalMoney"] select Z_persistentMoney),_wealth + _coins,true];
RemoteMessage = ["systemChat",["STR_CL_ZSC_PACK_WARNING",_displayName,[_coins] call BIS_fnc_numberText,CurrencyName]];
(owner _player) publicVariableClient "RemoteMessage";
};
// Delete safe from database
[_objectID,_objectUID,_obj] call server_deleteObjDirect;
};
};
if (_status < 4) then {
_type = call {
if (_type in ["VaultStorageLocked","VaultStorage","VaultStorage2Locked","VaultStorage2","TallSafe"]) exitwith {
if (_ownerID == _playerUID) then {_lockCode = format["%1 - Owner",_lockCode];};
"Safe"
};
if (_type in ["LockboxStorage","LockboxStorageLocked","LockboxStorage2","LockboxStorage2Locked","LockboxStorageWinterLocked","LockboxStorageWinter2Locked","LockboxStorageWinter","LockboxStorageWinter2"]) exitwith {
if (_ownerID == _playerUID) then {
_lockCode = _charID call fnc_lockCode;
_lockCode = format["%1 - Owner",_lockCode];
} else {
_lockCode = _charID call fnc_lockCode;
};
if (_status == 3) then {_suppliedCode = _suppliedCode call fnc_lockCode;};
"LockBox"
};
};
};
if (_statusText == "FAILED unlocking") then {
_message = format["%1 (%2) %3 %4 with code: %5 (actual: %8) @%6 %7, ObjectID: %8, ObjectUID: %9",_name,_playerUID,_statusText,_type,_suppliedCode,mapGridPosition _pos,_pos,_lockCode,_objectID,_objectUID];
} else {
_message = format["%1 (%2) %3 %4 with code: %5 @%6 %7, ObjectID: %8, ObjectUID: %9",_name,_playerUID,_statusText,_type,_lockCode,mapGridPosition _pos,_pos,_objectID,_objectUID];
};
diag_log _message;
if (_status < 3) then {
dze_waiting = "success";
_clientID publicVariableClient "dze_waiting";
};

View File

@ -0,0 +1,47 @@
/* Maintain Area - written by Skaronator */
/*
1: PVDZE_maintainArea = [player,1,[[Object, _objectID, _objectUID],[Object, _objectID, _objectUID]...etc]];
2: PVDZE_maintainArea = [player,2,[Object, _objectID, _objectUID]];
*/
private ["_player","_option","_obj","_name","_objectsInfo","_UID","_ID","_key"];
_player = _this select 0;
_option = _this select 1;
_objectsInfo = _this select 2;
if (_option == 1) then {
{
_obj = _x select 0;
_ID = _x select 1;
_UID = _x select 2;
if (_ID == "0") then {
if (_UID != "0") then {
_obj setDamage 0;
_key = format["CHILD:397:%1:", _UID];
_key call server_hiveWrite;
};
} else {
_obj setDamage 0;
_key = format["CHILD:396:%1:", _ID];
_key call server_hiveWrite;
};
} count _objectsInfo;
_name = if (alive _player) then { name _player; } else { "Dead Player"; };
diag_log format ["MAINTAIN AREA BY %1 - %2 Objects at %3, Grid: %4", _name, (count _objectsInfo), (getPosATL _player), mapGridPosition(getPosATL _player)];
} else {
_obj = _objectsInfo select 0;
_ID = _objectsInfo select 1;
_UID = _objectsInfo select 2;
if (_ID == "0") then {
if (_UID != "0") then {
_obj setDamage 0;
_key = format["CHILD:397:%1:", _UID];
_key call server_hiveWrite;
};
} else {
_obj setDamage 0;
_key = format["CHILD:396:%1:", _ID];
_key call server_hiveWrite;
};
};

View File

@ -0,0 +1,98 @@
/*
WARNING: Alive player objects are deleted by Arma shortly after onPlayerDisconnected fires
because DayZ uses disabledAI=1 https://community.bistudio.com/wiki/Description.ext#disabledAI
References to the player object after that point will return objNull, so this function
and server_playerSync must be fast or the player will not save.
*/
private ["_playerObj","_playerUID","_playerPos","_playerName","_characterID","_inCombat","_Sepsis"];
_playerUID = _this select 0;
_playerName = _this select 1;
_playerObj = nil;
//Lets search all players looking for the object that matches our UID
//If the player just died then the new unit they respawned into will be found (respawnDelay=0 in description.ext)
{
if ((getPlayerUID _x) == _playerUID) exitWith { _playerObj = _x; _playerPos = getPosATL _playerObj;};
} count playableUnits;
//If playerObj is not in playableUnits then lets exit the disconnect system.
if (isNil "_playerObj") exitWith {
diag_log format["INFO: OnPlayerDisconnect exiting. Player is not in playableUnits. %1", _this];
};
//Player object is alive in debug zone. The player most likely just respawned.
if (_playerPos distance respawn_west_original < 1500) exitWith {
diag_log format["INFO: OnPlayerDisconnect exiting. Player is near respawn_west. This is normal after death. %1", _this];
if (!isNull _playerObj) then {
_playerObj call sched_co_deleteVehicle;
};
};
//diag_log format["get: %1 (%2), sent: %3 (%4)",typeName (getPlayerUID _playerObj), getPlayerUID _playerObj, typeName _playerUID, _playerUID];
//If the the playerObj exists lets run all sync systems
_characterID = _playerObj getVariable["characterID", "?"];
_inCombat = _playerObj getVariable ["inCombat",false];
_Sepsis = _playerObj getVariable["USEC_Sepsis",false];
//Login processing do not sync
if (_playerUID in dayz_ghostPlayers) exitWith {
//Note player is alive (see set in dayz_ghostPlayers below)
diag_log format["ERROR: Cannot Sync Character [%1,%2] Still processing login",_playerName,_playerUID];
//Lets remove the object.
if (!isNull _playerObj) then {
_playerObj call sched_co_deleteVehicle;
};
};
//Make sure we know the ID of the object before we try and sync any info to the DB
if (_characterID != "?") then {
//If the player has sepsis before logging off lets give them infected status.
if (_Sepsis) then {
_playerObj setVariable["USEC_infected",true,true];
};
//if player object is alive lets sync the player and remove the body and if ghosting is active add the player id to the array
if (alive _playerObj) then {
// High priority. Sync must finish fast before player object isNull
[_playerObj,nil,nil,nil,_inCombat] call server_playerSync;
/*
Low priority code below this point where
_playerObj is no longer needed and may be Null.
*/
//Punish combat log
if (_inCombat) then {
// Moved setVariables to server_playerSync since they are high priority
// Messages are low priority. Player object not needed
diag_log format["PLAYER COMBAT LOGGED: %1(%3) at location %2",_playerName,_playerPos,_playerUID];
[nil, nil, rTitleText, format["Player %1 combat logged at location %2.",_playerName, mapGridPosition _playerPos], "PLAIN"] call RE; // Message whole server
};
if (dayz_enableGhosting) then {
//diag_log format["GhostPlayers: %1, ActivePlayers: %2",dayz_ghostPlayers,dayz_activePlayers];
if (!(_playerUID in dayz_ghostPlayers)) then {
dayz_ghostPlayers set [count dayz_ghostPlayers, _playerUID];
dayz_activePlayers set [count dayz_activePlayers, [_playerUID,diag_ticktime]];
//diag_log format["playerID %1 added to ghost list",_playerUID];
};
};
} else {
//Done in server_playerSync above if player is alive
{[_x,"gear"] call server_updateObject} count (nearestObjects [[_playerObj] call FNC_GetPos,DayZ_GearedObjects,10]);
};
[_playerUID,_characterID,3,_playerName,(_playerPos call fa_coor2str)] call dayz_recordLogin;
};
missionNamespace setVariable [_playerUID,nil];
if (alive _playerObj) then {
_playerObj call sched_co_deleteVehicle;
};

View File

@ -0,0 +1,21 @@
private ["_SWcorner","_NEcorner","_amount","_a","_b","_c"];
_SWcorner = [0,1360];
_NEcorner = [14400,13560];
_a = [(_SWcorner select 0), (_SWcorner select 1), (_NEcorner select 0) - (_SWcorner select 0), (_NEcorner select 1) - (_SWcorner select 1) ] call psrnd_init;
_b = [ -15, -15, 30, 30 ] call psrnd_init;
_c = [ 0, 0, 3, 360 ] call psrnd_init;
PVCDZ_plr_plantSpawner = [ _a, _b, _c, [] ];
//diag_log [ __FILE__, _a, _b, _c ];
"PVDZ_objgather_Delete" addPublicVariableEventHandler {
private [ "_pos", "_blacklist"];
_pos = (_this select 1);
_blacklist = PVCDZ_plr_plantSpawner select 3;
_blacklist set [ count _blacklist, _pos ];
//diag_log [ __FILE__, _this, _blacklist ];
};

View File

@ -0,0 +1,19 @@
#include "\z\addons\dayz_server\compile\server_toggle_debug.hpp"
private["_character","_clientID"];
_character = _this select 0;
_clientID = owner _character;
#ifdef SERVER_DEBUG
diag_log ("HIVE: Player Death list Request by ClientID: "+ str(_clientID));
diag_log(PlayerDeaths);
#endif
PVDZE_plr_DeathBResult = PlayerDeaths;
if(!isNull _character) then {
_clientID publicVariableClient "PVDZE_plr_DeathBResult";
};
PlayerDeaths

View File

@ -0,0 +1,90 @@
#include "\z\addons\dayz_server\compile\server_toggle_debug.hpp"
private ["_characterID","_minutes","_newObject","_playerID","_playerName","_key","_pos","_infected","_sourceName","_sourceWeapon","_distance","_message","_method","_suicide","_bodyName","_type","_sourceID"];
//[unit, weapon, muzzle, mode, ammo, magazine, projectile]
_characterID = _this select 0;
_minutes = _this select 1;
_newObject = _this select 2;
_playerID = _this select 3;
_playerName = toString (_this select 4); //Sent as array to avoid publicVariable value restrictions
_infected = _this select 5;
_sourceName = toString (_this select 6);
_sourceWeapon = _this select 7;
_distance = _this select 8;
_method = _this select 9;
_sourceID = _this select 10;
//Mark player as dead so we bypass the ghost system
dayz_died set [count dayz_died, _playerID];
_newObject setVariable ["bodyName",_playerName,true];
_newObject setVariable ["bodyUID",_playerID,true];
_pos = getPosATL _newObject;
// force to follow the terrain slope in sched_corpses.sqf
//if (_pos select 2 < 0.1) then {_pos set [2,0];};
//_newObject setVariable ["deathPos",_pos];
if (typeName _minutes == "STRING") then {_minutes = parseNumber _minutes;};
if (_characterID != "0") then {
_key = format["CHILD:202:%1:%2:%3:",_characterID,_minutes,_infected];
//diag_log ("HIVE: WRITE: "+ str(_key));
_key call server_hiveWrite;
};
diag_log format ["Player %1(%3) died as %5 at %2 CharID: %4",
_newObject call fa_plr2str, _pos call fa_coor2str,
_playerID, _characterID,
typeOf _newObject
];
// DEATH MESSAGES
_suicide = ((_sourceName == _playerName) or (_method == "suicide"));
if (_method in ["explosion","melee","shot","shothead","shotheavy","suicide"] && {!(_method == "explosion" && {_suicide || {_sourceName == "unknown"}})}) then {
if (_suicide) then {
_message = ["suicide",_playerName];
} else {
if (_sourceWeapon == "") then {_sourceWeapon = "unknown weapon";};
_message = ["killed",_playerName,_sourceName,_sourceWeapon,_distance];
// Store death messages to allow viewing at message board in trader citys.
PlayerDeaths set [count PlayerDeaths,[_playerName,_sourceName,_sourceWeapon,_distance,[(ServerCurrentTime select 3), (ServerCurrentTime select 4)]]];
};
} else {
// No source name, distance or weapon needed: "%1 died from %2" str_death_%1 (see stringtable)
// Possible methods: ["bled","combatlog","crash","crushed","dehyd","eject","fall","starve","sick","rad","runover","unknown","zombie"]
_message = ["died",_playerName,_method];
};
if (_playerName != "unknown" || {_sourceName != "unknown"}) then {
if (toLower DZE_DeathMsgChat != "none" || {DZE_DeathMsgRolling} || {DZE_DeathMsgDynamicText}) then {
PVDZE_deathMessage = _message;
//Don't use regular PV here since JIP clients don't need it
owner _newObject publicVariableClient "PVDZE_deathMessage"; //Send to dead player (not in playableUnits)
{
if !(getPlayerUID _x in ["",_playerID]) then {
owner _x publicVariableClient "PVDZE_deathMessage";
};
} count playableUnits;
};
_type = _message select 0;
_bodyName = _message select 1;
if (_type == "killed" && {_sourceName == "AI"}) then {
_message set [2, (localize "STR_PLAYER_AI")];
};
_message = call {
if (_type == "died") exitwith {format ["%1(%3) died from %2", _bodyName, localize format["str_death_%1",_message select 2],_playerID]};
if (_type == "killed") exitwith {format ["%1(%5) was killed by %2(%6) with %3 from %4m", _bodyName, _message select 2, _message select 3, _message select 4,_playerID,_sourceID]};
if (_type == "suicide") exitwith {format ["%1(%2) committed suicide", _bodyName,_playerID]};
};
diag_log format["DeathMessage: %1",_message];
};
_newObject setDamage 1;
_newObject setOwner 0;
//dead_bodyCleanup set [count dead_bodyCleanup,_newObject];

View File

@ -0,0 +1,201 @@
private ["_playerID","_endMission","_0","_1","_timeleft","_doLoop","_key","_primary","_model","_inventory","_backpack","_survival","_CharacterCoins","_group","_playerCoins","_BankCoins","_hiveVer","_mags","_wpns","_bcpk","_config","_isInfected","_remaining","_playerObj","_playerName","_newPlayer","_isNew","_charID","_isHiveOk"];
#include "\z\addons\dayz_server\compile\server_toggle_debug.hpp"
_playerID = _this select 0;
_playerObj = _this select 1;
_playerName = name _playerObj;
if (_playerName == '__SERVER__' || _playerID == '' || local player) exitWith {};
// Cancel any login until server_monitor terminates.
// This is mandatory since all vehicles must be spawned before the first players spawn on the map.
// Otherwise, all vehicle event handlers won't be created on players' client side.
if (isNil "sm_done") exitWith { diag_log ("Login cancelled, server is not ready. " + str(_playerObj)); };
_inventory = [];
_backpack = [];
_survival = [0,0,0,0];
_model = "";
_isInfected = 0;
_CharacterCoins = 0;
_group = [];
_playerCoins = 0;
_BankCoins = 0;
if (_playerID == "") then {
_playerID = getPlayerUID _playerObj;
};
if ((_playerID == "") or (isNil "_playerID")) exitWith {
diag_log ("LOGIN FAILED: Player [" + _playerName + "] has no login ID");
};
_endMission = false;
_timeleft = 0;
{
//if ((_playerID select _i) in activePlayers) exitWith { diag_log ("Login cancelled, player has logged out within the past 2 mins. " + str(_playerObj)); };
_0 = _x select 0;
_1 = _x select 1;
_timeleft = diag_ticktime - _1;
if (_playerID == _0) then {
//If players last logoff is about the ghost timer remove player from ghost que.
if ((_timeleft > dayz_ghostTimer) or (_timeleft < 0)) then {
dayz_ghostPlayers = dayz_ghostPlayers - [_0];
dayz_activePlayers set [_forEachIndex, _0];
dayz_activePlayers = dayz_activePlayers - [_0];
} else {
//if player is in died allow them passage.
if (_playerID in dayz_died) then {
dayz_died = dayz_died - [_playerID];
dayz_ghostPlayers = dayz_ghostPlayers - [_0];
dayz_activePlayers set [_forEachIndex, _0];
dayz_activePlayers = dayz_activePlayers - [_0];
} else {
// Logoff time is not beyond ghost time and player didn't die
_endMission = true;
};
};
};
} forEach dayz_activePlayers;
//Do Connection Attempt
_doLoop = 0;
while {_doLoop < 5} do {
_key = format["CHILD:101:%1:%2:%3:",_playerID,dayZ_instance,_playerName];
_primary = _key call server_hiveReadWrite;
if (count _primary > 0) then {
if ((_primary select 0) != "ERROR") then {
_doLoop = 9;
};
};
_doLoop = _doLoop + 1;
};
if (isNull _playerObj or !isPlayer _playerObj) exitWith {
diag_log ("LOGIN RESULT: Exiting, player object null: " + str(_playerObj));
};
if ((_primary select 0) == "ERROR") exitWith {
diag_log format ["LOGIN RESULT: Exiting, failed to load _primary: %1 for player: %2 ",_primary,_playerID];
};
//Process request
_newPlayer = _primary select 1;
_isNew = count _primary < 10; //_result select 1;
_charID = _primary select 2;
//diag_log ("LOGIN RESULT: " + str(_primary));
/* PROCESS */
_hiveVer = 0;
if (!_isNew) then {
//RETURNING CHARACTER
_inventory = _primary select 4;
_backpack = _primary select 5;
_survival = _primary select 6;
_CharacterCoins = _primary select 7;
_model = _primary select 8;
_group = _primary select 9;
_playerCoins = _primary select 10;
_BankCoins = _primary select 11;
_hiveVer = _primary select 12;
if !(_model in AllPlayers) then {_model = "Survivor2_DZ";};
} else {
_isInfected = if (DZE_PlayerZed) then {_primary select 3} else {0};
_model = _primary select 4;
_group = _primary select 5;
_playerCoins = _primary select 6;
_BankCoins = _primary select 7;
_hiveVer = _primary select 8;
if (isNil "_model") then {
_model = "Survivor2_DZ";
} else {
if (_model == "") then {_model = "Survivor2_DZ";};
};
//Record initial inventory only if not player zombie
if (_isInfected != 1) then {
_config = configFile >> "CfgSurvival" >> "Inventory" >> "Default";
_mags = getArray (_config >> "magazines");
_wpns = getArray (_config >> "weapons");
_bcpk = getText (_config >> "backpack");
if (!isNil "DefaultMagazines") then {_mags = DefaultMagazines;};
if (!isNil "DefaultWeapons") then {_wpns = DefaultWeapons;};
if (!isNil "DefaultBackpack") then {_bcpk = DefaultBackpack;};
//Wait for HIVE to be free
_key = str formatText["CHILD:203:%1:%2:%3:",_charID,[_wpns,_mags],[_bcpk,[],[]]];
_key call server_hiveWrite;
};
};
_isHiveOk = (_hiveVer >= dayz_hiveVersionNo); //EDITED
/*
if (count _inventory > 2 && {typeName (_inventory select 2) != "STRING"}) then {
//Pre 1.0.6 character with Zupa 3.0 coins where dayz_onBack should be. Wipe coins and log playerID and amount to RPT.
diag_log format["%1 - Updating pre 1.0.6 character inventory to add dayz_onBack. Coins have been wiped for PlayerID: %2 PreviousCoins:%3",__FILE__,_playerID,(_inventory select 2)];
_inventory set [2,""];
};
*/
PVCDZ_plr_Login = [_charID,_inventory,_backpack,_survival,_isNew,dayz_versionNo,_model,_isHiveOk,_newPlayer,_isInfected,_group,_CharacterCoins,_playerCoins,_BankCoins];
(owner _playerObj) publicVariableClient "PVCDZ_plr_Login";
//Make player wait until ghost timer is up.
if (_endMission) exitwith {
_remaining = dayz_ghostTimer - _timeleft;
//Log For GhostMode
diag_log format["INFO - Player:%1(UID:%2/CID%3) Status: LOGIN CANCELLED, GHOSTMODE. Time remianing: %4",_playerName,_playerID,_charID,_remaining];
PVCDZ_plr_Ghost = [_remaining];
(owner _playerObj) publicVariableClient "PVCDZ_plr_Ghost";
};
//Sync chopped trees for JIP player
{_x setDamage 1} count dayz_choppedTrees;
if (toLower worldName in ["chernarus","chernarus_winter"]) then {
//Destroy glitched map objects which can not be deleted or hidden
{(_x select 0) nearestObject (_x select 1) setDamage 1} count [
//Clipped benches in barracks hallway
[[4654,9595,0],145259],
[[4654,9595,0],145260],
//Clip into Land_houseV_2T2
[[3553,2563,0],327203], //popelnice.p3d trash can
[[9649,10412,0],240641], //popelnice.p3d trash can
[[12085,3581,0],373017], //popelnice.p3d trash can
[[2632,5064,0],188661], //popelnice.p3d trash can
[[11772,12195,0],251224], //lavicka_1.p3d bench
[[2581,3456,0],1019127], //lavicka_2.p3d bench
//Clip into zero_building Land_HouseV_3I3
[[2800,5202,0],187548], //popelnice.p3d trash can
[[12876,8031,0],294873], //popelnice.p3d trash can
//Clip into zero_building Land_HouseV_1L2
[[3656,2429,0],327885], //plot_rust_draty.p3d fence
[[3656,2429,0],328107], //plot_rust_draty.p3d fence
[[3656,2429,0],328108], //plot_rust_draty.p3d fence
[[3656,2429,0],328109], //plot_rust_draty.p3d fence
[[3656,2429,0],328110], //plot_rust_draty.p3d fence
//Floating stump misc_stub1.p3d
[[9084,8654,0],244480]
];
};
//Sync active group invites to JIP player
if (count dayz_activeInvites > 0) then {
(owner _playerObj) publicVariableClient "dayz_activeInvites";
};
//Record Player Login/LogOut
[_playerID,_charID,2,(_playerObj call fa_plr2str),((getPosATL _playerObj) call fa_coor2str)] call dayz_recordLogin;
PVCDZ_plr_PlayerAccepted = [_playerName,diag_ticktime];
(owner _playerObj) publicVariableClient "PVCDZ_plr_PlayerAccepted";
if ((count DZE_ServerMarkerArray) > 0) then {
PVDZ_ServerMarkerSend = ["JIP",DZE_ServerMarkerArray];
(owner _playerObj) publicVariableClient "PVDZ_ServerMarkerSend";
};

View File

@ -0,0 +1,250 @@
private ["_dir","_IslandMap","_pos","_randomKey","_findIndex","_characterID","_playerObj","_spawnSelection","_inventory","_playerID","_dummy","_worldspace","_state","_doLoop","_key","_primary","_medical","_stats","_humanity","_randomSpot","_position","_distance","_fractures","_score","_findSpot","_mkr","_j","_isIsland","_w","_clientID","_lastInstance"];
_characterID = _this select 0;
_playerObj = _this select 1;
_spawnSelection = _this select 3;
_inventory = _this select 4;
_playerID = getPlayerUID _playerObj;
#include "\z\addons\dayz_server\compile\server_toggle_debug.hpp"
if (isNull _playerObj) exitWith {
diag_log ("SETUP INIT FAILED: Exiting, player object null: " + str(_playerObj));
};
if (_playerID == "") then {
_playerID = getPlayerUID _playerObj;
};
if (_playerID == "") exitWith {
diag_log ("SETUP INIT FAILED: Exiting, no player ID: " + str(_playerObj));
};
_dummy = getPlayerUID _playerObj;
if (_playerID != _dummy) then {
diag_log format["DEBUG: _playerID miscompare with UID! _playerID:%1",_playerID];
_playerID = _dummy;
};
_worldspace = [];
_state = [];
//Do Connection Attempt
_doLoop = 0;
while {_doLoop < 5} do {
_key = format["CHILD:102:%1:",_characterID];
_primary = _key call server_hiveReadWrite;
if (count _primary > 0) then {
if ((_primary select 0) != "ERROR") then {
_doLoop = 9;
};
};
_doLoop = _doLoop + 1;
};
if (isNull _playerObj || !isPlayer _playerObj) exitWith {
diag_log ("SETUP RESULT: Exiting, player object null: " + str(_playerObj));
};
//Wait for HIVE to be free
//diag_log ("SETUP: RESULT: Successful with " + str(_primary));
_medical = _primary select 1;
_stats = _primary select 2;
_worldspace = _primary select 4;
_humanity = _primary select 5;
_lastInstance = _primary select 6;
_randomSpot = false; //Set position
_state = [["",""],_primary select 3 select 0] select (count _primary >= 4);
_dir = 0;
//diag_log ("WORLDSPACE: " + str(_worldspace));
if (count _worldspace > 0) then {
_dir = _worldspace select 0;
_position = _worldspace select 1;
if (count _position < 3) exitWith {_randomSpot = true;}; //prevent debug world!
_distance = respawn_west_original distance _position;
if (_distance < 2000) then {_randomSpot = true;};
_distance = [0,0,0] distance _position;
if (_distance < 500) then {_randomSpot = true;};
//_playerObj setPosATL _position;
// Came from another server force random spawn
if (_lastInstance != dayZ_instance) then {_randomSpot = true;};
} else {
_randomSpot = true;
};
//diag_log ("LOGIN: Location: " + str(_worldspace) + " doRnd?: " + str(_randomSpot));
//set medical values
if (count _medical > 0) then {
_playerObj setVariable ["USEC_isDead",(_medical select 0),true];
_playerObj setVariable ["NORRN_unconscious",(_medical select 1),true];
_playerObj setVariable ["USEC_infected",(_medical select 2),true];
_playerObj setVariable ["USEC_injured",(_medical select 3),true];
_playerObj setVariable ["USEC_inPain",(_medical select 4),true];
_playerObj setVariable ["USEC_isCardiac",(_medical select 5),true];
_playerObj setVariable ["USEC_lowBlood",(_medical select 6),true];
_playerObj setVariable ["USEC_BloodQty",(_medical select 7),true];
//Add bleeding wounds
{
_playerObj setVariable ["hit_"+_x,true,true];
} forEach (_medical select 8);
//Add fractures
_fractures = _medical select 9;
_playerObj setVariable ["hit_legs",(_fractures select 0),true];
_playerObj setVariable ["hit_hands",(_fractures select 1),true];
_playerObj setVariable ["unconsciousTime",(_medical select 10),true];
_playerObj setVariable ["messing",if (count _medical >= 14) then {(_medical select 13)} else {[0,0,0]},true];
_playerObj setVariable ["blood_testdone",if (count _medical >= 15) then {(_medical select 14)} else {false},true];
if (count _medical > 12 && {typeName (_medical select 11) == "STRING"}) then { //Old character had no "messing" OR "messing" in place of blood_type
_playerObj setVariable ["blood_type",(_medical select 11),true];
_playerObj setVariable ["rh_factor",(_medical select 12),true];
// diag_log [ "Character data: blood_type,rh_factor,testdone=",
// _playerObj getVariable ["blood_type", "?"],_playerObj getVariable ["rh_factor", "?"], _playerObj getVariable ["blood_testdone", false]
// ];
} else {
_playerObj call player_bloodCalc;
diag_log [ "Character upgrade to 1.8.3: blood_type,rh_factor=",_playerObj getVariable ["blood_type", "?"],_playerObj getVariable ["rh_factor", "?"]];
};
} else {
//Reset bleeding wounds
call fnc_usec_resetWoundPoints;
//Reset fractures
_playerObj setVariable ["hit_legs",0,true];
_playerObj setVariable ["hit_hands",0,true];
_playerObj setVariable ["USEC_injured",false,true];
_playerObj setVariable ["USEC_inPain",false,true];
_playerObj call player_bloodCalc; // will set blood_type and rh_factor according to real population statitics
//diag_log [ "New character setup: blood_type,rh_factor=",_playerObj getVariable ["blood_type", "?"],_playerObj getVariable ["rh_factor", "?"]];
_playerObj setVariable ["messing",[0,0,0],true];
_playerObj setVariable ["blood_testdone",false,true];
};
if (count _stats > 0) then {
//register stats Global
_playerObj setVariable ["zombieKills",(_stats select 0),true];
_playerObj setVariable ["headShots",(_stats select 1),true];
_playerObj setVariable ["humanKills",(_stats select 2),true];
_playerObj setVariable ["banditKills",(_stats select 3),true];
//ConfirmedKills
_playerObj setVariable ["ConfirmedHumanKills",(_stats select 2),true];
_playerObj setVariable ["ConfirmedBanditKills",(_stats select 3),true];
_playerObj addScore (_stats select 1);
//Save Score
_score = score _playerObj;
_playerObj addScore ((_stats select 0) - _score);
missionNamespace setVariable [_playerID,[_humanity,(_stats select 0),(_stats select 1),(_stats select 2),(_stats select 3)]];
} else {
//register stats
_playerObj setVariable ["zombieKills",0,true];
_playerObj setVariable ["humanKills",0,true];
_playerObj setVariable ["banditKills",0,true];
_playerObj setVariable ["headShots",0,true];
//ConfirmedKills
_playerObj setVariable ["ConfirmedHumanKills",0,true];
_playerObj setVariable ["ConfirmedBanditKills",0,true];
missionNamespace setVariable [_playerID,[_humanity,0,0,0,0]];
};
if (_randomSpot) then {
if (!isDedicated) then {endLoadingScreen;};
_IslandMap = (toLower worldName in ["caribou","cmr_ovaron","dayznogova","dingor","dzhg","fallujah","fapovo","fdf_isle1_a","isladuala","lingor","mbg_celle2","namalsk","napf","oring","panthera2","ruegen","sara","sauerland","smd_sahrani_a2","tasmania2010","tavi","taviana","trinity","utes"]);
//spawn into random
_findSpot = true;
_mkr = [];
_position = [0,0,0];
_j = 0;
while {_findSpot && _j <= 100} do {
if (_spawnSelection == 9) then {
// random spawn location selected, lets get the marker and spawn in somewhere
if (dayz_spawnselection == 1) then {_mkr = getMarkerPos ("spawn" + str(floor(random 6)));} else {_mkr = getMarkerPos ("spawn" + str(floor(random actualSpawnMarkerCount)));};
} else {
// spawn is not random, lets spawn in our location that was selected
_mkr = getMarkerPos ("spawn" + str(_spawnSelection));
};
_position = ([_mkr,0,spawnArea,10,0,2,spawnShoremode] call BIS_fnc_findSafePos);
if ((count _position >= 2) // !bad returned position
&& {(_position distance _mkr < spawnArea)}) then { // !ouside the disk
_position set [2, 0];
if (((ATLtoASL _position) select 2 > 2.5) //! player's feet too wet
&& {({alive _x} count (_position nearEntities ["CAManBase",150]) == 0)}) then { // !too close from other players/zombies
_pos = +(_position);
_isIsland = false; //Can be set to true during the Check
// we check over a 809-meter cross line, with an effective interlaced step of 5 meters
_w = 0;
while {_w != 809} do {
//if (_w < 17) then { diag_log format[ "%1 loop starts with _w=%2", __FILE__, _w]; };
_pos = [((_pos select 0) - _w),((_pos select 1) + _w),(_pos select 2)];
if ((surfaceisWater _pos) && !_IslandMap) exitWith {_isIsland = true;};
_w = ((_w + 17) % 811);
};
if (!_isIsland) then {_findSpot = false};
};
};
//diag_log format["%1: pos:%2 _findSpot:%3", __FILE__, _position, _findSpot];
_j = _j + 1;
};
if (_findSpot && !_IslandMap) exitWith {
diag_log format["%1: Error, failed to find a suitable spawn spot for player. area:%2",__FILE__, _mkr];
};
_worldspace = [_dir,_position];
//Fresh spawn, clear animationState so anim from last sync does not play on login
_state = ["","reset"];
};
//record player pos locally for server checking
_playerObj setVariable ["characterID",_characterID,true];
_playerObj setVariable ["humanity",_humanity,true];
_playerObj setVariable ["lastPos",_position];
_clientID = owner _playerObj;
_randomKey = [];
for "_i" from 0 to 12 do {
_randomKey set [_i, (ceil(random 128)) + 256]; //Latin Extended-A characters not filtered in publicvariableval.txt
};
_randomKey = toString _randomKey;
_findIndex = dayz_serverPUIDArray find _playerID;
if (_findIndex > -1) then {
dayz_serverClientKeys set [_findIndex, [_clientID,_randomKey]];
} else {
dayz_serverPUIDArray set [(count dayz_serverPUIDArray), _playerID];
dayz_serverClientKeys set [(count dayz_serverClientKeys), [_clientID,_randomKey]];
};
// Sync weather settings for JIP player
_clientID publicVariableClient "PVDZE_SetWeather";
//PVCDZ_plr_Login2 = [_worldspace,_state,_randomKey];
PVCDZ_plr_Login2 = [[0,respawn_west_original],_state,_randomKey,_worldspace,_randomSpot,([_randomSpot,_playerID] call spawn_config)];
_clientID publicVariableClient "PVCDZ_plr_Login2";
if (dayz_townGenerator) then {
_clientID publicVariableClient "PVCDZ_plr_plantSpawner";
};
//record time started
_playerObj setVariable ["lastTime",diag_ticktime];
//set server-side inventory variable to monitor player gear
if (count _inventory > 2) then {
_playerObj setVariable["ServerMagArray",[_inventory select 1,_inventory select 2,_inventory select 0], false];
};
//Record Player Login/LogOut
[_playerID,_characterID,1,(_playerObj call fa_plr2str),((_worldspace select 1) call fa_coor2str)] call dayz_recordLogin;
PVDZ_plr_Login1 = null;
PVDZ_plr_Login2 = null;

View File

@ -0,0 +1,237 @@
#include "\z\addons\dayz_server\compile\server_toggle_debug.hpp"
local _character = _this select 0;
local _magazines = _this select 1;
local _dayz_onBack = _this select 2;
local _weaponsPlayer = _this select 3;
local _characterID = _character getVariable ["characterID","0"];
local _playerUID = getPlayerUID _character;
local _charPos = getPosATL _character;
local _isInVehicle = vehicle _character != _character;
local _timeSince = 0;
local _humanity = 0;
local _name = if (alive _character) then {name _character} else {"Dead Player"};
local _inDebug = (respawn_west_original distance _charPos) < 1500;
local _exitReason = call {
if (isNil "_characterID") exitwith {("ERROR: Cannot Sync Character " + _name + " has nil characterID")}; //Unit is null
if (_inDebug) exitwith {format["INFO: Cannot Sync Character %1 near respawn_west %2. This is normal when relogging or changing clothes.",_name,_charPos]};
if (_characterID == "0") exitwith {("ERROR: Cannot Sync Character " + _name + " has no characterID")};
if (_character isKindOf "Animal") exitwith {("ERROR: Cannot Sync Character " + _name + " is an Animal class")};
"none";
};
if (_exitReason != "none") exitWith {
diag_log _exitReason;
};
//Check for player initiated updates
local _playerPos = [];
local _playerGear = [];
local _playerBackp = [];
local _medical = [];
local _distanceFoot = 0;
//all getVariable immediately
local _globalCoins = _character getVariable ["globalMoney", -1];
local _bankCoins = _character getVariable ["bankMoney", -1];
local _coins = _character getVariable ["cashMoney", -1]; //should getting coins fail set the variable to an invalid value to prevent overwritting the in the DB
local _lastPos = _character getVariable ["lastPos",_charPos];
local _usec_Dead = _character getVariable ["USEC_isDead",false];
local _lastTime = _character getVariable ["lastTime",-1];
local _modelChk = _character getVariable ["model_CHK",""];
local _temp = round (_character getVariable ["temperature",100]);
local _lastMagazines = _character getVariable ["ServerMagArray",[[],"",[]]];
//Get difference between current stats and stats at last sync
local _statsDiff = [_character,_playerUID] call server_getStatsDiff;
_humanity = _statsDiff select 0;
local _kills = _statsDiff select 1;
local _headShots = _statsDiff select 2;
local _killsH = _statsDiff select 3;
local _killsB = _statsDiff select 4;
local _charPosLen = count _charPos;
local _magTemp = [];
if (!isNil "_magazines") then {
_playerGear = [_weaponsPlayer,_magazines,_dayz_onBack];
_character setVariable["ServerMagArray",[_magazines,_dayz_onBack,_weaponsPlayer], false];
} else {
//check Magazines everytime they aren't sent by player_forceSave
_magTemp = (_lastMagazines select 0);
if (isNil "_dayz_onBack") then {
_dayz_onBack = _lastMagazines select 1;
};
if (isNil "_weaponsPlayer") then {
_weaponsPlayer = _lastMagazines select 2;
};
if (count _magTemp > 0) then {
_magazines = [(magazines _character),20] call array_reduceSize;
{
local _class = _x;
if (typeName _x == "ARRAY") then {
_class = _x select 0;
};
if (_class in _magazines) then {
local _MatchedCount = {_compare = if (typeName _x == "ARRAY") then {_x select 0;} else {_x}; _compare == _class} count _magTemp;
local _CountedActual = {_x == _class} count _magazines;
if (_MatchedCount > _CountedActual) then {
_magTemp set [_forEachIndex, "0"];
};
} else {
_magTemp set [_forEachIndex, "0"];
};
} forEach (_lastMagazines select 0);
_magazines = _magTemp - ["0"];
_magazines = [_magazines,_dayz_onBack,_weaponsPlayer];
_character setVariable["ServerMagArray",_magazines, false];
_playerGear = [_magazines select 2,_magazines select 0,_magazines select 1];
} else {
_magazines = [_magTemp,_dayz_onBack,_weaponsPlayer];
};
_character setVariable["ServerMagArray",_magazines, false];
_playerGear = [_magazines select 2,_magazines select 0,_magazines select 1];
};
//Check if update is requested
if !((_charPos select 0 == 0) && (_charPos select 1 == 0)) then {
//Position is not zero
_playerPos = [round (direction _character),_charPos];
if (count _lastPos > 2 && {_charPosLen > 2}) then {
if (!_isInVehicle) then {_distanceFoot = round (_charPos distance _lastPos);};
_character setVariable["lastPos",_charPos];
};
if (_charPosLen < 3) then {_playerPos = [];};
};
//Check player backpack each time sync runs
local _backpack = unitBackpack _character;
_playerBackp = [typeOf _backpack,getWeaponCargo _backpack,getMagazineCargo _backpack];
if (!_usec_Dead) then {
_medical = _character call player_sumMedical;
};
_character addScore _kills;
/*
Assess how much time has passed, for recording total time on server
Note "lastTime" is -1 after clothes change
*/
local _timeLeft = 0;
if (_lastTime == -1) then {
_character setVariable ["lastTime",diag_tickTime,false];
} else {
local _timeGross = (diag_tickTime - _lastTime);
_timeSince = floor (_timeGross / 60);
_timeLeft = (_timeGross - (_timeSince * 60));
};
/*
Get character state details
*/
local _currentWpn = currentMuzzle _character;
local _currentAnim = animationState _character;
local _config = configFile >> "CfgMovesMaleSdr" >> "States" >> _currentAnim;
local _onLadder = (getNumber (_config >> "onLadder")) == 1;
local _isTerminal = (getNumber (_config >> "terminal")) == 1;
//_wpnDisabled = (getNumber (_config >> "disableWeapons")) == 1;
local _currentModel = typeOf _character;
if (_currentModel == _modelChk) then {
_currentModel = "";
} else {
_currentModel = str _currentModel;
_character setVariable ["model_CHK",typeOf _character];
};
// If player is in a vehicle, keep its position updated
if (vehicle _character != _character) then {
[vehicle _character, "position"] call server_updateObject;
};
if (count _this > 4) then { //calling from player_onDisconnect
if (_this select 4) then { //combat logged
_medical set [1, true]; //set unconcious to true
_medical set [10, 150]; //combat timeout
//_character setVariable ["NORRN_unconscious",true,true]; // Set status to unconscious
//_character setVariable ["unconsciousTime",150,true]; // Set knock out timer to 2 minutes 30 seconds
//_character setVariable ["USEC_injured",true]; // Set status to bleeding
//_character setVariable ["USEC_BloodQty",3000]; // Set blood to 3000
};
if (_isInVehicle) then {
//if the player object is inside a vehicle lets eject the player
local _relocate = ((vehicle _character isKindOf "Air") && (_charPos select 2 > 1.5));
_character action ["eject", vehicle _character];
// Prevent relog in parachute, heli or plane above base exploit to get inside
if (_relocate) then {
local _count = 0;
local _maxDist = 800;
local _newPos = [_charPos, 80, _maxDist, 10, 1, 0, 0, [], [_charPos,_charPos]] call BIS_fnc_findSafePos;
while {_newPos distance _charPos == 0} do {
_count = _count + 1;
if (_count > 4) exitWith {_newPos = _charPos;}; // Max 4km away fail safe (needs to finish fast so server_playerSync runs below)
_newPos = [_charPos, 80, (_maxDist + 800), 10, 1, 0, 0, [], [_charPos,_charPos]] call BIS_fnc_findSafePos;
};
_newPos set [2,0]; //findSafePos only returns two elements
_charPos = _newPos;
diag_log format["%1(%2) logged out in air vehicle. Relocated to safePos %3 - %4.",_name,_playerUID,mapGridPosition _charPos,_charPos];
};
};
};
if (_onLadder or _isInVehicle or _isTerminal) then {
_currentAnim = "";
//If position to be updated, make sure it is at ground level!
if ((count _playerPos > 0) && !_isTerminal) then {
_charPos set [2,0];
_playerPos set [1,_charPos];
};
};
if (_isInVehicle) then {
_currentWpn = "";
} else {
if (typeName _currentWpn == "STRING") then {
local _muzzles = getArray (configFile >> "cfgWeapons" >> _currentWpn >> "muzzles");
if (count _muzzles > 1) then {_currentWpn = currentMuzzle _character;};
} else {
//diag_log ("DW_DEBUG: _currentWpn: " + str(_currentWpn));
_currentWpn = "";
};
};
local _currentState = [[_currentWpn,_currentAnim,_temp],[]];
//Reset timer
if (_timeSince > 0) then {
_character setVariable ["lastTime",(diag_ticktime - _timeLeft)];
};
/*
Everything is ready, now publish to HIVE
Low priority code below this point where _character object is no longer needed and may be Null.
*/
if (count _playerPos > 0) then {
local _array = [];
{
if (_x > dayz_minpos && _x < dayz_maxpos) then {_array set [count _array,_x];};
} forEach (_playerPos select 1);
_playerPos set [1,_array];
};
//Wait for HIVE to be free and send request
local _key = if (Z_SingleCurrency) then {
str formatText["CHILD:201:%1:%2:%3:%4:%5:%6:%7:%8:%9:%10:%11:%12:%13:%14:%15:%16:%17:",_characterID,_playerPos,_playerGear,_playerBackp,_medical,false,false,_kills,_headShots,_distanceFoot,_timeSince,_currentState,_killsH,_killsB,_currentModel,_humanity,_coins]
} else {
str formatText["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,_kills,_headShots,_distanceFoot,_timeSince,_currentState,_killsH,_killsB,_currentModel,_humanity]
};
#ifdef PLAYER_DEBUG
diag_log str formatText["INFO - %2(UID:%4,CID:%3) PlayerSync, %1",_key,_name,_characterID,_playerUID];
#endif
_key call server_hiveWrite;
if (Z_SingleCurrency) then { //update global coins
_key = str formatText["CHILD:205:%1:%2:%3:%4:",_playerUID,dayZ_instance,_globalCoins,_bankCoins];
_key call server_hiveWrite;
};
// Force gear updates for nearby vehicles/tents
{[_x,"gear"] call server_updateObject;} count nearestObjects [[_character] call FNC_GetPos,DayZ_GearedObjects,10];

View File

@ -0,0 +1,52 @@
#include "\z\addons\dayz_server\compile\server_toggle_debug.hpp"
private ["_type","_objectUID","_characterID","_object","_worldspace","_key","_ownerArray","_inventory","_clientKey","_exitReason","_player","_playerUID"];
if (count _this < 6) exitWith {diag_log "Server_PublishObj error: Wrong parameter format";};
_characterID = _this select 0;
_object = _this select 1;
_worldspace = _this select 2;
_inventory = _this select 3;
_player = _this select 4;
_clientKey = _this select 5;
_type = typeOf _object;
_playerUID = getPlayerUID _player;
_exitReason = [_this,"PublishObj",(_worldspace select 1),_clientKey,_playerUID,_player] call server_verifySender;
if (_exitReason != "") exitWith {diag_log _exitReason};
if ([_object, "Server"] call check_publishobject) then {
//diag_log ("PUBLISH: Attempt " + str(_object));
_objectUID = _worldspace call dayz_objectUID2;
_object setVariable [ "ObjectUID", _objectUID, true ];
// we can't use getVariable because only the object creation is known from the server (position,direction,variables are not sync'ed yet)
//_characterID = _object getVariable [ "characterID", 0 ];
//_ownerArray = _object getVariable [ "ownerArray", [] ];
//_key = str formatText["CHILD:308:%1:%2:%3:%4:%5:%6:%7:%8:%9:", dayZ_instance, _type, 0, _characterID, _worldspace, _inventory, [], 0,_objectUID];
_key = str formatText["CHILD:308:%1:%2:%3:%4:%5:%6:%7:%8:%9:",dayZ_instance, _type, 0, _characterID, _worldspace call AN_fnc_formatWorldspace, _inventory, [], 0,_objectUID]; // Precise Base Building 1.0.5
_key call server_hiveWrite;
if !(_object isKindOf "TrapItems") then {
if (DZE_GodModeBase && {!(_type in DZE_GodModeBaseExclude)}) then {
_object addEventHandler ["HandleDamage", {false}];
} else {
_object addMPEventHandler ["MPKilled",{_this call vehicle_handleServerKilled;}];
};
};
// Test disabling simulation server side on buildables only.
_object enableSimulation false;
dayz_serverObjectMonitor set [count dayz_serverObjectMonitor,_object];
#ifdef OBJECT_DEBUG
diag_log format["PUBLISH: Player %1(%2) created %3 with UID:%4 CID:%5 @%6 inventory:%7",(_player call fa_plr2str),_playerUID,_type,_objectUID,_characterID,((_worldspace select 1) call fa_coor2str),_inventory];
#endif
}
else {
#ifdef OBJECT_DEBUG
diag_log ("PUBLISH: *NOT* created " + (_type ) + " (not allowed)");
#endif
};

View File

@ -0,0 +1,92 @@
private ["_object","_worldspace","_location","_dir","_class","_uid","_dam","_hitpoints","_selection","_array","_damage","_fuel","_key","_totaldam","_spawnDMG","_characterID","_result","_outcome","_oid"];
//[_veh,[_dir,_location],"V3S_Civ",true]
#include "\z\addons\dayz_server\compile\server_toggle_debug.hpp"
_object = _this select 0;
_worldspace = _this select 1;
_class = _this select 2;
_spawnDMG = _this select 3;
_characterID = _this select 4;
_fuel = 1;
_damage = 0;
_array = [];
#ifdef OBJECT_DEBUG
diag_log ("PUBLISH: Attempt " + str(_object));
#endif
_dir = _worldspace select 0;
_location = _worldspace select 1;
_uid = _worldspace call dayz_objectUID2;
if (_spawnDMG) then {
_fuel = 0;
if (getNumber(configFile >> "CfgVehicles" >> _class >> "isBicycle") != 1) then {
_totaldam = 0;
_hitpoints = _object call vehicle_getHitpoints;
{
_dam = call generate_new_damage;
_selection = getText(configFile >> "cfgVehicles" >> _class >> "HitPoints" >> _x >> "name");
if (_dam > 0) then {
_array set [count _array,[_selection,_dam]];
_totaldam = _totaldam + _dam;
};
} count _hitpoints;
_damage = 0;
_fuel = (random(DynamicVehicleFuelHigh-DynamicVehicleFuelLow)+DynamicVehicleFuelLow) / 100;
};
};
_key = str formatText["CHILD:308:%1:%2:%3:%4:%5:%6:%7:%8:%9:",dayZ_instance,_class,_damage,_characterID,_worldspace,[],_array,_fuel,_uid];
#ifdef OBJECT_DEBUG
diag_log ("HIVE: WRITE: "+ str(_key));
#endif
_key call server_hiveWrite;
dayz_serverObjectMonitor set [count dayz_serverObjectMonitor,_object];
// GET DB ID
_key = format["CHILD:388:%1:",_uid];
#ifdef OBJECT_DEBUG
diag_log ("HIVE: WRITE: "+ str(_key));
#endif
_result = _key call server_hiveReadWrite;
_outcome = _result select 0;
if (_outcome != "PASS") then {
deleteVehicle _object;
diag_log("CUSTOM: failed to get id for : " + str(_uid));
} else {
_oid = _result select 1;
_object setVariable ["ObjectID", _oid, true];
#ifdef OBJECT_DEBUG
diag_log("CUSTOM: Selected " + str(_oid));
#endif
_object setVariable ["lastUpdate",diag_tickTime];
_object setVariable ["CharacterID", _characterID, true];
_object setDamage _damage;
{
_selection = _x select 0;
_dam = _x select 1;
if (_selection in dayZ_explosiveParts && _dam > 0.8) then {_dam = 0.8};
[_object,_selection,_dam] call fnc_veh_setFixServer;
} count _array;
_object setFuel _fuel;
_object setvelocity [0,0,1];
_object call fnc_veh_ResetEH;
PVDZE_veh_Init = _object;
publicVariable "PVDZE_veh_Init";
diag_log ("PUBLISH: Created " + (_class) + " with ID " + str(_uid));
};

View File

@ -0,0 +1,105 @@
private ["_activatingPlayer","_isOK","_worldspace","_location","_dir","_class","_uid","_key","_keySelected","_characterID","_donotusekey","_object","_result","_outcome","_oid","_object_para","_clientKey","_exitReason","_playerUID"];
#include "\z\addons\dayz_server\compile\server_toggle_debug.hpp"
if (count _this < 6) exitWith {diag_log "Server_PublishVehicle2 error: Wrong parameter format";};
_worldspace = _this select 0;
_class = _this select 1;
_donotusekey = _this select 2;
_keySelected = _this select 3;
_activatingPlayer = _this select 4;
_clientKey = _this select 5;
_playerUID = getPlayerUID _activatingPlayer;
_exitReason = [_this,"PublishVehicle2",(_worldspace select 1),_clientKey,_playerUID,_activatingPlayer] call server_verifySender;
if (_exitReason != "") exitWith {diag_log _exitReason};
if(_donotusekey) then {
_isOK = true;
} else {
_isOK = isClass(configFile >> "CfgWeapons" >> _keySelected);
};
if(!_isOK) exitWith {diag_log ("HIVE: CARKEY DOES NOT EXIST: "+ str(_keySelected));};
if(_donotusekey) then {
_characterID = _keySelected;
} else {
_characterID = str(getNumber(configFile >> "CfgWeapons" >> _keySelected >> "keyid"));
};
_dir = _worldspace select 0;
_location = _worldspace select 1;
_uid = _worldspace call dayz_objectUID2;
_key = format["CHILD:308:%1:%2:%3:%4:%5:%6:%7:%8:%9:",dayZ_instance, _class, 0 , _characterID, _worldspace, [], [], 1,_uid];
#ifdef OBJECT_DEBUG
diag_log ("HIVE: WRITE: "+ str(_key));
#endif
_key call server_hiveWrite;
_key = format["CHILD:388:%1:",_uid];
#ifdef OBJECT_DEBUG
diag_log ("HIVE: WRITE: "+ str(_key));
#endif
_result = _key call server_hiveReadWrite;
_outcome = _result select 0;
if (_outcome != "PASS") then {
diag_log("CUSTOM: failed to get id for : " + str(_uid));
} else {
_oid = _result select 1;
#ifdef OBJECT_DEBUG
diag_log("CUSTOM: Selected " + str(_oid));
#endif
if(DZE_TRADER_SPAWNMODE) then {
_object_para = "ParachuteMediumWest" createVehicle [0,0,0];
_object_para setPos [_location select 0, _location select 1,(_location select 2) + 65];
_object = _class createVehicle [0,0,0];
} else {
// Don't use setPos or CAN_COLLIDE here. It will spawn inside other vehicles
_object = _class createVehicle _location;
if (surfaceIsWater _location && {({_x != _object} count (_location nearEntities ["Ship",8])) == 0}) then {
//createVehicle "NONE" is especially inaccurate in water
_object setPos _location;
};
};
if(!_donotusekey) then {
_object setvehiclelock "locked";
//_object setVariable ["MF_Tow_Cannot_Tow",true,true];
};
clearWeaponCargoGlobal _object;
clearMagazineCargoGlobal _object;
dayz_serverObjectMonitor set [count dayz_serverObjectMonitor,_object];
_object setVariable ["ObjectID", _oid, true];
_object setVariable ["lastUpdate",diag_tickTime];
_object setVariable ["CharacterID", _characterID, true];
if(DZE_TRADER_SPAWNMODE) then {
_object attachTo [_object_para, [0,0,-1.6]];
[_object,_object_para] spawn {
_object = _this select 0;
_object_para = _this select 1;
uiSleep 1;
waitUntil {([_object] call fnc_getPos) select 2 < 0.1};
detach _object;
deleteVehicle _object_para;
};
};
_object call fnc_veh_ResetEH;
_object setVariable ["Owner", [_playerUID], true];
PVDZE_veh_Init = _object;
publicVariable "PVDZE_veh_Init";
diag_log format["PUBLISH: %1(%2) bought %3 with UID %4 @%5",(_activatingPlayer call fa_plr2str),_playerUID,_class,_uid,(_location call fa_coor2str)];
};

View File

@ -0,0 +1,205 @@
private ["_coins","_activatingPlayer","_object","_worldspace","_location","_dir","_class","_uid","_key","_keySelected"
,"_characterID","_result","_outcome","_oid","_objectID","_objectUID","_newobject","_weapons","_magazines","_backpacks"
,"_clientKey","_exitReason","_playerUID","_isAir","_fuel","_selection","_dam","_hitpoints","_newHitpoints","_damage"
,"_hit","_inv","_action","_clearTurrets","_message"];
#include "\z\addons\dayz_server\compile\server_toggle_debug.hpp"
if (count _this < 6) exitWith {
diag_log "Server_PublishVehicle3 error: Wrong parameter format";
dze_waiting = "fail";
(owner (_this select 4)) publicVariableClient "dze_waiting";
};
_object = _this select 0;
_worldspace = _this select 1;
_class = _this select 2;
_keySelected = _this select 3;
_activatingPlayer = _this select 4;
_clientKey = _this select 5;
_action = if (count _this > 6) then {_this select 6} else {""};
_playerUID = getPlayerUID _activatingPlayer;
_characterID = _keySelected;
_exitReason = [_this,"PublishVehicle3",(_worldspace select 1),_clientKey,_playerUID,_activatingPlayer] call server_verifySender;
if (_exitReason != "") exitWith {
diag_log _exitReason;
dze_waiting = "fail";
(owner _activatingPlayer) publicVariableClient "dze_waiting";
};
if (!(isClass(configFile >> "CfgVehicles" >> _class)) || isNull _object) exitWith {
diag_log ("HIVE-PublishVehicle3 Error: Vehicle does not exist: "+ str(_class));
dze_waiting = "fail";
(owner _activatingPlayer) publicVariableClient "dze_waiting";
};
_objectID = _object getVariable ["ObjectID","0"];
_objectUID = _object getVariable ["ObjectUID","0"];
_location = [_object] call fnc_getPos;
_fuel = fuel _object;
_hitpoints = _object call vehicle_getHitpoints;
_newHitpoints = [];
_damage = damage _object;
// add items from previous vehicle here
_weapons = getWeaponCargo _object;
_magazines = getMagazineCargo _object;
_backpacks = getBackpackCargo _object;
_inv = [_weapons,_magazines,_backpacks];
if (Z_SingleCurrency && ZSC_VehicleMoneyStorage) then {
_coins = _object getVariable ["cashMoney",0];
};
{
_hit = [_object,_x] call object_getHit;
if ((_hit select 0) > 0) then {
_newHitpoints set [count _newHitpoints,[(_hit select 1),(_hit select 0)]];
} else {
_newHitpoints set [count _newHitpoints,[(_hit select 1),0]];
};
} count _hitpoints;
#ifdef OBJECT_DEBUG
diag_log ("PUBLISH: Attempt " + str(_object));
#endif
_dir = _worldspace select 0;
_uid = _worldspace call dayz_objectUID2;
_key = format["CHILD:308:%1:%2:%3:%4:%5:%6:%7:%8:%9:",dayZ_instance, _class, _damage , _characterID, _worldspace, _inv, _newHitpoints, _fuel,_uid];
#ifdef OBJECT_DEBUG
diag_log ("HIVE: WRITE: "+ str(_key));
#endif
_key call server_hiveWrite;
// GET DB ID
_key = format["CHILD:388:%1:",_uid];
#ifdef OBJECT_DEBUG
diag_log ("HIVE: WRITE: "+ str(_key));
#endif
_result = _key call server_hiveReadWrite;
_outcome = _result select 0;
if (_outcome != "PASS") then {
diag_log("HIVE-pv3: failed to get id for : " + str(_uid));
_key = format["CHILD:310:%1:",_uid];
_key call server_hiveWrite;
dze_waiting = "fail";
(owner _activatingPlayer) publicVariableClient "dze_waiting";
} else {
_oid = _result select 1;
#ifdef OBJECT_DEBUG
diag_log("CUSTOM: Selected " + str(_oid));
#endif
_colour = _object getVariable ["Colour","0"];
_colour2 = _object getVariable ["Colour2","0"];
deleteVehicle _object;
[_objectID,_objectUID,_object] call server_deleteObjDirect;
uiSleep 3;
_newobject = _class createVehicle [0,0,0];
// switch var to new vehicle at this point.
_object = _newobject;
_object setVariable ["ObjectID", _oid, true];
_object setVariable ["lastUpdate",diag_tickTime];
_object setVariable ["CharacterID", _characterID, true];
if (Z_SingleCurrency && ZSC_VehicleMoneyStorage && {_coins > 0}) then {
_object setVariable ["cashMoney",_coins,true];
};
dayz_serverObjectMonitor set [count dayz_serverObjectMonitor,_object];
clearWeaponCargoGlobal _object;
clearMagazineCargoGlobal _object;
clearBackpackCargoGlobal _object;
_object setDir _dir;
_object setPosATL _location;
_object setVectorUp surfaceNormal _location;
_object setDamage _damage;
if (_colour != "0") then {
_object setVariable ["Colour",_colour,true];
_clrinit = format ["#(argb,8,8,3)color(%1)",_colour];
_object setVehicleInit "this setObjectTexture [0,"+str _clrinit+"];";
};
if (_colour2 != "0") then {
_object setVariable ["Colour2",_colour2,true];
_clrinit2 = format ["#(argb,8,8,3)color(%1)",_colour2];
_object setVehicleInit "this setObjectTexture [1,"+str _clrinit2+"];";
};
processInitCommands;
[_weapons,_magazines,_backpacks,_object] call fn_addCargo;
_clearTurrets = {
//By denvdmj (probably, I found it on the biki)
private ["_weaponArray","_findRecurse","_class","_obj","_turret","_mags"];
_obj = _this;
_weaponArray = [];
_weaponArray set [count _weaponArray,[-1]];
_findRecurse = {
private ["_root", "_class", "_path", "_currentPath", "_thisThis"];
_root = (_this select 0);
_path = +(_this select 1);
_thisThis = _this select 2;
for "_i" from 0 to count _root -1 do {
_class = _root select _i;
if (isClass _class) then {
_currentPath = _path + [_i];
{_weaponArray set [count _weaponArray, _currentPath];} count getArray (_class >> "weapons");
_class = _class >> "turrets";
if (isClass _class) then {[_class, _currentPath, _thisThis] call _findRecurse;};
};
};
};
[configFile >> "CfgVehicles" >> typeOf (_obj) >> "turrets", [], _this] call _findRecurse;
{
_turret = _x;
_mags = _obj magazinesTurret _turret;
{_obj removeMagazinesTurret[_x,_turret];} count _mags;
} forEach _weaponArray;
};
_isAir = _object isKindOf "Air";
{
_selection = _x select 0;
_dam = [_x select 1,(_x select 1) min 0.8] select (!_isAir && {_selection in dayZ_explosiveParts});
_object setHit [_selection,_dam];
} count _newHitpoints;
_object setFuel _fuel;
[_object,"all",true] call server_updateObject;
_object call fnc_veh_ResetEH;
// for non JIP users this should make sure everyone has eventhandlers for vehicles.
PVDZE_veh_Init = _object;
publicVariable "PVDZE_veh_Init";
{if (_object isKindOf _x) exitWith {_object disableTIEquipment true;}} count vkc_disableThermal;
if (vkc_clearAmmo) then {_object call _clearTurrets;};
dze_waiting = "success";
(owner _activatingPlayer) publicVariableClient "dze_waiting";
if (_action == "") then {
_message = format["PUBLISH: %1(%2) upgraded %3 with UID %4 @%5",(_activatingPlayer call fa_plr2str),_playerUID,_class,_uid,(_location call fa_coor2str)];
} else {
_message = format["PUBLISH: %1(%2) %6 %3 with UID %4 @%5",(_activatingPlayer call fa_plr2str),_playerUID,_class,_uid,(_location call fa_coor2str),_action];
};
diag_log _message;
};

View File

@ -0,0 +1,24 @@
private "_trader";
{
_trader = createAgent [_x select 0,_x select 1,[],0,"CAN_COLLIDE"];
{_trader removeMagazine _x;} count magazines _trader;
removeAllItems _trader;
removeAllWeapons _trader;
removeBackpack _trader;
_trader switchMove "";
_trader setDir (_x select 2);
_trader setVehicleInit "this disableAI 'ANIM'; this disableAI 'AUTOTARGET'; this disableAI 'FSM'; this disableAI 'MOVE'; this disableAI 'TARGET'; this setBehaviour 'CARELESS'; this forceSpeed 0; this allowDamage false;";
_trader setUnitAbility 0.6;
_trader disableAI "ANIM";
_trader disableAI "AUTOTARGET";
_trader disableAI "FSM";
_trader disableAI "MOVE";
_trader disableAI "TARGET";
_trader setBehaviour "CARELESS";
_trader setcaptive true;
_trader forceSpeed 0;
_trader allowDamage false;
_trader enableSimulation false;
} count _this;
processInitCommands;

View File

@ -0,0 +1,117 @@
private ["_gearClasses","_coins","_class","_uid","_charID","_object","_worldspace","_key","_allowed","_obj","_inv","_objectID","_objectUID","_proceed","_activatingplayer","_clientKey","_exitReason","_playerUID","_weapons","_magazines","_backpacks"];
if (count _this < 8) exitWith {diag_log format ["Server_SwapObject error: Wrong parameter format from player %1",_this select 5];};
_charID = _this select 0;
_object = _this select 1;
_worldspace = _this select 2;
_class = _this select 3;
_obj = _this select 4;
_activatingplayer = _this select 5;
_inv = _this select 6;
_clientKey = _this select 7;
_proceed = false;
_objectID = "0";
_objectUID = "0";
_playerUID = getPlayerUID _activatingPlayer;
_exitReason = [_this,"SwapObject",(_worldspace select 1),_clientKey,_playerUID,_activatingPlayer] call server_verifySender;
if (_exitReason != "") exitWith {diag_log _exitReason};
if (!isNull(_obj)) then {
// Find objectID
_objectID = _obj getVariable ["ObjectID","0"];
// Find objectUID
_objectUID = _obj getVariable ["ObjectUID","0"];
if !(DZE_GodModeBase) then {
_obj removeAllMPEventHandlers "MPKilled";
};
if ((_class isKindOf "Land_A_tent" || {_class in DZE_isNewStorage}) && !(_class in DZE_isLockedStorageUpgrade)) then {
_weapons = getWeaponCargo _obj;
_magazines = getMagazineCargo _obj;
_backpacks = getBackpackCargo _obj;
_inv = [_weapons,_magazines,_backpacks];
};
if (_class in DZE_isLockedStorageUpgrade) then {
_weapons = _obj getVariable ["WeaponCargo",[]];
_magazines = _obj getVariable ["MagazineCargo",[]];
_backpacks = _obj getVariable ["BackpackCargo",[]];
_inv = [_weapons,_magazines,_backpacks];
};
if (Z_SingleCurrency && {_class in DZE_MoneyStorageClasses}) then {
_coins = _obj getVariable ["cashMoney",0];
};
// Remove old object
deleteVehicle _obj;
_proceed = true;
};
if (isNull(_object)) then {
_proceed = false;
};
if (_objectID == "0" && {_objectUID == "0"}) then {
_proceed = false;
} else {
[_objectID,_objectUID,_obj] call server_deleteObjDirect;
};
_allowed = [_object, "Server"] call check_publishobject;
if (!_allowed || !_proceed) exitWith {
if(!isNull(_object)) then {
deleteVehicle _object;
};
diag_log ("Invalid object swap by playerUID:" + _playerUID);
};
// Publish variables
_object setVariable ["CharacterID",_charID,true];
//_object setVariable ["ObjectUID",_objectUID,true];
_object setVariable ["OEMPos",(_worldspace select 1),true];
//diag_log ("PUBLISH: Attempt " + str(_object));
//get UID
_uid = _worldspace call dayz_objectUID2;
//Send request
_key = str formatText["CHILD:308:%1:%2:%3:%4:%5:%6:%7:%8:%9:",dayZ_instance, _class, 0, _charID, _worldspace call AN_fnc_formatWorldspace, _inv, [], 0,_uid];
//diag_log ("HIVE: WRITE: "+ str(_key));
_key call server_hiveWrite;
_object setVariable ["lastUpdate",diag_tickTime];
_object setVariable ["ObjectUID", _uid,true];
// _object setVariable ["CharacterID",_charID,true];
if (DZE_GodModeBase && {!(_class in DZE_GodModeBaseExclude)}) then {
_object addEventHandler ["HandleDamage",{false}];
} else {
_object addMPEventHandler ["MPKilled",{_this call vehicle_handleServerKilled;}];
};
_gearClasses = ["Wooden_shed2_DZ","WoodShack2_DZ","StorageShed2_DZ","GunRack2_DZ","WoodCrate2_DZ","TentStorage0","TentStorage1","TentStorage2","TentStorage3","TentStorage4""DomeTentStorage0","DomeTentStorage1","DomeTentStorage2","DomeTentStorage3","DomeTentStorage4","DesertTentStorage0","DesertTentStorage1","DesertTentStorage2","DesertTentStorage3","DesertTentStorage4","StashSmall1","StashSmall2","StashSmall3","StashSmall4","StashMedium","StashMedium1","StashMedium2","StashMedium3","StashMedium4","TentStorageWinter0","TentStorageWinter1","TentStorageWinter2","TentStorageWinter3","TentStorageWinter4","WinterDomeTentStorage0","WinterDomeTentStorage1","WinterDomeTentStorage2","WinterDomeTentStorage3","WinterDomeTentStorage4"];
if (count _inv > 0 && {_class in _gearClasses}) then {
[_weapons,_magazines,_backpacks,_object] call fn_addCargo;
};
if (_class in DZE_isLockedStorageUpgrade) then {
_object setVariable ["WeaponCargo",_weapons,false];
_object setVariable ["MagazineCargo",_magazines,false];
_object setVariable ["BackpackCargo",_backpacks,false];
};
// Test disabling simulation server side on buildables only.
_object enableSimulation false;
dayz_serverObjectMonitor set [count dayz_serverObjectMonitor,_object];
if (Z_SingleCurrency && {_class in DZE_MoneyStorageClasses && {_coins > 0}}) then { //Do not use server_updateObject, safes and lockboxes need a different handling
_object setVariable ["cashMoney",_coins,true];
_key = format["CHILD:309:%1:",_uid] + str _inv + ":" + str _coins + ":";
_key call server_hiveWrite;
};
diag_log format["PUBLISH: Player %1(%2) upgraded or downgraded object to %3 with UID:%4 @%5",(_activatingPlayer call fa_plr2str),_playerUID,_class,_uid,((_worldspace select 1) call fa_coor2str)];

View File

@ -0,0 +1,19 @@
/*
Created exclusively for ArmA2:OA - DayZMod.
Please request permission to use/alter/distribute from project leader (R4Z0R49)
*/
//// TOGGLE DEBUGS ////
// comment this out if you don't want any LOGIN related debug
#define LOGIN_DEBUG
// comment this out if you don't want any VEHICLE/TENT/OBJECT related debug
//#define OBJECT_DEBUG
// comment this out if you don't want any PLAYER (WORLDSPACE/INVENTORY/ETC) related debug
//#define PLAYER_DEBUG
// comment this out if you don't want any misc SERVER (ZOMBIE, LOOT, CLEANUP) related debug
//#define SERVER_DEBUG

View File

@ -0,0 +1,40 @@
local _player = _this select 0;
local _traderID = _this select 1;
local _buyorsell = _this select 2; //0 > Buy // 1 > Sell
local _classname = _this select 3;
local _traderCity = _this select 4;
local _currency = _this select 5;
local _price = _this select 6;
local _message = "";
local _playerUID = getPlayerUID _player;
local _name = if (alive _player) then {name _player} else {"Dead Player"};
local _quantity = 1;
local _container = "gear";
if (count _this > 7) then {
_quantity = _this select 7;
_container = _this select 8;
};
local _checkItems = true; // Activate this to log all items within the '_watchClasses'. Specify the quantity with '_watchNumber' when the sold items will be logged.
if (_checkItems) then {
local _watchClasses = ["ItemBriefcase40oz","ItemBriefcase50oz","ItemBriefcase60oz","ItemBriefcase70oz","ItemBriefcase80oz","ItemBriefcase90oz","ItemBriefcase100oz","ItemTopaz","ItemObsidian","ItemSapphire","ItemAmethyst","ItemEmerald","ItemCitrine","ItemRuby"]; // Items to be logged
local _watchNumber = 4; // Minimum number of quantity before logging occurs
if (_quantity >= _watchNumber && {_className in _watchClasses} && {_buyOrSell == 1}) then {
_message = format ["%1 (%2) could be duping! Selling %3x %4",_name,_playerUID,_quantity,_className];
diag_log _message;
};
};
if (typeName _currency == "STRING") then {_price = format ["%1 %2",_price,_currency];};
if (_buyorsell == 0) then { // Buy
_message = format["Trader Menu: %1 (%2) purchased %3x %4 into %5 at %6 for %7",_name,_playerUID,_quantity,_classname,_container,_traderCity,_price];
} else { // Sell
_message = format["Trader Menu: %1 (%2) sold %3x %4 from %5 at %6 for %7",_name,_playerUID,_quantity,_classname,_container,_traderCity,_price];
};
diag_log _message;

View File

@ -0,0 +1,76 @@
// [_object,_type] spawn server_updateObject;
#include "\z\addons\dayz_server\compile\server_toggle_debug.hpp"
//if (isNil "sm_done") exitWith {diag_log "sm_done is nil";};
local _object = _this select 0;
if ((isNil "_object") || isNull _object) exitWith {diag_log "server_updateObject.sqf _object null or nil, could not update object"};
local _type = _this select 1;
local _forced = if (count _this > 2) then {_this select 2} else {false};
local _totalDmg = if (count _this > 3) then {_this select 3} else {false};
local _isNotOk = false;
local _objectID = "0";
local _objectUID = "0";
_objectID = _object getVariable ["ObjectID","0"];
_objectUID = _object getVariable ["ObjectUID","0"];
local _class = typeOf _object;
if (typeName _objectID != "STRING" || {typeName _objectUID != "STRING"}) then {
#ifdef OBJECT_DEBUG
diag_log (format["Non-string Object: ID %1 UID %2", _objectID, _objectUID]);
#endif
//force fail
_objectID = nil;
_objectUID = nil;
};
if (!(_class in DZE_safeVehicle) && {!locked _object}) then {
//diag_log format["Object: %1, ObjectID: %2, ObjectUID: %3",_object,_objectID,_objectUID];
if (!(_objectID in dayz_serverIDMonitor) && {isNil "_objectUID"}) then {
//force fail
_objectID = nil;
_objectUID = nil;
};
if (isNil "_objectID" && {isNil "_objectUID"}) then {
#ifdef OBJECT_DEBUG
diag_log format["Object %1 with invalid ID at pos %2",_class,getPosATL _object];
#endif
_isNotOk = true;
};
};
if (_isNotOk) exitWith {
//deleteVehicle _object;
};
call {
if (_type == "all") exitwith {
[_object,_objectID,_class] call server_obj_pos;
[_object,_objectID,_objectUID,_class] call server_obj_inv;
[_object,_objectID,_objectUID,_forced,_totalDmg] call server_obj_dam;
};
if (_type == "position") exitwith {
[_object,_objectID,_class] call server_obj_pos;
};
if (_type == "gear") exitwith {
[_object,_objectID,_objectUID,_class] call server_obj_inv;
};
if (_type == "damage" || _type == "repair") exitwith {
[_object,_objectID,_objectUID,_forced,_totalDmg] call server_obj_dam;
};
if (_type == "killed") exitwith {
if (count _this != 6) exitWith {
diag_log "Server_UpdateObject error: wrong parameter format";
};
local _playerUID = _this select 4;
local _clientKey = _this select 5;
[_object,_objectID,_objectUID,_playerUID,_clientKey,_class] call server_obj_killed;
};
if (_type == "coins") exitwith {
_object setVariable ["lastInventory",["forceUpdate"]];
[_object,_objectID,_objectUID,_class] call server_obj_inv;
};
"";
};

View File

@ -0,0 +1,35 @@
/*
PVEH does not provide any information about the sender in A2, so
this is necessary to verify the sender was not spoofed.
This is useful to hinder and identify cheaters who attempt mass deletion or creation of hive objects via PVS.
*/
private ["_clientKey","_exitReason","_function","_index","_objPos","_params","_player","_playerUID"];
_params = _this select 0;
_function = "Server_" + (_this select 1);
_objPos = _this select 2; //Can be object or position
_clientKey = _this select 3;
_playerUID = _this select 4;
_player = _this select 5;
_index = dayz_serverPUIDArray find _playerUID;
_exitReason = call {
//If object or player is null distance returns 9999+
//If object or player was moved with setPos on client, position takes a second to update on server
//Coordinates can be used in place of object
if (_objPos distance _player > (Z_VehicleDistance + 10)) exitwith {
format["%1 error: Verification failed, player is too far from object. Distance: %2m/%3m limit PV ARRAY: %4",_function,round (_objPos distance _player),Z_VehicleDistance + 10,_params]
};
if (_index < 0) exitwith {
format["%1 error: PUID NOT FOUND ON SERVER. PV ARRAY: %2",_function,_params]
};
if (((dayz_serverClientKeys select _index) select 0 != owner _player) or ((dayz_serverClientKeys select _index) select 1 != _clientKey)) exitwith {
format["%1 error: CLIENT AUTH KEY INCORRECT OR UNRECOGNIZED. PV ARRAY: %2",_function,_params]
};
"";
};
_exitReason

View File

@ -0,0 +1,24 @@
/*
Spawns several random "Supply_Crate_DZE" across map.
Lootable by destroying and then opening with crowbar.
Currently outputs vehicle ammo defined in Land_ammo_supply_wreck CfgVehicles class
*/
private ["_position","_veh","_istoomany"];
// do not make _roadList or _buildingList private in this function
_position = _roadList call BIS_fnc_selectRandom;
_position = _position modelToWorld [0,0,0];
_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 {};
//_veh = createVehicle ["Supply_Crate_DZE",_position, [], 0, "CAN_COLLIDE"];
_veh = "Supply_Crate_DZE" createVehicle [0,0,0];
_veh enableSimulation false;
_veh setDir round(random 360);
_veh setPos _position;
_veh setVariable ["ObjectID","1",true];
};

View File

@ -0,0 +1,26 @@
private ["_position","_veh","_istoomany","_spawnveh","_positions"];
_position = [getMarkerPos "center",0,(((getMarkerSize "center") select 1)*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;
_istoomany = _position nearObjects ["All",10];
if (((count _istoomany) > 0) or (isOnRoad _position)) exitWith {};
_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;
//diag_log("DEBUG: Spawning a crashed " + _spawnveh + " with " + _spawnloot + " at " + str(_position));
_veh = _spawnveh createVehicle [0,0,0];
_veh enableSimulation false;
_veh setDir round(random 360);
_veh setPos _position;
_veh setVariable ["ObjectID","1",true];
_veh addEventHandler ["HandleDamage",{
local _damage = _this select 2;
if ((_this select 4) == "Sledge_Swing_Ammo") then {
_damage = _damage*1.2;
};
_damage
} ];
};

View File

@ -0,0 +1,19 @@
private ["_position","_veh","_istoomany","_spawnveh"];
// do not make _roadList or _buildingList private in this function
_position = _roadList call BIS_fnc_selectRandom;
_position = _position modelToWorld [0,0,0];
_position = [_position,0,10,5,0,2000,0] call BIS_fnc_findSafePos;
if ((count _position) == 2) then {
_istoomany = _position nearObjects ["All",5];
if ((count _istoomany) > 0) exitWith {};
_spawnveh = DZE_isWreck call BIS_fnc_selectRandom;
//_veh = createVehicle [_spawnveh,_position, [], 0, "CAN_COLLIDE"];
_veh = _spawnveh createVehicle [0,0,0];
_veh enableSimulation false;
_veh setDir round(random 360);
_veh setPos _position;
_veh setVariable ["ObjectID","1",true];
};

View File

@ -0,0 +1,106 @@
private ["_random","_lastIndex","_index","_vehicle","_velimit","_qty","_isCessna","_isMV22","_isShip","_isHeli","_isC130","_isPlane","_position","_dir","_istoomany","_veh","_objPosition","_iClass","_num","_allCfgLoots"];
// do not make _roadList, _buildingList or _serverVehicleCounter private in this function
#include "\z\addons\dayz_code\loot\Loot.hpp"
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 (_qty <= _velimit) exitWith {}; // If under limit allow to proceed
// vehicle limit reached, remove vehicle from list
// since elements cannot be removed from an array, overwrite it with the last element and 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 random vehicle to spawn";
} else {
// add vehicle to counter for next pass
_serverVehicleCounter set [count _serverVehicleCounter,_vehicle];
// Find Vehicle Type to better control spawns
_isShip = _vehicle isKindOf "Ship"; // Any type of watercraft.
_isMV22 = _vehicle == "MV22_DZ"; // MV-22 is classified as a plane but it can take off vertically, so it is treated as a helicopter.
_isHeli = _vehicle isKindOf "Helicopter"; // All helicopters.
_isC130 = _vehicle == "C130J_US_EP1_DZ"; // C130s are too large to spawn in hangars.
_isCessna = _vehicle in ["GNT_C185C_DZ","GNT_C185R_DZ","GNT_C185_DZ","GNT_C185U_DZ"]; // Cessna models are unstable and should not spawn in hangars.
_isPlane = (_vehicle isKindOf "Plane" && {!_isCessna} && {!_isMV22} && {!_isC130}); // Cessna, MV-22, and C130 not allowed to spawn in hangars.
call {
// Spawn boats anywhere on coast on water
if (_isShip) exitWith {_position = [getMarkerPos "center",0,((getMarkerSize "center") select 1),10,1,2000,1] call BIS_fnc_findSafePos;};
// Spawn helicopters anywhere that is relatively flat
if (_isHeli || {_isMV22}) exitWith {_position = [getMarkerPos "center",0,((getMarkerSize "center") select 1),10,0,.15,0] call BIS_fnc_findSafePos;};
// Spawn AN2 and GyroCopter in hangar and runway positions
if (_isPlane) exitWith {
if (count DZE_AllAircraftPositions > 0) then { // Custom airfield positions available
_position = DZE_AllAircraftPositions call BIS_fnc_selectRandom; _dir = _position select 1; _position = _position select 0;
} else {
_position = [getMarkerPos "center",0,((getMarkerSize "center") select 1),10,0,.15,0] call BIS_fnc_findSafePos;
};
};
// Spawn C130 and Cessna on runway positions
if (_isCessna || {_isC130}) exitWith {
if (count DZE_Runway_Positions > 0) then { // Custom airfield positions available
_position = DZE_Runway_Positions call BIS_fnc_selectRandom; _dir = _position select 1; _position = _position select 0;
} else {
_position = [getMarkerPos "center",0,((getMarkerSize "center") select 1),10,0,.15,0] call BIS_fnc_findSafePos;
};
};
// Spawn land vehicles around buildings and 50% near roads
if ((random 1) > 0.5) then {
_position = _roadList call BIS_fnc_selectRandom;
_position = _position modelToWorld [0,0,0];
_position = [_position,0,10,10,0,2000,0] call BIS_fnc_findSafePos;
//diag_log("DEBUG: spawning near road " + str(_position));
} else {
_position = _buildingList call BIS_fnc_selectRandom;
_position = _position modelToWorld [0,0,0];
_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 and may spawn in air
if ((count _position) == 2) then {
_position set [2,0];
if (isNil "_dir") then {
_dir = round(random 180);
};
_istoomany = _position nearObjects ["AllVehicles",50];
if ((count _istoomany) > 0) exitWith {};
//_veh = createVehicle [_vehicle, _position, [], 0, "CAN_COLLIDE"];
//_veh setPos _position;
_veh = _vehicle createVehicle [0,0,0];
_veh setDir _dir;
_veh setPos _position;
_objPosition = getPosATL _veh;
clearWeaponCargoGlobal _veh;
clearMagazineCargoGlobal _veh;
// Add 0-3 loots to vehicle using random loot groups
_num = floor(random 4);
_allCfgLoots = ["Trash","Trash","Consumable","Consumable","Generic","Generic","MedicalLow","MedicalLow","clothes","tents","backpacks","Parts","pistols","AmmoCivilian"];
for "_x" from 1 to _num do {
_iClass = _allCfgLoots call BIS_fnc_selectRandom;
_lootGroupIndex = dz_loot_groups find _iClass;
Loot_InsertCargo(_veh, _lootGroupIndex, 1);
};
[_veh,[_dir,_objPosition],_vehicle,true,"0"] call server_publishVeh;
if (_num > 0) then {
_vehiclesToUpdate set [count _vehiclesToUpdate,_veh];
};
};
};

View File

@ -0,0 +1,106 @@
//private ["_control","_button","_parent","_group","_pos","_item","_conf","_name","_cfgActions","_numActions","_height","_menu","_config","_type","_script","_outputOriented","_compile","_array","_outputClass","_outputType"];
disableSerialization;
_control = _this select 0;
_button = _this select 1;
_parent = findDisplay 106;
if (carryClick) then {carryClick = false;};
if (_button == 1) then {
if (animationState player in ["ainjppnemstpsnonwnondnon_rolltofront","amovppnemstpsnonwnondnon_healed"]) exitWith {
//Prevent bypassing unconscious wake up animation with bandage or other right click actions
localize "str_player_actionslimit" call dayz_rollingMessages;
};
private ["_conf","_name","_compile","_height","_item"];
_group = _parent displayCtrl 6902;
_pos = ctrlPosition _group;
_item = gearSlotData _control;
if ( //No right click action
(!DZE_SelfTransfuse && {_item in ["ItemBloodbag","wholeBloodBagANEG","wholeBloodBagAPOS","wholeBloodBagBNEG","wholeBloodBagBPOS","wholeBloodBagABNEG","wholeBloodBagABPOS","wholeBloodBagONEG","wholeBloodBagOPOS"]})
) exitWith {};
if (mouseOverCarry) then {
_item = DayZ_onBack;
carryClick = true;
};
_pos set [0,((_this select 2) + 0.46)];
_pos set [1,((_this select 3) + 0.07)];
_conf = configFile >> "cfgMagazines" >> _item;
if (!isClass _conf) then {
_conf = configFile >> "cfgWeapons" >> _item;
};
_name = getText(_conf >> "displayName");
_cfgActions = _conf >> "ItemActions";
_numActions = (count _cfgActions);
_height = 0;
if (!dayz_groupSystem && {_item == "ItemRadio"}) then {_numActions = 1;}; // Used to bypass the group action when not enabled.
//Populate Menu
for "_i" from 0 to (_numActions - 1) do
{
_menu = _parent displayCtrl (1600 + _i);
_menu ctrlShow true;
_config = (_cfgActions select _i);
_type = getText (_config >> "text");
_script = getText (_config >> "script");
_outputOriented = getNumber (_config >> "outputOriented") == 1;
_height = _height + (0.025 * safezoneH);
_compile = format["_id = '%2' %1;",_script,_item];
uiNamespace setVariable ['uiControl', _control];
if (_outputOriented) then {
/*
This flag means that the action is output oriented
the output class will then be transferred to the script
and the type used for the name
*/
_array = getArray (_config >> "output");
_outputClass = _array select 0;
_outputType = _array select 1;
_name = getText (configFile >> _outputType >> _outputClass >> "displayName");
_compile = format["_id = ['%2',%3] %1;",_script,_item,_array];
};
_menu ctrlSetText format[_type,_name];
_menu ctrlSetEventHandler ["ButtonClick",_compile];
};
_isKey = ((["ItemKey",_item] call fnc_inString) && (_item != "ItemKeyKit"));
{
private["_classname","_text","_execute","_condition","_option"];
_classname = _x select 0;
_text = _x select 1;
_execute = _x select 2;
_condition = _x select 3;
if (count _this > 4) then {_option = _x select 4};
if ((_item == _classname || (_isKey && (_className == "ItemKey"))) && (call compile _condition)) then {
_menu = _parent displayCtrl (1600 + _numActions);
_menu ctrlShow true;
_height = _height + (0.025 * safezoneH);
uiNamespace setVariable ['uiControl', _control];
_menu ctrlSetText _text;
if (_isKey && (_className == "ItemKey")) then {
_menu ctrlSetEventHandler ["ButtonClick",format ["[%1,%2] %3",str _item,_option,_execute]];
} else {
_menu ctrlSetEventHandler ["ButtonClick",_execute];
};
_numActions = _numActions + 1;
};
} forEach DZE_CLICK_ACTIONS;
_pos set [3,_height];
//hint format["Obj: %1 \nHeight: %2\nPos: %3",_item,_height,_grpPos];
_group ctrlShow true;
ctrlSetFocus _group;
_group ctrlSetPosition _pos;
_group ctrlCommit 0;
};

View File

@ -0,0 +1,171 @@
#include "\z\addons\dayz_server\compile\server_toggle_debug.hpp"
server_obj_pos = {
local _object = _this select 0;
local _objectID = _this select 1;
local _class = _this select 2;
local _position = getPosATL _object;
//_worldspace = [round (direction _object),_position];
local _worldspace = [getDir _object, _position] call AN_fnc_formatWorldspace; // Precise Base Building 1.0.5
local _fuel = [0, fuel _object] select (_class isKindOf "AllVehicles");
local _key = format["CHILD:305:%1:%2:%3:",_objectID,_worldspace,_fuel];
_key call server_hiveWrite;
#ifdef OBJECT_DEBUG
diag_log ("HIVE: WRITE: "+ str(_key));
#endif
};
server_obj_inv = {
local _object = _this select 0;
local _objectID = _this select 1;
local _objectUID = _this select 2;
local _class = _this select 3;
local _inventory = call {
if (DZE_permanentPlot && {_class == "Plastic_Pole_EP1_DZ"}) exitwith {
_object getVariable ["plotfriends", []] //We're replacing the inventory with UIDs for this item
};
if (DZE_doorManagement && {_class in DZE_DoorsLocked}) exitwith {
_object getVariable ["doorfriends", []] //We're replacing the inventory with UIDs for this item
};
if (_class isKindOf "TrapItems") exitwith {
[["armed",_object getVariable ["armed",false]]]
};
[getWeaponCargo _object, getMagazineCargo _object, getBackpackCargo _object]
};
local _previous = str(_object getVariable["lastInventory",[]]);
if (str _inventory != _previous) then {
local _key = "";
_object setVariable ["lastInventory",_inventory];
if (_objectID == "0") then {
_key = format["CHILD:309:%1:",_objectUID] + str _inventory + ":";
} else {
_key = format["CHILD:303:%1:",_objectID] + str _inventory + ":";
};
if (Z_SingleCurrency) then {
local _coins = _object getVariable ["cashMoney", -1]; //set to invalid value if getVariable fails to prevent overwriting of coins in DB
_key = _key + str _coins + ":";
};
#ifdef OBJECT_DEBUG
diag_log ("HIVE: WRITE: "+ str(_key));
#endif
_key call server_hiveWrite;
};
};
server_obj_dam = {
//Allow dmg process
local _object = _this select 0;
local _objectID = _this select 1;
local _objectUID = _this select 2;
local _forced = _this select 3;
local _totalDmg = _this select 4;
local _recorddmg = false;
local _hitpoints = _object call vehicle_getHitpoints;
local _damage = damage _object;
local _array = [];
local _allFixed = true;
local _lastUpdate = _object getVariable ["lastUpdate",diag_tickTime];
{
local _hit = [_object,_x] call object_getHit;
if ((_hit select 0) > 0) then {
_allFixed = false;
_array set [count _array,[(_hit select 1),(_hit select 0)]];
//diag_log format ["Section Part: %1, Dmg: %2",(_hit select 1),(_hit select 0)];
} else {
_array set [count _array,[(_hit select 1),0]];
};
} count _hitpoints;
if (_allFixed && !_totalDmg && _forced) then {_object setDamage 0;};
if (_forced) then {
if (_object in needUpdate_objects) then {needUpdate_objects = needUpdate_objects - [_object];};
_recorddmg = true;
} else {
//Prevent damage events for the first 10 seconds of the servers live.
if (diag_ticktime - _lastUpdate > 10) then {
if !(_object in needUpdate_objects) then {
//diag_log format["DEBUG: Monitoring: %1",_object];
needUpdate_objects set [count needUpdate_objects, _object];
_recorddmg = true;
_object setVariable ["lastUpdate",diag_ticktime];
};
};
};
if (_recorddmg) then {
local _key = "";
if (_objectID == "0") then {
_key = format["CHILD:306:%1:",_objectUID] + str _array + ":" + str _damage + ":";
} else {
_key = format["CHILD:306:%1:",_objectID] + str _array + ":" + str _damage + ":";
};
#ifdef OBJECT_DEBUG
diag_log ("HIVE: WRITE: "+ str(_key));
#endif
_key call server_hiveWrite;
};
};
server_obj_killed = {
local _object = _this select 0;
local _objectID = _this select 1;
local _objectUID = _this select 2;
local _playerUID = _this select 3;
local _clientKey = _this select 4;
local _class = _this select 5;
local _key = "";
local _index = dayz_serverPUIDArray find _playerUID;
local _exitReason = call {
//Can't use owner because player may already be dead, can't use distance because player may be far from vehicle wreck
if (_clientKey == dayz_serverKey) exitwith {""};
if (_index < 0) exitwith {
format["Server_UpdateObject error: PUID NOT FOUND ON SERVER. PV ARRAY: %1",_this]
};
if ((dayz_serverClientKeys select _index) select 1 != _clientKey) exitwith {
format["Server_UpdateObject error: CLIENT AUTH KEY INCORRECT OR UNRECOGNIZED. PV ARRAY: %1",_this]
};
if (alive _object and {!(_class isKindOf "TentStorage_base" or _class isKindOf "IC_Tent")}) exitwith {
format["Server_UpdateObject error: object kill request on living object. PV ARRAY: %1",_this]
};
"";
};
if (_exitReason != "") exitWith {diag_log _exitReason};
_object setDamage 1;
if (_objectID == "0") then {
//Need to update hive to make a new call to allow UID to be updated for a killed event
//_key = format["CHILD:306:%1:%2:%3:",_objectUID,[],1];
_key = format["CHILD:310:%1:",_objectUID];
} else {
_key = format["CHILD:306:%1:%2:%3:",_objectID,[],1];
};
_key call server_hiveWrite;
if (_playerUID == "SERVER") then {
#ifdef OBJECT_DEBUG
diag_log format["DELETE: Server requested destroy on object %1 ID:%2 UID:%3",_class,_objectID,_objectUID];
#endif
} else {
diag_log format["DELETE: PUID(%1) requested destroy on object %2 ID:%3 UID:%4",_playerUID,_class,_objectID,_objectUID];
};
if (_class in DayZ_removableObjects || {_class in DZE_isRemovable}) then {[_objectID,_objectUID,_object] call server_deleteObjDirect;};
};

View File

@ -0,0 +1,50 @@
private ["_position","_doLoiter","_unitTypes","_array","_agent","_type","_radius","_method","_rndx","_rndy","_counter","_amount","_wildsdone"];
_unitTypes = _this select 0;
_amount = _this select 1;
//_doLoiter = true;
_wildsdone = true;
_counter = 0;
while {_counter < _amount} do {
//_loot = "";
//_array = [];
_agent = objNull;
_type = _unitTypes call BIS_fnc_selectRandom;
//Create the Group and populate it
//diag_log ("Spawned: " + _type);
//_radius = 0;
_method = "CAN_COLLIDE";
_position = [getMarkerPos "center",1,6500,1] call fn_selectRandomLocation;
if ([_position] call DZE_SafeZonePosCheck) exitWith {};
//Create Zed
_agent = createAgent [_type, _position, [], 1, _method];
//Set Random Direction
_agent setDir floor(random 360);
//Loiter State
_agent setVariable ["doLoiter",true]; //Might not be used.
//Zed stance
if (random 1 > 0.7) then {
_agent setUnitPos "Middle";
};
//Set home location to loiter around
_position = getPosATL _agent;
_agent setVariable ["homePos",_position,true];
//Store _agentobject
_agent setVariable["agentObject",_agent,true];
//add to counter
_counter = _counter + 1;
//Start behavior
//_id = [_agent] execFSM "\z\AddOns\dayz_code\system\zombie_wildagent.fsm";
//_agent setVariable [ "fsmid", _id ];
//Disable all zed systems
_agent enableSimulation false;
//diag_log format ["CREATE WILD: Active: %1, Waiting: %2",_counter,(_amount - _counter)]
};
_wildsdone

View File

@ -0,0 +1,8 @@
private["_unit"];
_unit = _this select 0;
#include "\z\addons\dayz_server\compile\server_toggle_debug.hpp"
#ifdef SERVER_DEBUG
diag_log ("CLEANUP: DELETE UNCONTROLLED ZOMBIE: " + (typeOf _unit) + " OF: " + str(_unit) );
#endif
deleteVehicle _unit;