Jump to content
celludriel

Trying to create cargo unit with inventory

Recommended Posts

Hey,

 

I've been trying to create a 20ft cargo unit with inventory without having to create a mod and add it to it's class.  Sofar I have tried the following stuff

 

First off I tried killzones kid's approach

if(!isDedicated) exitWith {};

params ["_spawnPosition", "_mobileHq"];

_inventory = createVehicle ["Land_Cargo20_military_green_F", _spawnPosition, [], 0, "can_collide"];
_cargo = "Supply500" createVehicle [0,0,0];
_cargo attachTo [_inventory , [0,1.2,0]];
[_mobileHq, _cargo] call MCSRV_fnc_moveInventory;

_inventory

This kinda works since if you know exatly where to point your gun, you get the inventory menu.  But you have to be really really precise.  This could work beter if you could increase the size of the object or something to encapsulate the container.

if(!isDedicated) exitWith {};

params ["_spawnPosition", "_mobileHq"];

_inventory = createVehicle ["Land_Cargo20_military_green_F", _spawnPosition, [], 0, "can_collide"];
_cargo = "B_CargoNet_01_ammo_F" createVehicle [0,0,0];
//hideObjectGlobal  _cargo;
_cargo attachTo [_inventory, [0,1.2,0]];
[_mobileHq, _cargo] call MCSRV_fnc_moveInventory;

_inventory

This works as it creates an item with inventory attached to my unit and I can see it sticking out of the unit and I can manipulate it with the action menu so this "works"

if(!isDedicated) exitWith {};

params ["_spawnPosition", "_mobileHq"];

_inventory = createVehicle ["Land_Cargo20_military_green_F", _spawnPosition, [], 0, "can_collide"];
_cargo = "B_CargoNet_01_ammo_F" createVehicle [0,0,0];
hideObjectGlobal  _cargo;
_cargo attachTo [_inventory, [0,1.2,0]];
[_mobileHq, _cargo] call MCSRV_fnc_moveInventory;

_inventory

Same code but now I hide the object for everyone , and well on the same spot I was able to access the inventory now there is no longer an action menu, so hiding the object doesn't also hide it's model but also it's functionality.

if(!isDedicated) exitWith {};

params ["_spawnPosition", "_mobileHq"];

_inventory = createVehicle ["Land_Cargo20_military_green_F", _spawnPosition, [], 0, "can_collide"];
_cargo = "GroundWeaponHolder" createVehicle [0,0,0];
//hideObjectGlobal  _cargo;
_cargo attachTo [_inventory, [0,1.2,0]];
[_mobileHq, _cargo] call MCSRV_fnc_moveInventory;

_inventory

This was my latest attempt but using this GroundWeaponHolder doesn't show me the inventory action either at the place I expect it to be (aka where the B_CargoNet_01_ammo_F was in my first attempt)

 

So this is the point I need to ask for help since google isn't helping me much :(  Anyone got an idea ?

Share this post


Link to post
Share on other sites

Add a custom action for to the cargo container.

 

player action ["Gear", INVENTORYOBJECT];

 

this will only work if the container is within 5m of the player so make sure your action has a condition for distance from the container. ie (position player) distance INVENTORYOBJECT < 5

  • Like 1

Share this post


Link to post
Share on other sites

Well I got it working this is what I eventualy ended up with, I know the distance condition could be in there but I don't particulary care much at which distance they get the menuoption when they are in the "camp"

if(!isDedicated) exitWith {};

params ["_spawnPosition", "_mobileHq"];

_inventory = createVehicle ["Land_Cargo20_military_green_F", _spawnPosition, [], 0, "can_collide"];
_cargo = "Supply500" createVehicle [0,0,0];
_cargo attachTo [_inventory, [0,0,0]];

[_inventory, ["Open arsenal",	{
					params ["_inventory"];
					_cargo = objNull;
					{
						_cargo = _x;
					} forEach attachedObjects _inventory;
					player action ["Gear", _cargo];
			}]] remoteExec ["addAction", 0, true];

[_mobileHq, _cargo] call MCSRV_fnc_moveInventory;

_inventory

As you can see to make it JIP prove I had to put it all in a remoteExec, the server is the one spawning the container after all.  Hope this would help other people out in the future as well

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×