ai-inventory
Grid inventory with item sizes, quick slots, ground drops, stashes, trunks and gloveboxes, shops, crafting and weapons. Answers the ox_inventory and qb-inventory APIs.
ai-inventory is a grid inventory: every item takes a number of cells (a phone 1x1, a rifle 4x2) and can be turned while dragging. It holds the player's items, the ground, stashes, vehicle trunks and gloveboxes, shops and crafting benches, and weapons as items.
What it does in the game
- The grid. Every inventory has the same number of columns; only the rows and the weight limit differ. Items have a size in cells and a weight; the inventory refuses what does not fit or is too heavy.
- The screen (F2): the character's clothes in two columns around the character, the five quick slots, the player's grid, and the second inventory (ground, trunk, stash, shop, bench) on the right. Clicking a piece of clothing takes it off or puts it back on.
- Quick slots. Five slots of their own (not grid cells). Keys 1 to 5 use them; TAB shows them as a bar at the bottom.
- Using items. Double click, or the item menu. Food and drink play an animation, fill hunger and thirst (ai-hud) and are used up. The server checks the item is still there after the animation.
- Give, drop, split. The item menu gives to the nearest player, drops on the ground or splits a stack.
- Ground drops. Dropped items lie in a bag on the ground. Dropping next to your own bag adds to it. Bags disappear after some untouched minutes.
- Trunks and gloveboxes. F2 at the back of a vehicle opens its trunk (when unlocked); inside a vehicle, its glovebox. An owned vehicle's trunk stays with the vehicle, whatever plate it wears; any other vehicle's trunk is temporary.
- Stashes. Storage at fixed places, shared or one per character, open to everyone or to some jobs and gangs.
- Shops. Places with products and prices, a map blip and an optional NPC, paid from cash then bank (as set).
- Crafting benches. Recipes that turn materials into items over a few seconds.
- Weapons. Weapons are items with a serial number. Ammo is an item; R reloads from it. Attachments (flashlight, suppressor...) are items that go onto the held weapon. GTA's weapon wheel is off by default: weapons come from the quick slots.
- Rarities. Items can belong to a rarity whose colour tints their box.
- Weapons from elsewhere. A weapon not given by ai-inventory is taken from the player.
Installation
The AI Core txAdmin recipe installs it. By hand: put the folder in resources/[ai]/ and add ensure ai-inventory to server.cfg after ensure ai-core. It needs ai-core and the database:
add_convar_permission ai-inventory read mysql_connection_stringThe table ai_inventory_inventories is created on the first start. Item pictures go in the resource's dist/web/images folder (the ox_inventory pictures ship with it).
Remove ox_inventory and qb-inventory: ai-inventory answers their names.
Panel settings
Open the admin panel (F10) and pick Inventory.
Items tab
Every item that exists in the game. Each item is one record; its key (water, lockpick) is the item name scripts use. The script ships with 242 items (taken from ox_inventory's lists).
Item: the name players see and what kind of item it is.
| Setting | What it changes | Values | Default for a new item |
|---|---|---|---|
| Name | The name players see. | up to 48 characters | |
| Description | A line under the name. | up to 240 characters | |
| Kind | Item, Weapon (held when used), Ammo (reloads the held weapon), Attachment (goes on the held weapon). | Item / Weapon / Ammo / Attachment | Item |
| Rarity | Tints the item's box with a rarity's colour (Rarities tab). Empty: a plain box. | a rarity | none |
| Picture | File name in the images folder (water.png) or a full https link. Empty shows an icon. | up to 200 characters | |
| Other names | Names other scripts use for this item (for example pistol_ammo), so they still work. | up to 30 names |
Size and weight: how many cells the item takes and how heavy it is.
| Setting | What it changes | Values | Default |
|---|---|---|---|
| Width | Cells from left to right. Players can turn an item while dragging it. | 1 to 8 cells | 1 |
| Height | Cells from top to bottom. | 1 to 8 cells | 1 |
| Weight | Grams per unit (1000 g = 1 kg). | 0 to 1,000,000 g | 100 |
| Stack size | Most units in one stack. 1 makes every unit separate, for items with their own data. | 1 to 100,000 | 10 |
Using: what happens when a player uses the item.
| Setting | What it changes | Values | Default |
|---|---|---|---|
| Can be used | Off: using does nothing unless a script handles this item. | on / off | off |
| Used up per use | Units removed each time it is used. 0 keeps it. | 0 to 1000 | 0 |
| Close the inventory | Closes the inventory screen when the item is used. | on / off | off |
| Animation | Played while using. | None / Eat / Drink / Bandage / Put on armour | None |
| Use time | How long the animation plays before the item takes effect. | 0 to 60,000 ms | |
| Hunger | Added to the player's hunger when used (minus lowers it). Needs a HUD that tracks needs. | -100 to 100 | |
| Thirst | Added to thirst. | -100 to 100 | |
| Stress | Added to stress. | -100 to 100 |
Weapon: only for weapons and attachments.
| Setting | What it changes | Values | Default |
|---|---|---|---|
| Ammo item | Item name the weapon loads (for example ammo-9). | an item name | |
| Thrown | Grenades and the like: the stack count is the ammo. | on / off | off |
| Attachment hashes | GTA component names this attachment can be (COMPONENT_AT_PI_FLSH); the first one the held weapon takes is used. | up to 20 names |
Deleting an item: players who have it keep a stack nobody can use.
Rarities tab
Colour groups items belong to. Shipped: Common, Uncommon, Rare, Epic, Legendary, Medical, Special.
| Setting | What it changes | Values |
|---|---|---|
| Name | The rarity's name. | up to 32 characters |
| Colour | The box of every item of this rarity is tinted with it. | a colour |
Deleting a rarity: its items lose their colour.
Shops tab
Places where players buy items. The script ships with 45 shops (24/7, LTD, Rob's Liquor, hardware stores, Ammu-Nation and others, plus job shops for police and EMS).
Shop: where the shop is and who may buy there.
| Setting | What it changes | Values | Default for a new shop |
|---|---|---|---|
| Shop name | The name players see. | up to 48 characters | |
| Place | Stand where players should open it and use your position. | a point | |
| Reach | How close a player must be to open it. | 0.5 to 30 m | 2 |
| Jobs | Only members of these jobs can use it. Leave jobs and gangs empty for everyone. | job names | empty |
| Gangs | Members of these gangs can use it too. | gang names | empty |
| Only on duty | Job members must be on duty in that job. | on / off | off |
| Map blip | Shows the shop on the map. | on / off | on |
| Blip look | Picture, colour and size of the blip (when the blip is on). | sprite, colour, size | |
| Paid from | Money accounts tried in order. | up to 5 accounts | cash, bank |
Products: items the shop sells and their price per unit. Up to 100 rows, each Item and Price (0 to 100,000,000 $).
NPC: a clerk standing at the shop. Model (empty for none, seen within 50 m), What it does (an idle animation), Where it stands (floor spot and facing; without one it stands on the shop's point).
Stashes tab
Storage at fixed places. Shipped: one Police Locker.
| Setting | What it changes | Values | Default for a new stash |
|---|---|---|---|
| Stash name | The name players see. | up to 48 characters | |
| Place | Where players open it. | a point | |
| Reach | How close a player must be. | 0.5 to 30 m | 1.5 |
| Jobs, Gangs, Only on duty | Who may open it (as for shops). | everyone | |
| One per character | On: every character has its own contents. Off: everyone who may open it shares one. | on / off | off |
| Rows | Rows of cells; the width is the Columns setting. | 1 to 50 | 6 |
| Weight limit | Grams. 0 means no limit. | 0 to 10,000,000 g | 100,000 |
Deleting a stash: the items stored in it stay in the database.
Crafting tab
Benches where players turn materials into items. Shipped: one Workbench.
Bench: Bench name, Place, Reach (default 1.5 m), Jobs, Gangs, Only on duty, as for shops.
Recipes: up to 50 rows.
| Setting | What it changes | Values | Default for a new row |
|---|---|---|---|
| Makes | The item made. | an item name | lockpick |
| Amount | How many are made. | 1 to 1000 | 1 |
| Time | How long it takes. | 0 to 600 s | 5 |
| Materials | What it uses, as item:count separated by commas: scrapmetal:3, paperbag:1. | up to 400 characters | scrapmetal:3 |
Settings tab
How big the inventories are.
| Card | Setting | What it changes | Values | Default |
|---|---|---|---|---|
| Grid | Columns | Cells per row in every inventory. Items that no longer fit move to free cells; an inventory too full for that gets extra rows. | 6 to 14 | 8 |
| Grid | No GTA weapon wheel | GTA's weapon wheel and switching weapons with the mouse wheel stay off: weapons are taken from the quick slots (1-5). | on / off | on |
| Player inventory | Rows | What a character can carry, in rows. | 1 to 50 | 20 |
| Player inventory | Weight limit | Grams; 0 = no limit. | 0 to 10,000,000 g | 40,000 |
| Ground | Rows | Size of a bag on the ground. | 1 to 50 | 6 |
| Ground | Weight limit | Grams; 0 = no limit. | 0 to 10,000,000 g | 1,000,000 |
| Ground | Disappears after | Items on the ground disappear when nobody touched them for this long. | 1 to 240 min | 15 |
| Ground | Bags per player | How many bags one character may have on the ground at a time. | 1 to 100 | 10 |
| Trunk | Rows | The trunk of every vehicle. | 1 to 50 | 5 |
| Trunk | Weight limit | Grams; 0 = no limit. | 0 to 10,000,000 g | 80,000 |
| Glovebox | Rows | The glovebox of every vehicle. | 1 to 50 | 2 |
| Glovebox | Weight limit | Grams; 0 = no limit. | 0 to 10,000,000 g | 10,000 |
A change of columns, rows or weight reaches open screens at once.
Commands
None of its own. Admins give and take items with ai-admin's item tools.
Keybinds
| Default key | What it does | Name in GTA settings |
|---|---|---|
| F2 | Opens the inventory (with the ground, trunk or glovebox next to you) or closes it | Open the inventory |
| TAB | Shows or hides the quick slots bar | Show / hide the quick slots bar |
| 1 to 5 | Uses the item in that quick slot | Use the item in quick slot 1 (to 5) |
| R | Reloads the held weapon from an ammo item | Reload the weapon |
In the screen: drag to move, turn the item while dragging, double click to use, right click for the item menu, Escape or F2 to close.
Works with other scripts
- Stands in for ox_inventory (
provide, ox_inventory 2.44 API) and qb-inventory (provide, 2.0 API): their exports answer, so ox and QB scripts give, take and check items here. See the developer page for what is and is not answered. - AI Core's inventory layer. Every
ai-*script and the ESX / QB bridge give and take items through AI Core, which calls ai-inventory. - You can replace it. AI Core has adapters for other inventories (tgiann-inventory, codem-inventory, core_inventory, origen_inventory, jaksam_inventory and more), each with its own limits. A supported inventory makes ai-inventory unneeded: AI Core tells you in the console to remove it. See Compatibility.
Known limits
- One use at a time per player.
- A new ground bag is limited to one per second per player, the panel's Bags per player, and 50 per map area. Crafting results and script drops skip these limits.
- Items cannot be dropped from inside a vehicle.
- ox_inventory's hooks,
RegisterShopwith ox's shape, and confiscation are not answered (shops come from the panel or ai-inventory's ownRegisterShop).