mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Added a function that will add the passed item to the unit or place it in a ground holder if the unit has no space.
This commit is contained in:
parent
0daa029622
commit
e06e7a2a51
@ -11,6 +11,7 @@ PREP(addLineToDebugDraw);
|
||||
PREP(addMapMarkerCreatedEventHandler);
|
||||
PREP(addScrollWheelEventHandler);
|
||||
PREP(addSetting);
|
||||
PREP(addToInventory);
|
||||
PREP(adminKick);
|
||||
PREP(ambientBrightness);
|
||||
PREP(applyForceWalkStatus);
|
||||
|
64
addons/common/functions/fnc_addToInventory.sqf
Normal file
64
addons/common/functions/fnc_addToInventory.sqf
Normal file
@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Author: Garth 'L-H' de Wet
|
||||
* Adds an item,weapon,magazine to the unit's inventory
|
||||
* or places it in a weaponHolder if no space.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Unit (OBJECT)
|
||||
* 1: Classname (String)
|
||||
* 2: Type (String)
|
||||
*
|
||||
* Return Value:
|
||||
* Array:
|
||||
* 0: Added to player (Bool)
|
||||
* 1: weaponholder (OBJECT)
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
EXPLODE_3_PVT(_this,_unit,_classname,_type);
|
||||
private "_addedToPlayer";
|
||||
_addedToPlayer = true;
|
||||
|
||||
switch (_type) do {
|
||||
case "weapon": {
|
||||
if (!isClass(ConfigFile >> "CfgWeapons" >> _classname)) exitWith {};
|
||||
if (_unit canAdd _classname) then {
|
||||
_unit addWeaponGlobal _classname;
|
||||
} else {
|
||||
_addedToPlayer = false;
|
||||
_pos = _unit modelToWorld [0,1,0.05];
|
||||
_unit = createVehicle ["WeaponHolder_Single_F",_pos,[],0,"NONE"];
|
||||
_unit addWeaponCargoGlobal [_classname,1];
|
||||
_unit setPosATL _pos;
|
||||
};
|
||||
};
|
||||
case "magazine": {
|
||||
if (!isClass(ConfigFile >> "CfgMagazines" >> _classname)) exitWith {};
|
||||
if (_unit canAdd _classname) then {
|
||||
_unit addMagazineGlobal _classname;
|
||||
} else {
|
||||
_addedToPlayer = false;
|
||||
_pos = _unit modelToWorld [0,1,0.05];
|
||||
_unit = createVehicle ["WeaponHolder_Single_F",_pos,[],0,"NONE"];
|
||||
_unit addMagazineCargoGlobal [_classname, 1];
|
||||
_unit setPosATL _pos;
|
||||
};
|
||||
};
|
||||
case "item": {
|
||||
if (!isClass(ConfigFile >> "CfgWeapons" >> _classname)) exitWith {};
|
||||
if (_unit canAdd _classname) then {
|
||||
_unit addItem _classname;
|
||||
} else {
|
||||
_addedToPlayer = false;
|
||||
_pos = _unit modelToWorld [0,1,0.05];
|
||||
_unit = createVehicle ["WeaponHolder_Single_F",_pos,[],0,"NONE"];
|
||||
_unit addItemCargoGlobal [_classname,1];
|
||||
_unit setPosATL _pos;
|
||||
};
|
||||
};
|
||||
default {diag_log format ["ACE: Incorrect item type passed to %1, passed: %2",QFUNC(AddToInventory),_type];};
|
||||
};
|
||||
|
||||
[_addedToPlayer,_unit]
|
Loading…
Reference in New Issue
Block a user