Documentation

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

ExportReturnsWhat it does
PlaceBag(source)booleanStarts 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)numberRemoves the player’s placed bags and returns how many. giveItemBack = true gives the item back.
HasPlacedBag(source)booleanThe player has a bag on the ground.
GetPlacedBags()tablePlaced bags: { id, owner, coords, bucket, shared }.
IsMenuOpen(source)booleanThe player has the bag menu open.
CloseMenu(source)booleanCloses the menu for the player. true if it was open.
GetOutfits(source)tableWardrobe outfits, the same list the bag shows.
SaveOutfit(source, name, outfit, model)boolean, reasonSaves an outfit { components, props } to the wardrobe.
DeleteOutfit(source, outfitId)boolean, reasonDeletes 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

ReasonMeaning
outfit_errorInvalid player, name or outfit, or the write failed.
outfit_fullWardrobe full (Config.MaxOutfits).
client_writesWith 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

ExportReturnsWhat it does
IsMenuOpen()booleanThe bag menu is open.
CloseMenu()booleanCloses the menu. true if it was open.
OpenNearestBag()booleanOpens 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

WhatDetails
useBag (export server)Used by ox_inventory for the item (server = { export = 'kairo_outfitbag.useBag' }). Don’t call it yourself.
CommandConfig.Command, e.g. 'outfitbag': places the bag without an item.
Key+kairo_outfitbag (text UI): players rebind it in Settings → Key Bindings → FiveM.
HookTo change behaviour rather than drive it, use the hooks in editable/.

See also Hooks & customisation.