mirror of
https://github.com/EpochModTeam/DayZ-Epoch.git
synced 2026-02-17 13:42:57 +03:00
fixes and cleanup
This commit is contained in:
@@ -3,10 +3,6 @@ private ["_array","_type","_classname","_holder","_config","_isOk","_muzzles","_
|
||||
// Exit if player zombie
|
||||
if(player isKindOf "PZombie_VB") exitWith {};
|
||||
|
||||
// Test cannot lock while another player is nearby
|
||||
// _playerNear = {isPlayer _x} count (player nearEntities ["CAManBase", 6]) > 1;
|
||||
// if(_playerNear) exitWith {cutText ["Cannot take item while another player is nearby." , "PLAIN DOWN"]; };
|
||||
|
||||
if (!DZE_CanPickup) exitWith { cutText [(localize "str_epoch_player_38") , "PLAIN DOWN"]; };
|
||||
DZE_CanPickup = false;
|
||||
|
||||
@@ -15,55 +11,40 @@ _type = _array select 0;
|
||||
_classname = _array select 1;
|
||||
_holder = _array select 2;
|
||||
|
||||
_playerID = getPlayerUID player;
|
||||
_text = getText (configFile >> _type >> _classname >> "displayName");
|
||||
|
||||
_claimedBy = _holder getVariable["claimed","0"];
|
||||
|
||||
// Check if any players are nearby if not allow player to claim item.
|
||||
_playerNear = {isPlayer _x} count (player nearEntities ["CAManBase", 6]) > 1;
|
||||
|
||||
// Only allow if not already claimed.
|
||||
if (_claimedBy == "0" or !_playerNear) then {
|
||||
// Since item was not claimed proceed with claiming it.
|
||||
_holder setVariable["claimed",_playerID,true];
|
||||
// if holder is null disallow pickup for 5 seconds
|
||||
if(isNull _holder) exitWith {
|
||||
[] spawn {
|
||||
sleep 5;
|
||||
DZE_CanPickup = true;
|
||||
};
|
||||
};
|
||||
|
||||
if(_classname isKindOf "TrapBear") exitwith {DZE_CanPickup = true; deleteVehicle _holder;};
|
||||
// Check if closest player
|
||||
_PlayerNear = _holder call dze_isnearest_player;
|
||||
if (_PlayerNear) exitWith {cutText [localize "str_pickup_limit_4", "PLAIN DOWN"]};
|
||||
|
||||
_text = getText (configFile >> _type >> _classname >> "displayName");
|
||||
|
||||
player playActionNow "PutDown";
|
||||
|
||||
_claimedBy = _holder getVariable["claimed","0"];
|
||||
if(_classname isKindOf "TrapBear") exitwith {DZE_CanPickup = true; deleteVehicle _holder;};
|
||||
|
||||
if (_claimedBy != _playerID) exitWith {sleep 1; DZE_CanPickup = true; cutText [format[(localize "str_player_beinglooted"),_text] , "PLAIN DOWN"]};
|
||||
|
||||
// test to see if item still exists just before adding and removing
|
||||
if(isNull _holder) exitWith { sleep 1; DZE_CanPickup = true; };
|
||||
|
||||
if(_classname isKindOf "Bag_Base_EP1") then {
|
||||
|
||||
_PlayerNear = _holder call dze_isnearest_player;
|
||||
if (_PlayerNear) exitWith {cutText [localize "str_pickup_limit_4", "PLAIN DOWN"]};
|
||||
|
||||
diag_log("Picked up a bag: " + _classname);
|
||||
player action ["TakeBag", _holder];
|
||||
if(_classname isKindOf "Bag_Base_EP1") exitwith {
|
||||
// diag_log("Picked up a bag: " + _classname);
|
||||
if(_classname == typeOf _holder) then {
|
||||
player action ["TakeBag", _holder];
|
||||
};
|
||||
};
|
||||
|
||||
_obj = nearestObjects [(getPosATL player), [(typeOf _holder)], 5];
|
||||
_qty = count _obj;
|
||||
|
||||
if(_qty >= 1) then {
|
||||
|
||||
//Remove melee magazines (BIS_fnc_invAdd fix) (add new melee ammo to array if needed)
|
||||
{player removeMagazines _x} forEach ["Hatchet_Swing","Crowbar_Swing","Machete_Swing","Fishing_Swing","sledge_swing"];
|
||||
|
||||
_config = (configFile >> _type >> _classname);
|
||||
_isOk = [player,_config] call BIS_fnc_invAdd;
|
||||
if (_isOk) then {
|
||||
|
||||
deleteVehicle _holder;
|
||||
if (_classname in ["MeleeHatchet","MeleeCrowbar","MeleeMachete","MeleeFishingPole","MeleeSledge"]) then {
|
||||
|
||||
if (_type == "cfgWeapons") then {
|
||||
_muzzles = getArray(configFile >> "cfgWeapons" >> _classname >> "muzzles");
|
||||
//_wtype = ((weapons player) select 0);
|
||||
@@ -74,19 +55,11 @@ if(_qty >= 1) then {
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
//adding melee mags back if needed
|
||||
switch (primaryWeapon player) do
|
||||
{
|
||||
case "MeleeHatchet": {player addMagazine 'Hatchet_Swing';};
|
||||
case "MeleeCrowbar": {player addMagazine 'Crowbar_Swing';};
|
||||
case "MeleeMachete": {player addMagazine 'Machete_Swing';};
|
||||
case "MeleeFishingPole": {player addMagazine 'Fishing_Swing';};
|
||||
case "MeleeSledge": {player addMagazine 'sledge_swing';};
|
||||
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
sleep 1;
|
||||
DZE_CanPickup = true;
|
||||
// disallow another pickup action for 5 seconds.
|
||||
[] spawn {
|
||||
sleep 5;
|
||||
DZE_CanPickup = true;
|
||||
};
|
||||
Reference in New Issue
Block a user