Installation
Item, admin access and the ox_inventory bridge.
Dependencies
| Resource | Required | Used for |
|---|---|---|
| ox_lib | Yes | UI, callbacks, skill checks |
| oxmysql | Yes | Storing consumables |
| ox_inventory | Yes | The consumable item |
| sleepless_prompts | Yes | Hold and share prompts |
| ox_target | Yes | Taking servings from shared boxes |
qbx_core, qb-core or es_extended | Optional | Hunger, thirst and stress |
Setup
filo_consumables in your resources folder and ensure it after ox_lib, oxmysql, ox_inventory and sleepless_prompts.Give your admins access to the panel:
add_ace group.admin filo_consumables.admin allowRegister the one item in ox_inventory/data/items.lua:
['filo_consumable'] = {
label = 'Consumable',
weight = 0,
stack = true,
close = true,
consume = 0,
server = { export = 'filo_consumables.useItem' },
},Config.Branding, then start the server. The table is created automatically, and three examples are added on the first start (Config.SeedExamples).The panel's Integration tab shows whether the item and the bridge are in place.
How items are stored
Every consumable is the filo_consumable item with its own metadata:
| Metadata | Shown by ox_inventory as |
|---|---|
label | The item name |
description | The description under it |
imageurl / image | The item image (a URL, or a file from your inventory:imagepath) |
weight | Added on top of the base item weight (0) |
durability + uses | The bar on multi-use items (bites or sips left) |
consumable | The spawn name the script looks it up by |
ox_inventory bridge
Without the bridge, exports.ox_inventory:AddItem(source, 'mac_n_cheese', 1) fails with invalid_item,
and other scripts have to use the exports instead.
With it, every ox_inventory function that takes an item name also accepts a consumable's spawn
name or label: server and client exports (AddItem, RemoveItem, SetItem, GetItemCount,
Search and more), stashes and drops with starting items, and /giveitem, /removeitem and /setitem.
A name is only resolved when it isn't a real item and the consumable exists, so everything else works
as before.
To apply it:
- Copy
filo_consumables/install/filoconsumables/shared.luatoox_inventory/modules/filoconsumables/shared.lua. - Make the small edits to ox_inventory's inventory, items and command files listed step by step in
install/ox_inventory.md. - Restart ox_inventory, then filo_consumables.
Redo this whenever you update ox_inventory.
Shops and crafting recipes are loaded from data files and need real items. Use
name = 'filo_consumable' with metadata = exports.filo_consumables:GetMetadata('mac_n_cheese').