Koja Scripts

Client exports

Client exports of koja-inventory-v2: opening inventories, reading the player's items, clothing sync and frisk checks.

Client exports

Call them on exports['koja-inventory-v2'].

Always available

ExportDescription
SyncClothing()Reads what the character wears right now and syncs it into the clothing slots immediately, without waiting for the watcher. Call it after your script changes clothes.
RegisterSearchCheck(function() end)Client side of the frisk check for the local player. Return true to allow being frisked, false to block, nil for the default checks.
IsSearching()true while the local player is frisking someone.
After a job wardrobe
SetPedComponentVariation(PlayerPedId(), 11, 55, 0, 0)
exports['koja-inventory-v2']:SyncClothing()

Native mode (Config.Ox.enabled = false)

ExportDescription
OpenInventory(type, data)'stash', name, 'player', serverId, or a payload table like { type = 'shop', name = 'general', index = 1 }.
CloseInventory()Closes the inventory.
IsOpen()true while the inventory is open.
GetPlayerItems(){ id, name, count, metadata, container } for every item the player carries.
OpenNearbyInventory()Frisks the player in front, same as /frisk.
GetCurrentWeapon()The drawn weapon or nil.

ox mode (Config.Ox.enabled = true, default)

The client answers the ox_inventory client API, both as exports['koja-inventory-v2'] and as exports.ox_inventory:

openInventory, closeInventory, openNearbyInventory, Items, Search, GetItemCount, GetPlayerItems, GetPlayerWeight, GetPlayerMaxWeight, GetSlotWithItem, GetSlotsWithItem, GetSlotIdWithItem, GetSlotIdsWithItem, getCurrentWeapon, useSlot, useItem, giveItemToTarget(serverId, slot, count), weaponWheel(state), IsOpen, OpenInventory, CloseInventory.

giveItemToTarget sends a normal give offer: the receiver gets the accept or decline window.

State bags and events

NameSideDescription
LocalPlayer.state.invOpenclienttrue while the inventory is open.
LocalPlayer.state.invBusyclienttrue while a progress bar (use, craft, repair) runs.
ox_inventory:currentWeaponclient eventFired with the weapon data when a weapon is drawn, nil when holstered.
koja-inventory-v2:client:slotChangedclient eventkey, item | nil when one of your equipment slots changes.
koja-inventory-v2:client:settingsChangedclient eventList of config paths changed in the admin panel.