AI Core

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:

env.cfg
add_convar_permission ai-inventory read mysql_connection_string

The 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.

SettingWhat it changesValuesDefault for a new item
NameThe name players see.up to 48 characters
DescriptionA line under the name.up to 240 characters
KindItem, Weapon (held when used), Ammo (reloads the held weapon), Attachment (goes on the held weapon).Item / Weapon / Ammo / AttachmentItem
RarityTints the item's box with a rarity's colour (Rarities tab). Empty: a plain box.a raritynone
PictureFile name in the images folder (water.png) or a full https link. Empty shows an icon.up to 200 characters
Other namesNames 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.

SettingWhat it changesValuesDefault
WidthCells from left to right. Players can turn an item while dragging it.1 to 8 cells1
HeightCells from top to bottom.1 to 8 cells1
WeightGrams per unit (1000 g = 1 kg).0 to 1,000,000 g100
Stack sizeMost units in one stack. 1 makes every unit separate, for items with their own data.1 to 100,00010

Using: what happens when a player uses the item.

SettingWhat it changesValuesDefault
Can be usedOff: using does nothing unless a script handles this item.on / offoff
Used up per useUnits removed each time it is used. 0 keeps it.0 to 10000
Close the inventoryCloses the inventory screen when the item is used.on / offoff
AnimationPlayed while using.None / Eat / Drink / Bandage / Put on armourNone
Use timeHow long the animation plays before the item takes effect.0 to 60,000 ms
HungerAdded to the player's hunger when used (minus lowers it). Needs a HUD that tracks needs.-100 to 100
ThirstAdded to thirst.-100 to 100
StressAdded to stress.-100 to 100

Weapon: only for weapons and attachments.

SettingWhat it changesValuesDefault
Ammo itemItem name the weapon loads (for example ammo-9).an item name
ThrownGrenades and the like: the stack count is the ammo.on / offoff
Attachment hashesGTA 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.

SettingWhat it changesValues
NameThe rarity's name.up to 32 characters
ColourThe 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.

SettingWhat it changesValuesDefault for a new shop
Shop nameThe name players see.up to 48 characters
PlaceStand where players should open it and use your position.a point
ReachHow close a player must be to open it.0.5 to 30 m2
JobsOnly members of these jobs can use it. Leave jobs and gangs empty for everyone.job namesempty
GangsMembers of these gangs can use it too.gang namesempty
Only on dutyJob members must be on duty in that job.on / offoff
Map blipShows the shop on the map.on / offon
Blip lookPicture, colour and size of the blip (when the blip is on).sprite, colour, size
Paid fromMoney accounts tried in order.up to 5 accountscash, 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.

SettingWhat it changesValuesDefault for a new stash
Stash nameThe name players see.up to 48 characters
PlaceWhere players open it.a point
ReachHow close a player must be.0.5 to 30 m1.5
Jobs, Gangs, Only on dutyWho may open it (as for shops).everyone
One per characterOn: every character has its own contents. Off: everyone who may open it shares one.on / offoff
RowsRows of cells; the width is the Columns setting.1 to 506
Weight limitGrams. 0 means no limit.0 to 10,000,000 g100,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.

SettingWhat it changesValuesDefault for a new row
MakesThe item made.an item namelockpick
AmountHow many are made.1 to 10001
TimeHow long it takes.0 to 600 s5
MaterialsWhat it uses, as item:count separated by commas: scrapmetal:3, paperbag:1.up to 400 charactersscrapmetal:3

Settings tab

How big the inventories are.

CardSettingWhat it changesValuesDefault
GridColumnsCells 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 148
GridNo GTA weapon wheelGTA's weapon wheel and switching weapons with the mouse wheel stay off: weapons are taken from the quick slots (1-5).on / offon
Player inventoryRowsWhat a character can carry, in rows.1 to 5020
Player inventoryWeight limitGrams; 0 = no limit.0 to 10,000,000 g40,000
GroundRowsSize of a bag on the ground.1 to 506
GroundWeight limitGrams; 0 = no limit.0 to 10,000,000 g1,000,000
GroundDisappears afterItems on the ground disappear when nobody touched them for this long.1 to 240 min15
GroundBags per playerHow many bags one character may have on the ground at a time.1 to 10010
TrunkRowsThe trunk of every vehicle.1 to 505
TrunkWeight limitGrams; 0 = no limit.0 to 10,000,000 g80,000
GloveboxRowsThe glovebox of every vehicle.1 to 502
GloveboxWeight limitGrams; 0 = no limit.0 to 10,000,000 g10,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 keyWhat it doesName in GTA settings
F2Opens the inventory (with the ground, trunk or glovebox next to you) or closes itOpen the inventory
TABShows or hides the quick slots barShow / hide the quick slots bar
1 to 5Uses the item in that quick slotUse the item in quick slot 1 (to 5)
RReloads the held weapon from an ammo itemReload 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, RegisterShop with ox's shape, and confiscation are not answered (shops come from the panel or ai-inventory's own RegisterShop).

On this page