Exports ​
All exports are called as exports.np_character:<name>(...).
Client ​
client
| Export | Returns | Description |
|---|---|---|
openCreator(opts) |
true | false, 'not_loaded' | 'busy' |
Open store mode for the playing character. opts = { kind?, steps?, title?, onDone? }. Asynchronous: true means requested. See Stores |
openSelect() |
true |
Back to the select screen, same as /logout |
isBusy() |
boolean |
true while select, the creator (including a store), the spawn picker or the arrival is active. The staff panel doesn't count |
getAppearance(ped?) |
Appearance |
The ped's appearance in the illenium-appearance format. ped defaults to the player |
setAppearance(ped, appearance) |
boolean |
Sanitise and apply an appearance. Swaps the model when needed, but only for the player ped (false for other peds with a different model). Does not save |
lua
-- barber from your own shop resource
local ok, err = exports.np_character:openCreator({
kind = 'barber',
onDone = function(saved, appearance)
if saved then exports.np_menu:notify({ type = 'success', title = 'Fresh cut' }) end
end,
})
if not ok then print('store not available:', err) end
-- don't open your UI over the character screens
if exports.np_character:isBusy() then return end
-- copy the player's look onto a ped of the same model
local app = exports.np_character:getAppearance()
exports.np_character:setAppearance(clonePed, app)
Appearance ​
The appearance format is the one of illenium-appearance / fivem-appearance:
lua
{
model = 'mp_m_freemode_01', -- or 'mp_f_freemode_01', or a Config.PedModels entry
headBlend = { shapeFirst, shapeSecond, shapeThird, skinFirst, skinSecond, skinThird, shapeMix, skinMix, thirdMix },
faceFeatures = { noseWidth = 0.0, … }, -- 20 features, each -1.0 .. 1.0
headOverlays = { beard = { style, opacity, color, secondColor }, … }, -- 12 overlays (native index 0..11)
hair = { style, color, highlight, texture },
eyeColor = 0, -- 0..31
components = { { component_id = 0..11, drawable, texture }, … }, -- 12 entries
props = { { prop_id = 0|1|2|6|7, drawable = -1, texture = -1 }, … }, -- 5 entries, -1 = none
tattoos = { ZONE_TORSO = { { name, label, hashMale, hashFemale, zone, collection, opacity } }, … },
}
Server ​
server
| Export | Returns | Description |
|---|---|---|
getCharacters(src) |
CharacterSummary[] |
The characters of the player's license (not deleted), ordered by slot |
getCharacter(cid) |
CharacterSummary | nil |
One character by CID, deleted ones included |
getActiveCharacter(src) |
cid | nil |
The playing character (also set right after a create, before the spawn) |
registerSpawnProvider(name, fn) |
boolean |
Add spawns: fn(src, cid) -> Spawn[]. See Spawn providers. Removed when your resource stops |
openStore(src, kind) |
boolean |
Open a Config.Store kind ('barber', 'clothing', 'surgeon', …) for a playing character. See Stores |
setSlots(license, n) |
boolean |
Per-license slot override, 1 … Config.Slots.max. nil removes the override |
logout(src) |
boolean |
Back to select, same as /logout. false (with a toast) when the player isn't playing |
lua
-- Tebex package: five slots for this player
local license = GetPlayerIdentifierByType(source, 'license')
exports.np_character:setSlots(license, 5)
-- who is this player playing?
local cid = exports.np_character:getActiveCharacter(source)
local char = cid and exports.np_character:getCharacter(cid)
if char then print(char.firstname, char.lastname, char.job.label) end
License type on qbx
The qbx bridge identifies players by license2 when they have one, like qbx_core does. Use the same identifier for
setSlots there.
CharacterSummary ​
lua
{
cid = 'ABC12345', -- citizenid (qb / qbx), 'char1:<license>' (ESX), or our own id (standalone)
slot = 1,
firstname = 'Marcus', lastname = 'Hale',
birthdate = '1992-03-14', -- ISO
age = 34, -- relative to Config.GameYear (nil = the real year)
gender = 'm', -- 'm' | 'f'
nationality = 'American',
job = { name = 'police', label = 'LSPD', grade = 'Sergeant', icon = 'shield-halved', tint = 'blue' },
cash = 2480, bank = 48920,
phone = '555-0142', -- nil if unknown
playtime = 763200, -- seconds
lastSeen = 1759500000, -- unix seconds
lastLocation = { x, y, z, w, label = 'Elgin Ave, Strawberry' }, -- nil if never saved
isDefault = false,
}
Events ​
See Events & commands for np_character:loaded, :unloaded, :created, :deleted and
:storeClosed.