Jump to content
austin_medic

[RELEASE] Inventory System

Recommended Posts

Inventory System

 

by

austin(medic)

 

Description:

 

 

This inventory system allows you to define some custom objects that you can use, without them actually existing in the game itself.

 

 

Installation:

 

 

Simply merge the stuff in the scripts folder, merge description.ext and drag over the defines.hpp if one doesn't already exist, and the inventory.hpp. Drag the inventory_functions folder into the main directory. An example mission is also included.

 

 

Usage:

 

 

How can I bring up the inventory menu?

 

 

This can be done by adding a simple action to the init.sqf:

player addAction["Inventory",{createDialog "AUSMD_inventory";}];

How to Add your own Items:

 

 

Add your item and its weight into the master array (will be inside init.sqf).

e.g

masterArray = 
[
	["Item1",2],
	["Item2",1],
	["myNewItem",5],
	["Default",0]
];

If you want your item to have functionality when its used, you'll need to go into the

functions folder and modify the useItem script.

 

Add your item's functionality into the code, you could also put in a call/spawn/execVM to another script that will run the code if you like instead of putting it here.

e.g


switch(_item) do
{
	case "Item1": {hint "Item1 Used";};
	case "Item2": {hint "Item2 Used";};
	case "myNewItem": {hint "code-to-run-goes-here";};
	default {hint "Item usage not defined.";};
};

How can I give an item on the ground functionality?

 

You can pass some parameters for the item you want on the ground to the droppedItem function. This should be done after the mission has started (e.g spawn a sleep followed by the below code.)

 

e.g

 

[container that will act as the object to get the action, your item, amount of the item]

nul = [] spawn {sleep 1;[myBox,"myNewItem",2] call AUSMD_fnc_droppedItem;};
How do I add things into the Inventory through a script with no containers?
 
Simply use the provided addInventory function.
 
e.g
 
[item,amount,mode(0 = add to current amount of item in inventory, 1 = set inventory amount to the amount here)]
["myNewItem",1,0] call AUSMD_fnc_addInventory;

 

 

Download:

 

Dropbox

Armaholic

 

 

It's a bit incomplete currently and I'll be adding some other stuff to it for mission makers to have more control over certain aspects (such as dropping items and what type of object will be used, currently script just uses plastic boxes for everything).

 

  • Like 1

Share this post


Link to post
Share on other sites

Just a little note that the version that went up earlier was bugged and is now fixed, dropbox version should work correctly now.

Share this post


Link to post
Share on other sites

so does this add an entry with picture to the default inventory listbox?

No its impossible to add anything into the default menu without mods, at least to my knowledge. This uses a custom menu for the custom items. Both are entirely seperate from each other

  • Like 1

Share this post


Link to post
Share on other sites

Could someone perhaps help me? I can't seem to add items to my inventory. I added a player to the map and added this to his init  

player addAction["Inventory",{createDialog "AUSMD_inventory";}];
["myNewItem",1,0] call AUSMD_fnc_addInventory; 

which allows me to view my inventory just fine through the action menu but there is nothing in it.

 

My masterArray looks like this 

masterArray =
[
	["Item1",2],
	["Item2",1],
	["myNewItem",5],
	["Default",0]
];

No errors are being thrown  and I can access all the functions but I can't figure out why I can't add anything to my inventory

Share this post


Link to post
Share on other sites

did you try closing/reopening the dialog window after you added the item? The dialog window doesn't refresh with any new items added until its reopened again

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

×