Koja Scripts

Exports & Commands

New exports (getClothing, IsSlotLocked, getClothingState, getStatus, throwItem, fastAction, requestTrade), the upstream ox_inventory API, commands, keybinds and the appearance events Koja listens to.

Exports & Commands

Every upstream ox_inventory export, event, callback and hook keeps working. This page lists what Koja adds, how it changes upstream behaviour, and every command and keybind.

New server exports

getClothing

Returns the clothing a player wears.

local state = exports.ox_inventory:getClothing(source)
Returns
{
    enabled = true,
    gender = 'male',
    slots = {
        {
            key = 'torso', label = 'Torso', icon = 'layers', column = 'left',
            kind = 'component', id = 11,
            item = { name = 'clothing', slot = 7, metadata = { ... }, ... }, -- nil when empty
            wear = { drawable = 4, texture = 0, ... },                        -- what the ped wears
        },
        -- one entry per slot of clothing.slots
    },
}

IsSlotLocked

true when the slot exists but needs a backpack.

if exports.ox_inventory:IsSlotLocked(source, slot) then
    -- do not put anything here
end

The first argument is anything exports.ox_inventory:GetInventory accepts (player id or inventory).

New client exports

ExportReturnsWhat it does
getClothingState()tableThe local clothing state (same shape as getClothing)
getStatus(){ health, armor, hunger, thirst }Values 0–100, as shown in the clothes panel
throwItem(slot){ ok, error? }Starts the aim of a throw for the item in that slot
fastAction(id, data?)—Runs a fast action: handsup, undress, hanger, trade
requestTrade(serverId?, slot?){ ok, error? }Sends a trade request. Without serverId, to the closest player
Client
-- open a trade with the closest player, offering slot 3
exports.ox_inventory:requestTrade(nil, 3)

-- undress the player
exports.ox_inventory:fastAction('undress')

Upstream exports

All exports of ox_inventory 2.48.0 are unchanged. The ones you use most:

Server: AddItem, RemoveItem, CanCarryItem, CanCarryAmount, CanCarryWeight, CanSwapItem, GetItem, GetItemCount, Search, GetSlot, GetSlotWithItem, GetSlotIdWithItem, GetSlotsWithItem, GetSlotIdsWithItem, GetEmptySlot, GetSlotForItem, SetMetadata, SetDurability, SetSlotCount, SetItem, SetMaxWeight, GetInventory, GetInventoryItems, GetInventories, GetContainerFromSlot, GetCurrentWeapon, RegisterStash, CreateTemporaryStash, RegisterShop, CustomDrop, CreateDropFromPlayer, ClearInventory, ConfiscateInventory, ReturnInventory, RemoveInventory, UpdateVehicle, SwapSlots, InspectInventory, forceOpenInventory, setPlayerInventory, registerHook, removeHooks, Items, ItemList, setContainerProperties.

Client: openInventory, closeInventory, openNearbyInventory, useItem, useSlot, getCurrentWeapon, setStashTarget, giveItemToTarget, Search, GetItemCount, GetPlayerItems, GetPlayerWeight, GetPlayerMaxWeight, GetSlotWithItem, GetSlotIdWithItem, GetSlotsWithItem, displayMetadata, notify, suppressItemNotifications, weaponWheel, setGetPlayerNameMethod, Items, ItemList, Keyboard, Progress, CancelProgress, ProgressActive.

See the ox_inventory documentation for their arguments.

What behaves differently

Upstream APIKoja change
AddItem, GetEmptySlot, GetSlotForItem, CanCarryItemNever use locked (backpack) slots of a player
Moving items (swapItems)Moves into locked slots are rejected
Player max weightinventory:weight + the weight of the worn backpack
Item useItems marked Hidden / disabled in the admin panel cannot be used or created
Shops (openInventory('shop', ...), RegisterShop)Open the basket panel; paymentMethods and interaction are read from the shop definition
Crafting (craftItem)Progress runs inside the crafting panel; never crafts into a locked slot

Events Koja listens to

EventSideWhat happens
illenium-appearance:server:saveAppearanceServerWorn clothing items follow the saved appearance (externalAppearance)
fivem-appearance:saveServerSame, for fivem-appearance
illenium-appearance:client:reloadSkinClientClothing is synced again
esx:onPlayerSpawn, QBCore:Client:OnPlayerLoaded, playerSpawnedClientClothing is synced again after spawning

Commands

CommandWhoWhat it does
/invadmin [page]StaffOpens the admin panel. Name from admin.command
/additem (/giveitem) [id] [item] [count] [type]group.adminGives an item
/removeitem [id] [item] [count] [type]group.adminRemoves an item
/setitem [id] [item] [count] [type]group.adminSets the item count
/viewinv [invId]group.adminInspects an inventory read-only
/clearinv [invId]group.adminWipes an inventory
/takeinv [id]group.adminConfiscates a player's inventory
/restoreinv (/returninv) [id]group.adminGives a confiscated inventory back
/saveinv [lock]group.adminSaves all pending changes to the database
/clearevidence [locker]Police bossClears an evidence locker
/stealEveryoneSearches the nearest player (when allowed). Needs inventory:enablestealcommand
convertinventory [esx|esxproperty]ConsoleUpstream conversion of old ESX inventories
clearActiveIdentifier [identifier]ConsoleUpstream workaround for a stuck inventory

Keybinds

All keybinds can be rebound by players in Settings → Key Bindings → FiveM. The default only applies to players who never changed it.

KeybindDefaultWhat it does
invF2Opens the inventory (inventory:keys[1])
inv2KOpens the other inventory: trunk, dumpster, glovebox (inventory:keys[2])
hotbarTABShows the hotbar (inventory:keys[3])
hotkey1 … hotkey51 … 5Uses the item in pocket 1–5
reloadweaponRReloads the weapon
koja_throw_weaponMiddle mouseHold to aim and charge, release to throw the weapon in hand
koja_trade_acceptYAccepts a trade request (inventory closed)
koja_trade_declineNDeclines a trade request (inventory closed)
koja_invadminnoneOpens the admin panel. Registered only when admin.key is set

While aiming a thrown item: left mouse throws, right mouse cancels (throw.keys).