Skip to content

Exports, events and hooks — CC Multicharacter

Everything another resource can use. Server exports can only be called from server code (a player can never call them). Replace cc_multicharacter with your folder name if you renamed it.

Everything another resource can use. Server exports can only be called from server code (a player can never call them). Replace cc_multicharacter with your folder name if you renamed it.

Server exports

lua
local mc = exports.cc_multicharacter
ExportArgumentsReturnsWhat
getActiveCharacter(src)server idstring?The framework's id of the active character (citizenid / identifier / charId)
getCharacter(src)server idtable?Standalone only: { id, firstname, lastname }. On a framework ask the framework
isSelecting(src)server idbooleanTrue while the player is on the select / create / spawn screens
getPhase(src)server idstring?'select', 'look' (clothing editor), 'spawn', 'landing', or nil in the world
getBridge()—string?, string?The framework and housing adapters in use
getSlots(src)server idtable?{ allowed, base, rank, ranks = { { id, label, extra, held } } }
addSlots(identifier, n)'license:..'/'discord:..'/'fivem:..', 1–20integer?Bought slots after the change (same as ccmc_addslots)
removeSlots(identifier, n)identifier, 1–20integer?Same, removing; never below 0
restoreCharacter(charId)idstring?Restores a soft-deleted character; its name, or nil
GetCharacterSlots(license2, license, src)integerSlot count (compatible with Qbox's slot hook and cc_loading's export)
SetCharacterSlots(license, total)licence, totalboolean, integerSet an absolute total (stores and coin shops)
registerHook(name, fn, opts?)see HooksidAdd a hook handler
removeHook(id)Remove one
getHooks()tableEvery hook with its description and handler count
getVersion() / getApi()Version and the whole surface (cc_lib 1.12+)

Client exports

ExportReturnsWhat
isSelecting()booleanTrue while our screens own the player (hide your HUD)
requestRelog()—Same as typing /relog (the server still decides)

Server events (listen with AddEventHandler)

These are local server events: only server code fires them, a player cannot.

lua
AddEventHandler('cc_multicharacter:characterSpawned', function(src, charId, info)
    -- info = { isNew = bool, kind = 'city' | 'home' | 'last', home = homeId? }
end)
EventArgumentsWhen
cc_multicharacter:bridgeReadyframework, housingAdapters picked at start
cc_multicharacter:characterSelectedsrc, charIdA returning character was logged in
cc_multicharacter:characterCreatedsrc, charId, { firstname, lastname, dob, sex, height, nationality }A new character exists (and is logged in)
cc_multicharacter:characterSpawnedsrc, charId, { isNew, kind, home }The character is in the world
cc_multicharacter:characterDeletedsrc, charId, softA character was deleted (soft = restorable)
cc_multicharacter:readyversionOur API is published (cc_lib 1.12+)

Client events

lua
AddEventHandler('cc_multicharacter:spawned', function(info)  -- info = { home = bool }
    -- show your HUD, start your phone, etc.
end)

Your framework's own loaded events still fire as usual (QBCore:Client:OnPlayerLoaded, esx:playerLoaded, ox_core's), so most resources need nothing new.

State bags

BagSideValue
Player(src).state.isInSpawnSelectorserver → allQbox: true while on the spawn map
Player(src).state.cc_characterserver → allStandalone: { id, firstname, lastname } of the active character

Hooks

A hook lets your resource refuse or adjust what cc_multicharacter does, without editing it. Handlers run in pcall (your bug never breaks us) and are removed automatically when your resource stops. A hook can only narrow what we do: refuse, hide. It never grants.

lua
-- server side, in your own resource
exports.cc_multicharacter:registerHook('beforeRelog', function(payload)
    if exports.my_jail:isJailed(payload.source) then return false end   -- refuse
end)
HookCancellablePayloadUse it for
beforeRelogyessourceNo relog in jail, during a heist, in a court case
beforeCreateyessource, firstname, lastname, dob, sex, height, nationality (already validated)Your own name rules, whitelists
beforeSelectyessource, charId, firstname, lastnameBan one character without banning the player
beforeDeleteyessource, charId, name, softProtect characters that own a business or a gang
spawnOptionsno (mutable)source, charId, isNew, job, hiddenHide cards: payload.hidden['paleto'] = true. Ids: last, home:<id>, or a Config.Spawn.points id

When a cancellable hook refuses, the player sees a short "Not allowed right now" message (notify.refused / create.err.refused in locales/).

Adding a framework or housing adapter

bridge/framework/*.lua and bridge/housing/*.lua are readable. Copy the closest one; the functions each must provide are documented at the top of every file (detect, account, list, listAccount, login, create, logout, purge, nameTaken, lastPosition, activeId, starter, holding, clientLoaded for frameworks; detect, homes, enter for housing). Add the file to server_scripts in fxmanifest.lua and its key to the order list in server/boot.lua, or force it with the cc_multicharacter_framework / cc_multicharacter_housing convar.