mirror of
https://github.com/EpochModTeam/DayZ-Epoch.git
synced 2025-12-14 20:13:13 +03:00
Update fn_addDuplicateTool again and add vehicle handling
This commit is contained in:
@@ -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.
|
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.
|
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.
|
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.
|
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:
|
Parameter:
|
||||||
_this: string - toolbelt item classname to check and add
|
_this: string - toolbelt item classname to check and add
|
||||||
|
|
||||||
How to use:
|
How to use:
|
||||||
"ItemSledge" call player_addDuplicateTool;
|
"ItemSledge" call player_addDuplicateTool;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
local _tool = _this;
|
local _tool = _this;
|
||||||
local _displayName = getText(configFile >> "CfgWeapons" >> _tool >> "displayName");
|
local _displayName = getText(configFile >> "CfgWeapons" >> _tool >> "displayName");
|
||||||
|
local _vehicle = vehicle player;
|
||||||
|
local _inVehicle = player != _vehicle;
|
||||||
|
|
||||||
if (_tool in items player) then {
|
if (_tool in items player) then {
|
||||||
local _bag = unitBackpack player;
|
local _bag = unitBackpack player;
|
||||||
if (!isNull _bag) then {
|
if (!isNull _bag) then {
|
||||||
local _freeSlots = call fnc_freeBackpackSlots;
|
local _freeSlots = call fnc_freeBackpackSlots;
|
||||||
if (_freeSlots > 0) then {
|
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];
|
systemChat format[localize "str_epoch_player_313",_displayName];
|
||||||
_bag addWeaponCargoGlobal [_tool,1];
|
_bag addWeaponCargoGlobal [_tool,1];
|
||||||
|
} else {
|
||||||
|
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 {
|
||||||
|
if (_inVehicle) then {
|
||||||
|
systemChat format[localize "str_epoch_player_313_1",_displayName];
|
||||||
|
_vehicle addWeaponCargoGlobal [_tool,1];
|
||||||
} else {
|
} else {
|
||||||
[_tool,2,1] call fn_dropItem;
|
[_tool,2,1] call fn_dropItem;
|
||||||
systemChat format[localize "str_actions_noroom",_displayName];
|
systemChat format[localize "str_actions_noroom",_displayName];
|
||||||
};
|
};
|
||||||
} else {
|
|
||||||
[_tool,2,1] call fn_dropItem;
|
|
||||||
systemChat format[localize "str_actions_noroom",_displayName];
|
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
//Remove melee magazines (BIS_fnc_invAdd fix)
|
//Remove melee magazines (BIS_fnc_invAdd fix)
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ if (!isNull _bag) then {
|
|||||||
call {
|
call {
|
||||||
if (_weaponInvType == 1) exitwith {_qtyMaxBag = _qtyMaxBag + (10*_qtyWeapon);};
|
if (_weaponInvType == 1) exitwith {_qtyMaxBag = _qtyMaxBag + (10*_qtyWeapon);};
|
||||||
if (_weaponInvType == 2) exitwith {_qtyMaxBag = _qtyMaxBag + (5*_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;
|
} foreach _weaponsBag;
|
||||||
|
|
||||||
|
|||||||
@@ -25152,13 +25152,17 @@
|
|||||||
<German>Zum Kommandantensitz</German>
|
<German>Zum Kommandantensitz</German>
|
||||||
</Key>
|
</Key>
|
||||||
<Key ID="STR_EPOCH_PLAYER_313">
|
<Key ID="STR_EPOCH_PLAYER_313">
|
||||||
<English>%1 is already in your inventory. Adding to backpack!</English>
|
<English>%1 is already in your inventory and got added to your backpack!</English>
|
||||||
<German>%1 ist bereits in deinem Inventar. Hinzufügen zum Rucksack!</German>
|
<German>%1 ist bereits in deinem Inventar und wurde deinem Rucksack hinzugefügt!</German>
|
||||||
<Russian>%1 уже есть в вашем инвентаре. Перемещено в рюкзак!</Russian>
|
<Russian>%1 уже есть в вашем инвентаре. Перемещено в рюкзак!</Russian>
|
||||||
<Dutch>%1 is al in je inventaris. Toevoegen aan rugzak!</Dutch>
|
<Dutch>%1 is al in je inventaris. Toevoegen aan rugzak!</Dutch>
|
||||||
<French>%1 est déjà dans votre inventaire. Ajout d'un sac à dos!</French>
|
<French>%1 est déjà dans votre inventaire. Ajout d'un sac à dos!</French>
|
||||||
<Czech>%1 je již ve vašem inventáři. Přidání do batoh!</Czech>
|
<Czech>%1 je již ve vašem inventáři. Přidání do batoh!</Czech>
|
||||||
</Key>
|
</Key>
|
||||||
|
<Key ID="STR_EPOCH_PLAYER_313_1">
|
||||||
|
<English>%1 is already in your inventory and got added to your vehicle!</English>
|
||||||
|
<German>%1 ist bereits in deinem Inventar und wurde deinem Fahrzeug hinzugefügt!</German>
|
||||||
|
</Key>
|
||||||
<Key ID="STR_EPOCH_PLAYER_315">
|
<Key ID="STR_EPOCH_PLAYER_315">
|
||||||
<English>%1 is restricted.</English>
|
<English>%1 is restricted.</English>
|
||||||
<German>%1 ist gesperrt.</German>
|
<German>%1 ist gesperrt.</German>
|
||||||
|
|||||||
Reference in New Issue
Block a user