KAIRO OutfitBag
Exports & API
Exports let other resources drive the bag: radial menus, keybinds, HUDs, jobs, admin tools. They go through the same checks as the item and the menu, so they open no shortcuts. Available from version 1.1.0.
Server exports
| Export | Returns | What it does |
|---|---|---|
PlaceBag(source) | boolean | Starts placing as if the player used the item: rate limit, maxPerPlayer, Custom.CanPlace, not in a vehicle. With RemoveItemOnPlace the item is still required. |
RemoveBag(source, giveItemBack) | number | Removes the player’s placed bags and returns how many. giveItemBack = true gives the item back. |
HasPlacedBag(source) | boolean | The player has a bag on the ground. |
GetPlacedBags() | table | Placed bags: { id, owner, coords, bucket, shared }. |
IsMenuOpen(source) | boolean | The player has the bag menu open. |
CloseMenu(source) | boolean | Closes the menu for the player. true if it was open. |
GetOutfits(source) | table | Wardrobe outfits, the same list the bag shows. |
SaveOutfit(source, name, outfit, model) | boolean, reason | Saves an outfit { components, props } to the wardrobe. |
DeleteOutfit(source, outfitId) | boolean, reason | Deletes an outfit (id from GetOutfits). |
server
-- an admin places a bag for a player
RegisterCommand('givebagspot', function(source, args)
local target = tonumber(args[1])
if target and exports.kairo_outfitbag:PlaceBag(target) then
print('placing started')
end
end, true)
-- on arrest remove the bag and give the item back
AddEventHandler('police:server:cuffed', function(target)
exports.kairo_outfitbag:CloseMenu(target)
exports.kairo_outfitbag:RemoveBag(target, true)
end)
-- save an outfit from another script
local ok, reason = exports.kairo_outfitbag:SaveOutfit(source, 'Divisa', {
components = { [11] = { 55, 0 }, [4] = { 35, 0 }, [6] = { 25, 0 } },
props = { [0] = { -1, 0 } },
})Error reasons
| Reason | Meaning |
|---|---|
outfit_error | Invalid player, name or outfit, or the write failed. |
outfit_full | Wardrobe full (Config.MaxOutfits). |
client_writes | With illenium-appearance, CodeM and Quasar the wardrobe is written from the client through their own events, so the server can’t write it. |
Client exports
| Export | Returns | What it does |
|---|---|---|
IsMenuOpen() | boolean | The bag menu is open. |
CloseMenu() | boolean | Closes the menu. true if it was open. |
OpenNearestBag() | boolean | Opens the nearest bag within Config.InteractDistance. Opening goes through the server checks: distance, owner or shared bag, Custom.CanOpen. |
client
-- radial menu entry
exports.kairo_outfitbag:OpenNearestBag()
-- close the bag when the phone opens
AddEventHandler('phone:open', function()
if exports.kairo_outfitbag:IsMenuOpen() then
exports.kairo_outfitbag:CloseMenu()
end
end)Placing can only be started from the server (
PlaceBag): from the client, a modified client could place bags without owning the item.Other entry points
| What | Details |
|---|---|
useBag (export server) | Used by ox_inventory for the item (server = { export = 'kairo_outfitbag.useBag' }). Don’t call it yourself. |
| Command | Config.Command, e.g. 'outfitbag': places the bag without an item. |
| Key | +kairo_outfitbag (text UI): players rebind it in Settings → Key Bindings → FiveM. |
| Hook | To change behaviour rather than drive it, use the hooks in editable/. |
See also Hooks & customisation.
