So, you want to find out about items - huh?
Cool, so how exactly does an "item" work? Well, an item in this sense is just an abstract data structure, more specifically a table of attributes which make up the item.
These attributes are returned from the database and cached by the server and each client. The structure of an item might look a little like this:
["name"] = "pistol",
["label"] = "Pistol",
["itemid"] = 453432689,
["weight"] = 10,
["stackable"] = false,
["durability"] = 2419200,
["description"] = "Standard handgun. A .45 caliber combat pistol with a magazine capacity of 12 rounds that can be extended to 16.",
["seize"] = true
Now, an item in your inventory may look slightly different. This is because storing some of the above metadata for each item would be a waste of memory and storage in your database. Instead, inventories store only critical item data such as the
name field. So if you're looking for an item
description, you should use an export like GetItemAttribute to fetch it rather then storing it with each item in every inventory ever.
Phew, that was quite a mouthful. Now let's find out how to add your own items.
Creating an Item
In order to create an item, you will have to add a new row to the
items database table. We recommend using HeidiSQL to manage database state. Once the item has been added to the database, there's a few small things left to do.
If you are adding a new weapon item, the
itemid field must be the Jenkins hash decimal equivelant of the weapon name. Otherwise, the item will not be recognised as a weapon and you may find unexpected results.
You will have to add all necessary configuration options to resources such as
px_injuries for intended behaviour, otherwise the weapon may not be usable or not injure your character in the case of
You must (or rather should) add a meaningful image for the item. You can do this by navigating to the
/px_inventory/ui/images directory where you will find all item images and dropping in the image file.
For the image to show, it must be named exactly the same as in the database and be in a
.png format. We recommend a resolution of
150x150 for all items, as anything beyond this will make no noticable difference in the UI. Larger file sizes mean longer download times, and ultimately poop stuff.
Also, for the sake of your eyes, ensure the background is transparent.
Once the item has been added, you will need to either restart your server or use the
refreshItems console command to clear the item cache and fetch an updated dictionary from the database. If your item image is not working, make sure to use the
refresh command and
restart px_inventory (or again, restart your server).