mirror of
https://github.com/EpochModTeam/Epoch.git
synced 2024-08-30 18:22:13 +00:00
Inventory space checks
This commit is contained in:
parent
22ef7c1c2c
commit
3b11fc7f75
@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
Author: Aaron Clark - EpochMod.com
|
||||||
|
|
||||||
|
Contributors: DirtySanchez
|
||||||
|
|
||||||
|
Description:
|
||||||
|
Epoch add magazine with overflow toggle
|
||||||
|
|
||||||
|
Licence:
|
||||||
|
Arma Public License Share Alike (APL-SA) - https://www.bistudio.com/community/licenses/arma-public-license-share-alike
|
||||||
|
|
||||||
|
Github:
|
||||||
|
https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_code/compile/functions/EPOCH_fnc_addMagazineOverflow.sqf
|
||||||
|
|
||||||
|
Example:
|
||||||
|
[_mag,_magAmmo,true] call EPOCH_fnc_addMagazineOverflow;
|
||||||
|
|
||||||
|
Parameter(s):
|
||||||
|
_this select 0: STRING - Magazine Class
|
||||||
|
_this select 1: NUMBER - (Optional) Ammo count
|
||||||
|
_this select 2: BOOLEAN - (Optional) drop to groundWeaponHolder
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
NUMBER 1: magazine was added to inventory
|
||||||
|
2: not enough room in inventory
|
||||||
|
3: magazine was dropped nearby
|
||||||
|
0: failed
|
||||||
|
*/
|
||||||
|
//[[[cog import generate_private_arrays ]]]
|
||||||
|
private ["_return","_nearByHolder","_wH","_wHPos"];
|
||||||
|
//[[[end]]]
|
||||||
|
params [["_item","",[""]],["_count",1],["_canDrop",true]];
|
||||||
|
_return = 0;
|
||||||
|
if (player canAdd _item) then {
|
||||||
|
player addMagazine [_item,_count];
|
||||||
|
_return = 1;
|
||||||
|
} else {
|
||||||
|
_return = 3;
|
||||||
|
if(_canDrop)then{
|
||||||
|
_wH = objNull;
|
||||||
|
if (isNil "_nearByHolder") then {
|
||||||
|
_nearByHolder = nearestObjects [player,["groundWeaponHolder"],3];
|
||||||
|
};
|
||||||
|
if (_nearByHolder isEqualTo []) then {
|
||||||
|
_wHPos = player modelToWorld [0,1,0];
|
||||||
|
if (surfaceIsWater _wHPos) then {
|
||||||
|
_wHPos = ASLToATL _wHPos;
|
||||||
|
};
|
||||||
|
_wH = createVehicle ["groundWeaponHolder",_wHPos, [], 0, "CAN_COLLIDE"];
|
||||||
|
} else {
|
||||||
|
_wH = _nearByHolder select 0;
|
||||||
|
};
|
||||||
|
if !(isNull _wh) then {
|
||||||
|
//_wh addItemCargoGlobal [_item,1];
|
||||||
|
_wh addMagazineAmmoCargo [_item, 1, _count];
|
||||||
|
};
|
||||||
|
_return = 2;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
_return
|
@ -33,7 +33,16 @@ if(_magAmmo isEqualTo 0)exitWith{
|
|||||||
[format["The %1 does not have any ammo",_nameTurret],5] call Epoch_message;
|
[format["The %1 does not have any ammo",_nameTurret],5] call Epoch_message;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
_return = [_magsTurret,_magAmmo] call EPOCH_fnc_addMagazineOverflow;
|
||||||
|
if(_return isEqualTo 0)exitWith{diag_log "[EpochDebug] removeCommanderAmmo _return epoch_equip failed"};
|
||||||
|
if(_return isEqualTo 1)then{
|
||||||
[format["You have removed 1 can of %1 with %2 rounds",_magsTurret, _magAmmo],5] call Epoch_message;
|
[format["You have removed 1 can of %1 with %2 rounds",_magsTurret, _magAmmo],5] call Epoch_message;
|
||||||
player addMagazine [_magsTurret,_magAmmo];
|
};
|
||||||
|
if(_return isEqualTo 2)then{
|
||||||
|
[format["You dropped 1 can of %1 with %2 rounds on the ground!",_magsTurret, _magAmmo],5] call Epoch_message;
|
||||||
|
};
|
||||||
|
if(_return isEqualTo 3)then{
|
||||||
|
[format["You dont have enough space for %1!",_magsTurret],5] call Epoch_message;
|
||||||
|
};
|
||||||
vehicle player removeMagazineTurret [_magsTurret,_turretPath];
|
vehicle player removeMagazineTurret [_magsTurret,_turretPath];
|
||||||
reload vehicle player;
|
reload vehicle player;
|
@ -24,7 +24,17 @@ if(_magsTurretDetails isEqualTo [])exitWith{
|
|||||||
|
|
||||||
private _magsTurret = (_magsTurretDetails select 0) select 0;
|
private _magsTurret = (_magsTurretDetails select 0) select 0;
|
||||||
private _magAmmo = (_magsTurretDetails select 0) select 1;
|
private _magAmmo = (_magsTurretDetails select 0) select 1;
|
||||||
|
|
||||||
|
_return = [_magsTurret,_magAmmo] call EPOCH_fnc_addMagazineOverflow;
|
||||||
|
if(_return isEqualTo 0)exitWith{diag_log "[EpochDebug] removeCommanderAmmo _return epoch_equip failed"};
|
||||||
|
if(_return isEqualTo 1)then{
|
||||||
[format["You have removed 1 can of %1 with %2 rounds",_magsTurret, _magAmmo],5] call Epoch_message;
|
[format["You have removed 1 can of %1 with %2 rounds",_magsTurret, _magAmmo],5] call Epoch_message;
|
||||||
player addMagazine [_magsTurret,_magAmmo];
|
};
|
||||||
|
if(_return isEqualTo 2)then{
|
||||||
|
[format["You dropped 1 can of %1 with %2 rounds on the ground!",_magsTurret, _magAmmo],5] call Epoch_message;
|
||||||
|
};
|
||||||
|
if(_return isEqualTo 3)then{
|
||||||
|
[format["You dont have enough space for %1!",_magsTurret],5] call Epoch_message;
|
||||||
|
};
|
||||||
vehicle player removeMagazineTurret [_magsTurret,_turretPath];
|
vehicle player removeMagazineTurret [_magsTurret,_turretPath];
|
||||||
reload vehicle player;
|
reload vehicle player;
|
@ -117,6 +117,7 @@ class CfgClientFunctions
|
|||||||
class fnc_isInsideBuilding {};
|
class fnc_isInsideBuilding {};
|
||||||
class fnc_findSafePos {};
|
class fnc_findSafePos {};
|
||||||
class fnc_addItemOverflow {};
|
class fnc_addItemOverflow {};
|
||||||
|
class fnc_addMagazineOverflow {};
|
||||||
class itemData {};
|
class itemData {};
|
||||||
class itemPicture {};
|
class itemPicture {};
|
||||||
class itemDisplayName {};
|
class itemDisplayName {};
|
||||||
|
Loading…
Reference in New Issue
Block a user