Files
DayZ-Epoch/SQF/dayz_code/actions/player_takeArrow.sqf
2016-04-16 15:47:49 -04:00

34 lines
1.2 KiB
Plaintext

private ["_qty_quivers","_control","_qty_quiverarrows","_empty","_emptymagslotcount"];
disableSerialization;
call gear_ui_init;
_qty_quivers = {_x == "Quiver"} count magazines player;
_control = uiNamespace getVariable 'uiControl';
_qty_quiverarrows = gearSlotAmmoCount _control;
//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"];
_empty = [player] call BIS_fnc_invSlotsEmpty;
_emptymagslotcount = _empty select 4; //empty magazines slots
if (_qty_quivers > 1) exitWith { localize "str_quiver_reachlimit" call dayz_rollingMessages;};
if (_qty_quiverarrows == 2) then { //remove quiver - add 2 arrows
if (_emptymagslotcount > 0) then {
player removeMagazine "Quiver";
player addMagazine "WoodenArrow";
player addMagazine "WoodenArrow";
} else {
localize "str_player_24" call dayz_rollingMessages; //Error
};
} else {
if (_emptymagslotcount > 0) then {
player removeMagazine "Quiver";
player addMagazine "WoodenArrow";
player addMagazine ["Quiver",_qty_quiverarrows-1];
} else {
localize "str_player_24" call dayz_rollingMessages; //Error
};
};