mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
addToInventory use addMagazineArray -maybe fix #530
This commit is contained in:
parent
9a25fb4f2f
commit
d50bff866b
@ -4,9 +4,10 @@
|
|||||||
* or places it in a weaponHolder if no space.
|
* or places it in a weaponHolder if no space.
|
||||||
*
|
*
|
||||||
* Arguments:
|
* Arguments:
|
||||||
* 0: Unit (OBJECT)
|
* 0: Unit <OBJECT>
|
||||||
* 1: Classname (String)
|
* 1: Classname <STRING>
|
||||||
* 2: Container (String, Optional) uniform, vest, backpack
|
* 2: Container (uniform, vest, backpack) <STRING><OPTIONAL>
|
||||||
|
* 3: Magazine Ammo Count <NUMBER><OPTIONAL>
|
||||||
*
|
*
|
||||||
* Return Value:
|
* Return Value:
|
||||||
* Array:
|
* Array:
|
||||||
@ -19,6 +20,9 @@
|
|||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
EXPLODE_2_PVT(_this,_unit,_classname);
|
EXPLODE_2_PVT(_this,_unit,_classname);
|
||||||
|
DEFAULT_PARAM(2,_container,"");
|
||||||
|
DEFAULT_PARAM(3,_ammoCount,-1);
|
||||||
|
|
||||||
private "_addedToPlayer";
|
private "_addedToPlayer";
|
||||||
private "_container";
|
private "_container";
|
||||||
private "_canAdd";
|
private "_canAdd";
|
||||||
@ -27,23 +31,13 @@ private "_type";
|
|||||||
_canAdd = false;
|
_canAdd = false;
|
||||||
_addedToPlayer = true;
|
_addedToPlayer = true;
|
||||||
|
|
||||||
if((count _this) > 2) then {
|
|
||||||
_container = _this select 2;
|
|
||||||
} else {
|
|
||||||
_container = nil;
|
|
||||||
};
|
|
||||||
|
|
||||||
_type = [_classname] call EFUNC(common,getItemType);
|
_type = [_classname] call EFUNC(common,getItemType);
|
||||||
|
|
||||||
if(!isNil "_container") then {
|
switch (_container) do {
|
||||||
switch (_container) do {
|
|
||||||
case "vest": { _canAdd = _unit canAddItemToVest _classname; };
|
case "vest": { _canAdd = _unit canAddItemToVest _classname; };
|
||||||
case "backpack": { _canAdd = _unit canAddItemToBackpack _classname; };
|
case "backpack": { _canAdd = _unit canAddItemToBackpack _classname; };
|
||||||
case "uniform": { _canAdd = _unit canAddItemToUniform _classname; };
|
case "uniform": { _canAdd = _unit canAddItemToUniform _classname; };
|
||||||
};
|
default {_canAdd = _unit canAdd _classname;};
|
||||||
} else {
|
|
||||||
_container = "";
|
|
||||||
_canAdd = _unit canAdd _classname;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
switch ((_type select 0)) do {
|
switch ((_type select 0)) do {
|
||||||
@ -64,18 +58,19 @@ switch ((_type select 0)) do {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
case "magazine": {
|
case "magazine": {
|
||||||
|
if (_ammoCount == -1) then {_ammoCount = getNumber (configFile >> "CfgMagazines" >> _classname >> "count");};
|
||||||
if (_canAdd) then {
|
if (_canAdd) then {
|
||||||
switch (_container) do {
|
switch (_container) do {
|
||||||
case "vest": { (vestContainer _unit) addMagazineCargoGlobal [_classname, 1]; };
|
case "vest": { (vestContainer _unit) addMagazineCargoGlobal [_classname, _ammoCount]; };
|
||||||
case "backpack": { (backpackContainer _unit) addMagazineCargoGlobal [_classname, 1]; };
|
case "backpack": { (backpackContainer _unit) addMagazineCargoGlobal [_classname, _ammoCount]; };
|
||||||
case "uniform": { (uniformContainer _unit) addMagazineCargoGlobal [_classname, 1]; };
|
case "uniform": { (uniformContainer _unit) addMagazineCargoGlobal [_classname, _ammoCount]; };
|
||||||
default { _unit addMagazineGlobal _classname; };
|
default {_unit addMagazine [_classname, _ammoCount]; };
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
_addedToPlayer = false;
|
_addedToPlayer = false;
|
||||||
_pos = _unit modelToWorldVisual [0,1,0.05];
|
_pos = _unit modelToWorldVisual [0,1,0.05];
|
||||||
_unit = createVehicle ["WeaponHolder_Single_F",_pos,[],0,"NONE"];
|
_unit = createVehicle ["WeaponHolder_Single_F",_pos,[],0,"NONE"];
|
||||||
_unit addMagazineCargoGlobal [_classname, 1];
|
_unit addMagazineCargoGlobal [_classname, _ammoCount];
|
||||||
_unit setPosATL _pos;
|
_unit setPosATL _pos;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user