JRS COREDocs

Characters

Load events, readiness checks, lookups, appearance, hooks and state bags for the character a player is playing.

A player can own several characters, but only one is active at a time. jrs_core loads that character, marks it ready and copies the basics into player state bags. Server scripts use the exports.jrs_core:* calls below, client scripts listen for the ready event or read LocalPlayer.state. jrs_character (the selector and creator) adds a few extra exports for age, slots and the player model.

Tip

Never give items, money or blips before the character is ready. Wait for jrs_core:server:characterReady on the server or jrs_core:client:characterReady on the client, or check IsCharacterReady first.

Load And Unload Events#

The order on a normal join is: characterLoaded, then characterReady, then jrs:SelectedCharacter on the client. When the player goes back to the selector or leaves, characterUnloaded fires.

Server

jrs_core:server:characterReady

#
AddEventHandler('jrs_core:server:characterReady', function(source, character) ... end)

Fires once the core has accepted the chosen character and the state bags are set. This is the safe place for server setup per character.

lua
AddEventHandler('jrs_core:server:characterReady', function(source, character)
    print(('%s %s is in town'):format(character.firstname, character.lastname))
end)
ArgumentTypeMeaning
sourcenumberPlayer server id.
charactertableThe live character object (same one GetCharacter returns).
Server

jrs_core:server:characterLoaded

#
AddEventHandler('jrs_core:server:characterLoaded', function(source, character) ... end)

Fires right before characterReady with the same arguments. Use it when your code must run ahead of the ready listeners.

ArgumentTypeMeaning
sourcenumberPlayer server id.
charactertableThe live character object.
Server

jrs_core:server:characterUnloaded

#
AddEventHandler('jrs_core:server:characterUnloaded', function(source, character, reason) ... end)

Fires when the active character is dropped: player left, opened the selector, or the core cleared it. State bags are already reset.

lua
AddEventHandler('jrs_core:server:characterUnloaded', function(source, character, reason)
    ActiveWagons[source] = nil
end)
ArgumentTypeMeaning
sourcenumberPlayer server id.
charactertableThe character that was active, or nil if none was.
reasonstringWhy it happened, for example dropped, joining, clear or unknown.
Client

jrs_core:client:characterReady

#
RegisterNetEvent('jrs_core:client:characterReady', function(charId) ... end)

Sent to the player's client when the character is ready. The same moment is also raised locally as jrs_core:characterReady, so you can use AddEventHandler without a net event.

lua
AddEventHandler('jrs_core:characterReady', function(charId)
    CreateMyBlips()
end)
ArgumentTypeMeaning
charIdnumberCharacter id.
Client

jrs_core:client:characterLoaded

#
RegisterNetEvent('jrs_core:client:characterLoaded', function(charId) ... end)

Client copy of the loaded step, sent just before characterReady. Also raised locally as jrs_core:characterLoaded.

ArgumentTypeMeaning
charIdnumberCharacter id.
Client

jrs_core:client:characterUnloaded

#
RegisterNetEvent('jrs_core:client:characterUnloaded', function(reason) ... end)

Tells the client its character is gone. Stop loops and hide your UI here. Also raised locally as jrs_core:characterUnloaded.

ArgumentTypeMeaning
reasonstringSame reason text the server event gets.
Client

jrs:SelectedCharacter

#
RegisterNetEvent('jrs:SelectedCharacter', function(charId) ... end)

Older client event sent after selection, once the character is ready. Many JRS resources still listen to it, so it keeps firing. It also fires again on every character switch.

lua
RegisterNetEvent('jrs:SelectedCharacter', function(charId)
    TriggerServerEvent('jrs_myscript:server:loadData')
end)
ArgumentTypeMeaning
charIdnumberCharacter id.

Other Character Events#

Server

jrs_core:server:characterCreated

#
AddEventHandler('jrs_core:server:characterCreated', function(source, charId, identifier) ... end)

Fires when a brand new character row is written to the database.

ArgumentTypeMeaning
sourcenumberPlayer server id.
charIdnumberThe new character id.
identifierstringAccount identifier that owns it.
Server

jrs_core:server:firstCharacterSetup

#
AddEventHandler('jrs_core:server:firstCharacterSetup', function(source, charId) ... end)

Fires after all starter hooks have run for a new character. Use RegisterCharacterStarterHook if you want to hand out items, this event is for logging or follow-up work.

ArgumentTypeMeaning
sourcenumberPlayer server id.
charIdnumberCharacter id.
Server

jrs_core:server:characterSaved

#
AddEventHandler('jrs_core:server:characterSaved', function(source, character) ... end)

Fires after SaveCharacter writes the character to the database.

ArgumentTypeMeaning
sourcenumberPlayer server id.
charactertableThe live character object.
Server

jrs_core:server:characterIdentityChanged

#
AddEventHandler('jrs_core:server:characterIdentityChanged', function(source, charId, old, new) ... end)

Fires when the name, nickname, occupation or story of the active character changes. Resources that keep their own copy of the name (ID cards, records) should update it here.

lua
AddEventHandler('jrs_core:server:characterIdentityChanged', function(source, charId, old, new)
    MySQL.update('UPDATE my_records SET name = ? WHERE charid = ?', { new.firstname .. ' ' .. new.lastname, charId })
end)
ArgumentTypeMeaning
sourcenumberPlayer server id.
charIdnumberCharacter id.
oldtableFields before the change: firstname, lastname, nickname, occupation, lore.
newtableThe same fields after the change.
Client

jrs_core:client:characterIdentityChanged

#
RegisterNetEvent('jrs_core:client:characterIdentityChanged', function(new) ... end)

Client side of the identity change, sent only to the player whose character changed.

ArgumentTypeMeaning
newtableThe new firstname, lastname, nickname, occupation and lore.
Server

jrs_core:server:appearanceChanged

#
AddEventHandler('jrs_core:server:appearanceChanged', function(source, charId, data) ... end)

Fires when the saved look of an online character changes through SaveAppearance or RefreshAppearanceCache.

ArgumentTypeMeaning
sourcenumberServer id of the player using that character.
charIdnumberCharacter id.
datatableThe appearance that was saved or reloaded.
Client

jrs_core:client:appearanceChanged

#
RegisterNetEvent('jrs_core:client:appearanceChanged', function(charId, version) ... end)

Sent to the player after RefreshAppearanceCache, so the client can redraw the ped.

ArgumentTypeMeaning
charIdnumberCharacter id.
versionnumberNew appearance version number.
Server

jrs_core:server:metadataChanged

#
AddEventHandler('jrs_core:server:metadataChanged', function(source, key, value) ... end)

Fires each time SetMetadata, AddMetadata or RemoveMetadata stores a value.

ArgumentTypeMeaning
sourcenumberPlayer server id.
keystringThe metadata key.
valueanyThe new value.
Server

jrs_core:server:characterDeleteHook

#
AddEventHandler('jrs_core:server:characterDeleteHook', function(charId, identifier, phase) ... end)

Fires after the registered delete hooks have run for a character that is being deleted.

ArgumentTypeMeaning
charIdnumberCharacter id.
identifierstringOwner account identifier.
phasestringDelete phase, before when not given.

Is The Character Ready#

Server

IsCharacterReady

#
exports.jrs_core:IsCharacterReady(source)

Checks that the player has a fully loaded character. Call it at the top of any server event that touches character data.

lua
RegisterNetEvent('jrs_myscript:server:buy', function()
    local src = source
    if not exports.jrs_core:IsCharacterReady(src) then return end
    -- safe to continue
end)
ArgumentTypeMeaning
sourcenumberPlayer server id.
Returnsbooleantrue when a character is active.
Server

IsIdentityReady

#
exports.jrs_core:IsIdentityReady(source)

Same check as IsCharacterReady, named for identity gates (the player has a verified character on their account).

ArgumentTypeMeaning
sourcenumberPlayer server id.
Returnsbooleantrue when a character is active.
Server

GetCharacter

#
exports.jrs_core:GetCharacter(source)

Gives the live character object of an online player. Changes you make to it stay in memory until the next save.

lua
local char = exports.jrs_core:GetCharacter(source)
if char then print(char.charIdentifier, char.job) end
ArgumentTypeMeaning
sourcenumberPlayer server id.
Returnstable|nilThe character, or nil when the player has none ready.
Server

GetCharacterState

#
exports.jrs_core:GetCharacterState(source)

Small status table, handy for debugging or for passing to another resource.

ArgumentTypeMeaning
sourcenumberPlayer server id.
Returnstableready, version (jrs_core version), identifier and charIdentifier.
Client

IsCharacterReady (client)

#
exports.jrs_core:IsCharacterReady()

Client check based on the CharacterReady state bag.

Returnsbooleantrue when the local character is ready.
Client

WaitForCharacterReady

#
exports.jrs_core:WaitForCharacterReady(timeoutMs?)

Blocks the current thread until the character is ready or the time runs out. Use it inside a CreateThread.

lua
CreateThread(function()
    if exports.jrs_core:WaitForCharacterReady(15000) then
        SpawnCampfire()
    end
end)
ArgumentTypeMeaning
timeoutMsnumberHow long to wait. Default 10000.
Returnsbooleantrue if the character became ready in time.
Client

GetCharacterStateLocal

#
exports.jrs_core:GetCharacterStateLocal()

Reads the local player's state bags into one table.

Returnstableready, charIdentifier, identifier, firstname, lastname, job, jobGrade, jobLabel, onDuty, gender.
Client

IsCharacterReady (jrs_character)

#
exports.jrs_character:IsCharacterReady()

Stricter client check from the selector: true only when a character is loaded and the selector or creator screen is closed.

Returnsbooleantrue when the player is in the world with a character.
Client

IsCharacterGateActive

#
exports.jrs_character:IsCharacterGateActive()

Tells you if the selector or creator is on screen. Hide your HUD while it is.

Returnsbooleantrue while the gate is open.

Find Characters#

Server

GetCharacterById

#
exports.jrs_core:GetCharacterById(charId)

Looks for the character among online players first and falls back to the database.

lua
local char, src,
if online then
    TriggerClientEvent('jrs_core:notify', src, 'You have mail')
end
ArgumentTypeMeaning
charIdnumberCharacter id.
Returnstable|nil, number|nil, booleanThe character, the server id if online, and true when it was found online.
Server

GetOfflineCharacter

#
exports.jrs_core:GetOfflineCharacter(charId)

Reads the character row straight from the database, even if the player is online. JSON columns (multijobs, skills, meta) come back decoded.

ArgumentTypeMeaning
charIdnumberCharacter id.
Returnstable|nilThe row, or nil when not found.
Server

GetCharactersByIdentifier

#
exports.jrs_core:GetCharactersByIdentifier(identifier)

Lists every character of one account, oldest first. The list is capped by Config.CharacterService.OfflineLookupLimit (50 by default, 200 max).

ArgumentTypeMeaning
identifierstringAccount identifier, for example a steam id.
ReturnstableArray of character rows, empty when none.
Server

FindCharactersByName

#
exports.jrs_core:FindCharactersByName(firstname, lastname?)

Exact name search, most recently played first. Leave the last name out to match on first name only.

lua
local found = exports.jrs_core:FindCharactersByName('Arthur', 'Morgan')
for _, row in ipairs(found) do print(row.charIdentifier) end
ArgumentTypeMeaning
firstnamestringFirst name.
lastnamestringLast name.
ReturnstableArray of character rows.
Server

GetPlayerObject

#
exports.jrs_core:GetPlayerObject(source)

One table with the player's data and bound helper functions, so you do not need to pass the source again.

lua
local p = exports.jrs_core:GetPlayerObject(source)
if p and p.Functions.GetMoney() >= 25 then
    p.Functions.RemoveMoney(25)
end
ArgumentTypeMeaning
sourcenumberPlayer server id.
Returnstable|nilsource, PlayerData (a flat copy with money, job, skills, metadata and more), Character (the live object) and Functions (AddMoney, RemoveMoney, GetMoney, SetJob, SetDuty, ToggleDuty, GetMetadata, SetMetadata, AddSkillXP, Save).
Server

GetCharacterSummaries

#
exports.jrs_character:GetCharacterSummaries(source)

Safe overview of an online player's own characters, without money, inventory or coordinates. Soft deleted characters are left out. At most 12 rows.

ArgumentTypeMeaning
sourcenumberPlayer server id.
ReturnstableArray of charId, firstname, lastname, nickname, occupation, gender, job, jobGrade, dateOfBirth, isDead, lastPlayed, active.

Character Slots#

Server

GetCharacterCount

#
exports.jrs_core:GetCharacterCount(source)

Counts the characters saved for the player's account.

ArgumentTypeMeaning
sourcenumberPlayer server id.
ReturnsnumberNumber of characters, 0 when unknown.
Server

GetMaxCharacters

#
exports.jrs_core:GetMaxCharacters(source)

How many characters this account may have. Uses the user's own limit, then Config.Char_Count, and never less than 1.

ArgumentTypeMeaning
sourcenumberPlayer server id.
ReturnsnumberThe slot limit.
Server

CanCreateCharacter

#
exports.jrs_core:CanCreateCharacter(source)

Shortcut for count below limit.

lua
if not exports.jrs_core:CanCreateCharacter(source) then
    TriggerClientEvent('jrs_core:notify', source, 'All slots are taken')
end
ArgumentTypeMeaning
sourcenumberPlayer server id.
Returnsbooleantrue when there is a free slot.
Server

SetMaxCharacters

#
exports.jrs_core:SetMaxCharacters(source, count)

Saves a new slot limit for the player's account (minimum 1). Good for VIP rewards.

ArgumentTypeMeaning
sourcenumberPlayer server id.
countnumberNew limit.
Returnsbooleantrue when stored.
Server

GetCharacterSlots

#
exports.jrs_character:GetCharacterSlots(source)

Slot numbers as the selector sees them, including role based slots. Soft deleted characters do not count.

ArgumentTypeMeaning
sourcenumberPlayer server id.
Returnstable|nillimit, used, free, source (where the limit came from) and max (hard cap).
Server

GetCharacterSlotsForIdentifier

#
exports.jrs_character:GetCharacterSlotsForIdentifier(identifier)

Same as GetCharacterSlots for any account, online or not. Role based slots are not applied because they need a live player.

ArgumentTypeMeaning
identifierstringAccount identifier.
Returnstable|nilSame fields as GetCharacterSlots.

Identity And Age#

Server

SetCharacterIdentity

#
exports.jrs_core:SetCharacterIdentity(source, fields)

Renames the active character everywhere at once: database, live object, core caches and state bags. It does not check the text for bad words, the caller must do that. Fires the identity changed events.

lua
local ok, why = exports.jrs_core:SetCharacterIdentity(source, {
    firstname = 'John', lastname = 'Marston', nickname = 'Johnny'
})
ArgumentTypeMeaning
sourcenumberPlayer server id.
fieldstablefirstname and lastname (both required), plus optional nickname, occupation and lore.
Returnsboolean, string?true, or false and a reason: character_not_ready, name_required, db_failed.
Server

GetCharacterAge

#
exports.jrs_character:GetCharacterAge(source)

Current in-game age of the active character, based on birth date and play time.

ArgumentTypeMeaning
sourcenumberPlayer server id.
Returnsnumber|nil, tableAge in years, plus a snapshot table with the aging details.
Server

GetCharacterAgeById

#
exports.jrs_character:GetCharacterAgeById(charId)

Same as GetCharacterAge for any character id, online or offline.

ArgumentTypeMeaning
charIdnumberCharacter id.
Returnsnumber|nil, tableAge in years and the snapshot.
Client

GetCurrentCharacterAge

#
exports.jrs_character:GetCurrentCharacterAge()

Local copy of the age the client is using for the ped.

Returnsnumber, stringAge in years and the age stage name.

Appearance#

Warning

In GetAppearance, SaveAppearance and RefreshAppearanceCache a plain number is always a character id, never a server id. To pass a player, use the ForSource version or { source = src }.

Server

GetAppearance

#
exports.jrs_core:GetAppearance(charIdOrRef)

Loads the saved look of any character, online or not. Clothes come from jrs_clothing and hair from jrs_barber when those are started.

lua
local look = exports.jrs_core:GetAppearance(charId)
ArgumentTypeMeaning
charIdOrRefnumber|tableCharacter id, or a table with charIdentifier or source.
Returnstable|nilcharIdentifier, skin, components, version, and when available outfitId, hiddenCategories, barber.
Server

GetAppearanceForSource

#
exports.jrs_core:GetAppearanceForSource(source)

Look of the character an online player is using.

ArgumentTypeMeaning
sourcenumberPlayer server id.
Returnstable|nilSame table as GetAppearance.
Server

SaveAppearance

#
exports.jrs_core:SaveAppearance(charIdOrRef, data)

Writes a new look and bumps the appearance version. Only the parts you include are changed. Clothes and barber data are passed on to jrs_clothing and jrs_barber.

lua
local look = exports.jrs_core:GetAppearance(charId)
look.skin.Eyes = 3
exports.jrs_core:SaveAppearance(charId, { skin = look.skin })
ArgumentTypeMeaning
charIdOrRefnumber|tableCharacter id or reference table.
datatableAny of skin, components, outfitId, barber.
Returnsboolean, string?true, or false and invalid_data / character_not_found.
Server

RefreshAppearanceCache

#
exports.jrs_core:RefreshAppearanceCache(charIdOrRef)

Reloads the look from the database into the live character and tells the client to redraw. Use it after you edit the tables yourself.

ArgumentTypeMeaning
charIdOrRefnumber|tableCharacter id or reference table.
Returnsboolean, table|stringtrue and the appearance, or false and a reason.
Server

RefreshAppearanceForSource

#
exports.jrs_core:RefreshAppearanceForSource(source)

RefreshAppearanceCache for the character an online player is using.

ArgumentTypeMeaning
sourcenumberPlayer server id.
Returnsboolean, table|stringSame as RefreshAppearanceCache.
Client

ReloadCurrentCharacter

#
exports.jrs_character:ReloadCurrentCharacter()

Rebuilds the local ped from the saved look. It does not unload the character or open the selector.

ReturnsbooleanAlways true. A reload already running is not started twice.
Client

IsReloadingCurrentCharacter

#
exports.jrs_character:IsReloadingCurrentCharacter()

Tells you if ReloadCurrentCharacter is still busy.

Returnsbooleantrue while reloading.
Client

RestoreCharacterAppearance

#
exports.jrs_character:RestoreCharacterAppearance(ped?)

Puts the saved look back on a ped, for example after a respawn or a model swap.

ArgumentTypeMeaning
pednumberPed handle. Defaults to the player ped.
Returnsbooleantrue when applied.

Metadata#

Small values stored per character in the meta column. Good for flags and counters that do not need their own table.

Server

GetMetadata

#
exports.jrs_core:GetMetadata(source, key?, default?)

Reads one value, or the whole metadata table when no key is given.

lua
local done = exports.jrs_core:GetMetadata(source, 'tutorial_done', false)
ArgumentTypeMeaning
sourcenumberPlayer server id.
keystringThe key to read.
defaultanyReturned when the key is missing or no character is loaded.
ReturnsanyThe stored value or the default.
Server

SetMetadata

#
exports.jrs_core:SetMetadata(source, key, value)

Stores a value and saves it to the database right away.

ArgumentTypeMeaning
sourcenumberPlayer server id.
keystringThe key.
valueanyAny value that fits in JSON.
Returnsbooleanfalse when no character is loaded.
Server

AddMetadata

#
exports.jrs_core:AddMetadata(source, key, amount)

Adds a number to a numeric key (missing keys start at 0).

lua
exports.jrs_core:AddMetadata(source, 'wolves_hunted', 1)
ArgumentTypeMeaning
sourcenumberPlayer server id.
keystringThe key.
amountnumberHow much to add.
ReturnsbooleanResult of the save.
Server

RemoveMetadata

#
exports.jrs_core:RemoveMetadata(source, key, amount)

Subtracts a number from a numeric key. It does not delete the key.

ArgumentTypeMeaning
sourcenumberPlayer server id.
keystringThe key.
amountnumberHow much to take off.
ReturnsbooleanResult of the save.

Skills#

Per character skill XP. Level size and cap come from Config.CharacterService.Skills[name] (xpPerLevel and maxLevel, both 100 by default).

Server

GetSkills

#
exports.jrs_core:GetSkills(source)

All skills stored for the active character.

ArgumentTypeMeaning
sourcenumberPlayer server id.
ReturnstableSkill name to skill table. Empty when no character.
Server

GetSkill

#
exports.jrs_core:GetSkill(source, skillName)

One skill with its level worked out.

ArgumentTypeMeaning
sourcenumberPlayer server id.
skillNamestringSkill name.
Returnstable|nilxp, level, maxLevel, nextLevelXp, label.
Server

SetSkillXP

#
exports.jrs_core:SetSkillXP(source, skillName, xp)

Sets the XP of a skill and saves it. When the level changes, jrs_core:server:skillLevelChanged and jrs_core:client:skillLevelChanged fire with the skill, new level and old level.

ArgumentTypeMeaning
sourcenumberPlayer server id.
skillNamestringSkill name.
xpnumberNew XP, at least 0.
Returnsboolean, table?true and the updated skill.
Server

AddSkillXP

#
exports.jrs_core:AddSkillXP(source, skillName, amount)

Adds XP on top of the current amount.

lua
exports.jrs_core:AddSkillXP(source, 'fishing', 10)
ArgumentTypeMeaning
sourcenumberPlayer server id.
skillNamestringSkill name.
amountnumberXP to add.
Returnsboolean, table?Same as SetSkillXP.
Note

Jobs, multi job and duty calls (AddJob, SwitchJob, SetDuty and the rest) are on the JRS API page.

Saving And Health#

Server

SaveCharacter

#
exports.jrs_core:SaveCharacter(source)

Writes name, job, duty, multi jobs, skills and metadata of the live character to the database and updates the last played time.

ArgumentTypeMeaning
sourcenumberPlayer server id.
Returnsbooleanfalse when no character is loaded.
Server

SaveHealthState

#
exports.jrs_core:SaveHealthState(source, healthState)

Stores a health snapshot (any table you choose) for the active character.

ArgumentTypeMeaning
sourcenumberPlayer server id.
healthStatetableThe data to keep.
Returnsbooleantrue when saved.
Server

GetHealthState

#
exports.jrs_core:GetHealthState(charIdOrRef)

Reads the stored health snapshot of any character.

ArgumentTypeMeaning
charIdOrRefnumber|tableCharacter id or reference table.
Returnstable|nilThe snapshot, an empty table when none was saved, nil for a bad id.
Server

GetHealthStateForSource

#
exports.jrs_core:GetHealthStateForSource(source)

GetHealthState for the character an online player is using.

ArgumentTypeMeaning
sourcenumberPlayer server id.
Returnstable|nilThe snapshot.

Create And Delete Hooks#

Hooks let your resource react to a new or deleted character without editing jrs_core. Each hook has a name, so registering the same name again replaces the old one.

Server

RegisterCharacterStarterHook

#
exports.jrs_core:RegisterCharacterStarterHook(name, callback)

Runs your function for every newly created character. Errors are caught and printed, they do not stop other hooks.

lua
exports.jrs_core:RegisterCharacterStarterHook('jrs_myscript', function(source, charId)
    exports.jrs_inventory:addItem(source, 'canned_beans', 3)
end)
ArgumentTypeMeaning
namestringUnique hook name, usually your resource name.
callbackfunctionCalled as callback(source, charId).
Returnsbooleanfalse when the name is empty or the callback is not a function.
Server

RegisterCharacterDeleteHook

#
exports.jrs_core:RegisterCharacterDeleteHook(name, callback)

Runs your function when a character is deleted, so you can clean up your own tables. Return false from the callback to report a failure.

lua
exports.jrs_core:RegisterCharacterDeleteHook('jrs_myscript', function(charId, identifier, phase)
    MySQL.update('DELETE FROM my_wagons WHERE charid = ?', { charId })
end)
ArgumentTypeMeaning
namestringUnique hook name.
callbackfunctionCalled as callback(charId, identifier, phase).
Returnsbooleanfalse when the name is empty or the callback is not a function.
Server

RunCharacterDeleteHooks

#
exports.jrs_core:RunCharacterDeleteHooks(charId, identifier, phase?)

Runs every registered delete hook. The character selector calls this, you only need it if you delete characters from your own tool.

ArgumentTypeMeaning
charIdnumberCharacter id.
identifierstringOwner account identifier.
phasestringDefault before.
Returnsbooleanfalse if any hook failed.
Server

RunStarterHooks

#
exports.jrs_core:RunStarterHooks(source, charId)

Runs every starter hook, then fires jrs_core:server:firstCharacterSetup. Normally called by the creator.

ArgumentTypeMeaning
sourcenumberPlayer server id.
charIdnumberCharacter id.
Server

IsCharacterSoftDeleted

#
exports.jrs_character:IsCharacterSoftDeleted(charId)

Characters deleted from the selector can be kept as soft deleted for a while. This tells you if one is.

ArgumentTypeMeaning
charIdnumberCharacter id.
Returnsbooleantrue when soft deleted.
Server

RestoreDeletedCharacter

#
exports.jrs_character:RestoreDeletedCharacter(charId)

Brings a soft deleted character back. It does not check permissions, so guard it in your own code.

ArgumentTypeMeaning
charIdnumberCharacter id.
Returnsboolean, string?true, or false and a reason.

State Bags#

jrs_core writes these keys on the player state bag when the character is ready and sets them to false when it is unloaded. They replicate to every client, so other players can read them too.

Key Type Content
CharacterReady boolean true while a character is active
CharacterId number character id
CharacterIdentifier string owner account identifier
FirstName, LastName string character name
Nickname string nickname, may be empty
Gender string gender from the creator
Job, JobGrade, JobLabel string, number, string active job
OnDuty boolean duty flag
Group string permission group, for example user or admin
lua
-- client: your own character
if LocalPlayer.state.CharacterReady then
    print(LocalPlayer.state.FirstName, LocalPlayer.state.Job)
end

-- server: any player
local job = Player(source).state.Job

-- client: react when the ready flag flips
AddStateBagChangeHandler('CharacterReady', ('player:%s'):format(GetPlayerServerId(PlayerId())), function(_, _, value)
    if value then print('character ready') end
end)
Note

State bags are a fast read only copy. To change a job or a name use the exports above, never state:set from your own script.