registerHook using the event name onPreOpenInventory.
Opening your own player inventory never triggers this hook.
Payload
This hook can prevent the inventory from opening by returning
false. The data never leaves the server, so it is a real access control point (job/gang/whitelist gating), not just a UI check.inventoryTypeFilter and inventoryFilter.
Prefer stateless hooks
When a player presses the inventory key, the client preloads the inventories in range (stashes within 3m of a configured location, plus nearby trunks, gloveboxes, shops, dumpsters and drops) before the UI opens, and every preload triggers this hook. Your callback can therefore run several times for the same inventory, and for inventories the player never actually opens. This only affects inventories that have configured coordinates - purely virtual ones, opened programmatically by your own script, are never preloaded. Still, write the callback as a pure check on job/gang/identifier where you can. A one-shot token pattern (authorized[source] = inventoryId, consumed on first match) is racy for a physically placed inventory: a preload can consume the token before the real open reaches the hook, and the open is then denied.
Things to know
Private stashes
Private stashes
jaksam appends
_<ownerCharIdentifier> to private stash IDs, so payload.inventoryId is the fully resolved ID. Prefix-based patterns keep matching, since the suffix is at the end.Containers
Containers
Blocking a container only prevents it from being opened. Dropping an item onto a closed backpack still works, because that is an item transfer - use
onItemTransferred to restrict what goes in.forceOpenInventory still triggers this hook
forceOpenInventory still triggers this hook
forceOpenInventory skips jaksam’s own permission checks, but not your hooks - the same as ox_inventory, whose openInventory hook fires even when forceOpenInventory passes ignoreSecurityChecks. This means a hook can block an admin /openinventory, OpenInventoryById or forceOpenInventoryOX too, so filter on the inventories you actually care about instead of denying by default.Examples
Restrict job stashes to their own job
Restrict job stashes to their own job
registerHook API, available filters, and return-value behavior.