Cube Scripts

Ox Inventory REDESIGNED

A slot-based inventory with item metadata for "item uniqueness", redesigned UI and extra functions.

A slot-based inventory with item metadata for "item uniqueness", with a redesigned interface and additional functions on top of the original resource.

Note

This documentation is based on the official ox_inventory docs, extended with the functions added by this redesign.

Is a REDESIGNED, so is open-source, expected my functions, my web.

Warning

If you are replacing a built-in framework inventory there will be compatibility errors. If you are unwilling or incapable of resolving incompatibilities, do not install this resource.

Open source#

Almost everything ships open source and is yours to edit — the Lua modules, the item data, the shops, the bridges and the config are all readable and editable.

Two things are protected, and only to prevent the resource from being leaked and resold:

  • The web / NUI build (the redesigned interface itself).
  • A small escrowed file holding a few internal functions.

Everything else behaves exactly like the original resource, so any tweak you could make to ox_inventory you can still make here.

Tip

Need a change inside a protected part? Open a ticket on our Discord — we take feature requests and we can often ship it in the next update.

Installation#

1

Download the resource#

After your purchase, the resource is delivered to your CFX account. Download it from the CFX Portal, under Granted assets.

Note

Sign in with the same CFX.re account you used at checkout. If the asset is not listed, open a ticket on our Discord and we will look into it.

Unzip the folder into your server's resources directory. There is nothing to build - the resource ships ready to start.

2

Install the dependencies#

These resources are required and must start before the inventory.

3

Install optional dependencies#

These resources aren't required but provide additional functionality.

4

Resource start order#

It's important for your resources to start in a logical order to prevent errors from missing dependencies.

bash
start oxmysql   # this should be one of the first resources
start ox_lib
start framework # the name of your framework (i.e. ox_core, es_extended, qbx_core)
start ox_target
start ox_inventory
5

Config#

Resource configuration is handled using convars.

bash
  ### Shared
 
# Activate specific event handlers and functions (supported: ox, esx, qb, nd)
setr inventory:framework "esx"
 
# Number of slots for player inventories
setr inventory:slots 71
 
# Maximum carry capacity for players, in grams (frameworks may override this)
setr inventory:weight 50000
 
# Integrated support for qtarget/ox_target stashes, shops, etc
# Note: qtarget is deprecated, a future update may drop support (ox_target only, or gated features)
setr inventory:target false
 
# Jobs with access to police armoury, evidence lockers, etc
setr inventory:police ["police", "sheriff"]
 
### Client
 
# The URL to load item images from
setr inventory:imagepath "nui://ox_inventory/web/images"

# The URL to load UI icons from (IconNAME.png)
setr inventory:iconpath "nui://ox_inventory/web/icons"

# Weapons will reload after reaching 0 ammo
setr inventory:autoreload true
 
# Blur the screen while accessing the inventory
setr inventory:screenblur true
 
# Default hotkeys to access primary and secondary inventories, and hotbar
setr inventory:keys ["I", "K", "TAB"]
 
# Enable control action when inventory is open
setr inventory:enablekeys [249]
 
# Weapons must be aimed before shooting
setr inventory:aimedfiring false
 
# Show a list of all nearby players when giving items
setr inventory:giveplayerlist false
 
# Toggle weapon draw/holster animations
setr inventory:weaponanims false
 
# Toggle item notifications (add/remove)
setr inventory:itemnotify true
 
# Disable drop markers and spawn a prop instead
setr inventory:dropprops true
 
# Set the default model used for drop props
setr inventory:dropmodel "prop_med_bag_01b"
 
# Disarm the player if an unexpected weapon is in use (i.e. did not use the weapon item)
setr inventory:weaponmismatch true
 
# Ignore weapon mismatch checks for the given weapon type (e.g. ['WEAPON_SHOVEL', 'WEAPON_HANDCUFFS'])
setr inventory:ignoreweapons ["GADGET_PARACHUTE"]
 
# Suppress weapon and ammo pickups
setr inventory:suppresspickups 1
 
### Server
 
# Compare current version to latest release on GitHub
set inventory:versioncheck false
 
# Stashes will be wiped after remaining unchanged for the given time
set inventory:clearstashes "6 MONTH"
 
# Discord webhook url, used for imageurl metadata content moderation (image embeds)
set inventory:webhook ""

# Logging via ox_lib (0: Disable, 1: Standard, 2: Include AddItem/RemoveItem, and all shop purchases)
set inventory:loglevel 2
 
# Item prices fluctuate in shops
set inventory:randomprices false
 
# Loot will randomly generate inside unowned vehicles and dumpsters
set inventory:randomloot false
 
# Minimum job grade to remove items from evidence lockers
set inventory:evidencegrade 2
 
# Trim whitespace from vehicle plates when checking owned vehicles
setr inventory:trimplate true
 
# Set the contents of randomly generated inventories
# [item name, minimum, maximum, loot chance]
set inventory:vehicleloot [
    # ["cola", 1, 1],
    # ["water", 1, 1],
    # ["garbage", 1, 2, 50],
    # ["panties", 1, 1, 5],
    # ["money", 1, 50],
    # ["money", 200, 400, 5],
    # ["bandage", 1, 1]
]
 
set inventory:dumpsterloot [
    # ["cups", 1, 3, 50],
    # ["scratchcardperdant", 2, 10, 50],
    # ["scratchcard", 2, 1, 40],
    # ["polaroid_camera", 1, 400, 40], 
    # ["cwnotepad", 2, 40, 50]

]
 
# Set items to sync with framework accounts
set inventory:accounts ["money"]

Framework incompatibilities#

  • Any frameworks with their own built-in inventory, item, or weapon systems are expected to have compatibility issues.
  • Money as an item may conflict with banking/account systems.
    • You can sync these values with server.syncInventory in the bridge module for your framework.

If you hit a conflict we have not covered, open a ticket on our Discord with your resource list and the error, and we will help you sort it out.

Using an unsupported framework#

If your framework does not have official support you'll have to implement it yourself. If you're replacing an existing/built-in inventory system this may be complicated, but is a fairly simple task otherwise.

This setup is highly opinionated and rigid, so it's up to your own ability as a developer to make it work.

1

Setup a bridge submodule#

You'll want to set the target framework first - this could be the name, an acronym, or just "custom".

bash
setr inventory:framework "custom"

Copy the ox directory from modules/bridge and give it the name you used above.

The bare minimum functions and event handlers are added here, but you'll need to change them to match your framework; we can't provide any help here. You can refer to the other framework bridges if you need inspiration.

2

Setup database references#

Take a look at modules/mysql/server.lua. You'll need to reference your player/vehicle tables and id columns.

lua
elseif shared.framework == 'custom' then
    playerTable = 'characters' -- table storing player / character data
    playerColumn = 'charid'    -- primary key for identifying the character (i.e. identifier, citizenid, id)
    vehicleTable = 'vehicles'  -- table storing owned vehicle data
    vehicleColumn = 'id'       -- primary key for identifying the vehicle (i.e. plate, vin, id)
end