From 3d9914a239f0edabf3abc5b560ac88b7ccd3dc3e Mon Sep 17 00:00:00 2001 From: A Man Date: Mon, 2 May 2022 11:16:57 +0200 Subject: [PATCH] Update fn_addDuplicateTool again and add vehicle handling --- SQF/dayz_code/compile/fn_addDuplicateTool.sqf | 31 ++++++++++++++----- .../compile/fn_freeBackpackSlots.sqf | 2 +- SQF/dayz_code/stringtable.xml | 8 +++-- 3 files changed, 31 insertions(+), 10 deletions(-) diff --git a/SQF/dayz_code/compile/fn_addDuplicateTool.sqf b/SQF/dayz_code/compile/fn_addDuplicateTool.sqf index 402228982..9aae300f1 100644 --- a/SQF/dayz_code/compile/fn_addDuplicateTool.sqf +++ b/SQF/dayz_code/compile/fn_addDuplicateTool.sqf @@ -3,32 +3,49 @@ Description: Checks whether the player already has the tool on their toolbelt and then adds it. Useful for batch crafting tools. 1. If they don't then it adds it to their toolbelt. If the toolbelt is full it is dropped on the floor. 2. If they do then it adds it to their backpack. If their backpack is full it spills out on the floor. -3. If they have no backpack it spawns on the floor as a last resort. +3. If in vehicle and the backpack is full or they have no backpack it drops the tool into the vehicle gear. +4. If they have no backpack and are not in a vehicle it spawns on the floor as a last resort. The player is given an appropriate systemChat message in each case. +Warning: The case if the player is inside a vehicle and the players inventory is full and full backpack/no backpack and full vehicle cannot +be handled properly. In this case the tools getting dropped on the ground even when the vehicle moves. + Parameter: _this: string - toolbelt item classname to check and add How to use: "ItemSledge" call player_addDuplicateTool; */ + local _tool = _this; local _displayName = getText(configFile >> "CfgWeapons" >> _tool >> "displayName"); +local _vehicle = vehicle player; +local _inVehicle = player != _vehicle; if (_tool in items player) then { local _bag = unitBackpack player; if (!isNull _bag) then { - local _freeSlots = call fnc_freeBackpackSlots; - if (_freeSlots > 0) then { + local _freeSlots = call fnc_freeBackpackSlots; + if (_freeSlots > 0) then { // This check does not work 100% since we have no command to get the exact number of free space within a backpack systemChat format[localize "str_epoch_player_313",_displayName]; _bag addWeaponCargoGlobal [_tool,1]; } else { - [_tool,2,1] call fn_dropItem; - systemChat format[localize "str_actions_noroom",_displayName]; + if (_inVehicle) then { + systemChat format[localize "str_epoch_player_313_1",_displayName]; + _vehicle addWeaponCargoGlobal [_tool,1]; + } else { + [_tool,2,1] call fn_dropItem; + systemChat format[localize "str_actions_noroom",_displayName]; + }; }; } else { - [_tool,2,1] call fn_dropItem; - systemChat format[localize "str_actions_noroom",_displayName]; + if (_inVehicle) then { + systemChat format[localize "str_epoch_player_313_1",_displayName]; + _vehicle addWeaponCargoGlobal [_tool,1]; + } else { + [_tool,2,1] call fn_dropItem; + systemChat format[localize "str_actions_noroom",_displayName]; + }; }; } else { //Remove melee magazines (BIS_fnc_invAdd fix) diff --git a/SQF/dayz_code/compile/fn_freeBackpackSlots.sqf b/SQF/dayz_code/compile/fn_freeBackpackSlots.sqf index bde21ea09..346af59e7 100644 --- a/SQF/dayz_code/compile/fn_freeBackpackSlots.sqf +++ b/SQF/dayz_code/compile/fn_freeBackpackSlots.sqf @@ -29,7 +29,7 @@ if (!isNull _bag) then { call { if (_weaponInvType == 1) exitwith {_qtyMaxBag = _qtyMaxBag + (10*_qtyWeapon);}; if (_weaponInvType == 2) exitwith {_qtyMaxBag = _qtyMaxBag + (5*_qtyWeapon);}; - if (_weaponInvType in [256,4096]) exitwith {_qtyMaxBag = _qtyMaxBag + _qtyWeapon;}; + if (_weaponInvType in [131072,4096]) exitwith {_qtyMaxBag = _qtyMaxBag + _qtyWeapon;}; }; } foreach _weaponsBag; diff --git a/SQF/dayz_code/stringtable.xml b/SQF/dayz_code/stringtable.xml index a603c856a..e8095ce6b 100644 --- a/SQF/dayz_code/stringtable.xml +++ b/SQF/dayz_code/stringtable.xml @@ -25152,13 +25152,17 @@ Zum Kommandantensitz - %1 is already in your inventory. Adding to backpack! - %1 ist bereits in deinem Inventar. Hinzufügen zum Rucksack! + %1 is already in your inventory and got added to your backpack! + %1 ist bereits in deinem Inventar und wurde deinem Rucksack hinzugefügt! %1 уже есть в вашем инвентаре. Перемещено в рюкзак! %1 is al in je inventaris. Toevoegen aan rugzak! %1 est déjà dans votre inventaire. Ajout d'un sac à dos! %1 je již ve vašem inventáři. Přidání do batoh! + + %1 is already in your inventory and got added to your vehicle! + %1 ist bereits in deinem Inventar und wurde deinem Fahrzeug hinzugefügt! + %1 is restricted. %1 ist gesperrt.