Character¶
Character metadata helpers for lookup, recognition, persistence, and state management.
Overview
getID()View Source
Purpose
Returns the numeric ID assigned to this character.
Realm
Shared
Returns
number The character ID.
Example Usage
local charID = character:getID()
print("Character ID:", charID)
getPlayer()View Source
Purpose
Resolves and caches the player currently using this character, if any.
Realm
Shared
Returns
Player|nil The owning player when found.
Example Usage
local owner = character:getPlayer()
if IsValid(owner) then print(owner:Nick()) end
getDisplayedName(client)View Source
Purpose
Returns the name this character should display to a specific viewer.
Realm
Shared
Parameters
Player client The player viewing this character.
Returns
string The true name, a fake recognized name, or the localized unknown label.
Example Usage
local shownName = targetCharacter:getDisplayedName(viewer)
viewer:ChatPrint(shownName)
hasMoney(amount)View Source
hasFlags(flagStr)View Source
Purpose
Checks whether the character owns any of the supplied flags.
Realm
Shared
Parameters
string flagStr One or more flag characters to test.
Returns
boolean `true` if any requested flag is present.
Example Usage
if character:hasFlags("pet") then
print("Character has at least one of those flags.")
end
getAttrib(key, default)View Source
Purpose
Returns an attribute value after applying any active boosts for that attribute.
Realm
Shared
Parameters
Returns
number The current effective attribute value.
Example Usage
local strength = character:getAttrib("str", 0)
print("Strength:", strength)
doesRecognize(id)View Source
Purpose
Checks whether this character normally recognizes another character ID.
Realm
Shared
Parameters
number|table id A character ID or character object.
Returns
boolean `true` unless a hook explicitly rejects recognition.
Example Usage
if viewerCharacter:doesRecognize(targetCharacter) then
print("This character is recognized.")
end
doesFakeRecognize(id)View Source
Purpose
Checks whether this character uses a fake recognized name for another character.
Realm
Shared
Parameters
number|table id A character ID or character object.
Returns
boolean `true` unless a hook explicitly rejects fake recognition.
Example Usage
if viewerCharacter:doesFakeRecognize(targetCharacter) then
print("A fake recognized name is being used.")
end
setData(k, v, noReplication, receiver)View Source
Purpose
Stores arbitrary character data, optionally replicating it and persisting it on the server.
Realm
Shared
Parameters
string|table k A single key or a table of key-value pairs.
any v The value for a single key update.
boolean noReplication Whether to skip sending the updated data over the network.
Player receiver An optional player to receive replicated data.
Example Usage
character:setData("title", "Quartermaster")
character:setData({
rank = "Captain",
callsign = "Echo-3"
})
getData(key, default)View Source
Purpose
Retrieves stored character data, checking the cache first and the database on the server when needed.
Realm
Shared
Parameters
string key optional The key to fetch, or `nil` to return the full data table.
any default The fallback value if the key is missing.
Returns
any The stored value, the full data table, or the fallback.
Example Usage
local title = character:getData("title", "Citizen")
local allData = character:getData()
isBanned()View Source
Purpose
Checks whether the character is currently banned.
Realm
Shared
Returns
boolean `true` if the ban is permanent or still active.
Example Usage
if character:isBanned() then
print("This character cannot be selected right now.")
end
recognize(character, name)View Source
Purpose
Marks another character as recognized, optionally storing a fake display name.
Realm
Server
Parameters
number|table character A character ID or character object to recognize.
string name optional A fake name to store instead of normal recognition.
Returns
boolean `true` after the recognition data is updated.
Example Usage
observerCharacter:recognize(targetCharacter)
observerCharacter:recognize(targetCharacter, "John Doe")
joinClass(class, isForced)View Source
Purpose
Moves the character into a class if the class exists and passes eligibility checks.
Realm
Server
Parameters
string|number class optional The class identifier to join.
boolean isForced Whether to bypass `lia.class.canBe`.
Returns
boolean `true` if the class was joined.
Example Usage
local joined = character:joinClass(CLASS_MEDIC)
print("Joined class:", joined)
kickClass()View Source
updateAttrib(key, value)View Source
setAttrib(key, value)View Source
addBoost(boostID, attribID, boostAmount)View Source
Purpose
Adds or replaces a temporary boost on an attribute.
Realm
Server
Parameters
string boostID A unique identifier for the boost source.
string attribID The attribute being boosted.
number boostAmount The amount to apply.
Returns
any The result of `setVar`.
Example Usage
character:addBoost("adrenaline", "stm", 10)
removeBoost(boostID, attribID)View Source
clearAllBoosts()View Source
Purpose
Clears every active attribute boost on the character.
Realm
Server
Returns
any The result of `setVar`.
Example Usage
character:clearAllBoosts()
setFlags(flags)View Source
Purpose
Replaces the character's entire flag string and triggers flag callbacks.
Realm
Server
Parameters
string flags The complete set of flags to store.
Example Usage
character:setFlags("pet")
giveFlags(flags)View Source
Purpose
Adds any missing flags from the supplied string.
Realm
Server
Parameters
string flags The flags to grant.
Example Usage
character:giveFlags("ab")
takeFlags(flags)View Source
Purpose
Removes any matching flags from the supplied string.
Realm
Server
Parameters
string flags The flags to revoke.
Example Usage
character:takeFlags("b")
save(callback)View Source
Purpose
Persists the character's field-backed variables to the database.
Realm
Server
Parameters
function callback optional Runs after a successful save.
Example Usage
character:save(function()
print("Character saved.")
end)
sync(receiver)View Source
Purpose
Sends this character's networked state to one player or every player.
Realm
Server
Parameters
Player receiver optional The player to sync to, or `nil` to sync to everyone.
Example Usage
character:sync()
character:sync(adminPlayer)
setup(noNetworking)View Source
Purpose
Applies the character to its owning player and optionally syncs inventories and character vars.
Realm
Server
Parameters
boolean noNetworking Whether to skip syncing inventories and character data.
Example Usage
character:setup()
kick()View Source
ban(time)View Source
Purpose
Bans the character until a timestamp or permanently, then saves and kicks it.
Realm
Server
Parameters
number time optional Ban duration in seconds. `nil` creates a permanent ban.
Example Usage
character:ban(3600)
character:ban()
delete()View Source
destroy()View Source
giveMoney(amount)View Source
takeMoney(amount)View Source
isMainCharacter()View Source
Purpose
Checks whether this character is set as the player's main character.
Realm
Server
Returns
boolean `true` when the owner's main character ID matches this character.
Example Usage
if character:isMainCharacter() then
print("This is the player's main character.")
end