mirror of
https://github.com/EpochModTeam/DayZ-Epoch.git
synced 2025-12-21 19:06:29 +03:00
Fix copy key failing when player has no backpack
Related to #1567, so I made this a function so it can be reused. People should call this whenever they are adding a toolbelt item which the player may already have. It has localized strings and handles spawning the weapon holder on water, land and rooftop. Tested both the sledgehammer and key copying. Confirmed all three conditions are working.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
private ["_item","_config","_pos","_onLadder","_create","_started","_finished","_animState","_isMedic","_qty","_b0x1337","_num_removed","_text","_haskey","_hastoolweapon","_isNear","_hasTinBar"];
|
||||
private ["_item","_config","_pos","_onLadder","_create","_started","_finished","_animState","_isMedic","_num_removed","_text","_haskey","_hastoolweapon","_isNear","_hasTinBar"];
|
||||
|
||||
if(DZE_ActionInProgress) exitWith { cutText [(localize "str_epoch_player_56") , "PLAIN DOWN"]; };
|
||||
DZE_ActionInProgress = true;
|
||||
@@ -59,12 +59,8 @@ if(_finished) then {
|
||||
_num_removed = ([player,"ItemTinBar"] call BIS_fnc_invRemove);
|
||||
|
||||
if(_num_removed == 1) then {
|
||||
// output key to backpack if space
|
||||
_create = _item;
|
||||
_qty = 1;
|
||||
_b0x1337 = unitBackpack player;
|
||||
_b0x1337 addWeaponCargoGlobal [_create,_qty];
|
||||
cutText [(localize "str_epoch_player_60") , "PLAIN DOWN"];
|
||||
_create call player_addDuplicateTool;
|
||||
} else {
|
||||
cutText [(localize "str_epoch_player_61") , "PLAIN DOWN"];
|
||||
};
|
||||
|
||||
@@ -222,20 +222,8 @@ if (_canDo) then {
|
||||
_craft_doLoop = false;
|
||||
};
|
||||
{
|
||||
if ((_x == "ItemSledge") && {_x in items player}) then {
|
||||
_bag = unitBackpack player;
|
||||
if (!isNull _bag) then {
|
||||
systemChat format[(localize "str_epoch_player_313"),_x];
|
||||
_bag addWeaponCargoGlobal [_x,1];
|
||||
} else {
|
||||
systemChat format[(localize "str_epoch_player_314"),_x];
|
||||
_location = player modeltoworld [0,0.3,0];
|
||||
if ((_location select 2) < 0) then {_location set [2,0];};
|
||||
_object = createVehicle ["WeaponHolder",_location,[],0,"CAN_COLLIDE"];
|
||||
if (surfaceIsWater _location) then {_object setPosASL (getPosASL player);} else {_object setPosATL _location;};
|
||||
_object setVariable ["permaLoot",true];
|
||||
_object addWeaponCargoGlobal [_x,1];
|
||||
};
|
||||
if (_x == "ItemSledge") then {
|
||||
_x call player_addDuplicateTool;
|
||||
} else {
|
||||
player addWeapon _x;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user