Character Meta
Character management system for the Lilia framework.
Overview
The character meta table provides comprehensive functionality for managing character data, attributes, and operations in the Lilia framework. It handles character creation, data persistence, attribute management, recognition systems, and character-specific operations. The meta table operates on both server and client sides, with the server managing character storage and validation while the client provides character data access and display. It includes integration with the database system for character persistence, inventory management for character items, and faction/class systems for character roles. The meta table ensures proper character data synchronization, attribute calculations with boosts, recognition between characters, and comprehensive character lifecycle management from creation to deletion.
tostring
đ Purpose
Converts the character object to a string representation
â° When Called
When displaying character information or debugging
âŠī¸ Returns
- string - Formatted character string with ID
đ Realm
Shared
đĄ Example Usage
đ° Low Complexity
-- Simple: Get character string representation
local charString = character:tostring()
print(charString) -- Output: "character[123]"
đ Medium Complexity
-- Medium: Use in debug messages
local char = player:getChar()
if char then
print("Character: " .. char:tostring())
end
âī¸ High Complexity
-- High: Use in logging system
local char = player:getChar()
lia.log.add(player, "action", "Character " .. char:tostring() .. " performed action")
eq
đ Purpose
Compares two character objects for equality based on their IDs
â° When Called
When checking if two character references point to the same character
âī¸ Parameters
| Parameter | Type | Description |
|---|---|---|
other |
character | The other character object to compare with |
âŠī¸ Returns
- boolean - True if both characters have the same ID, false otherwise
đ Realm
Shared
đĄ Example Usage
đ° Low Complexity
-- Simple: Compare two character objects
local char1 = player1:getChar()
local char2 = player2:getChar()
if char1:eq(char2) then
print("Same character")
end
đ Medium Complexity
-- Medium: Use in conditional logic
local targetChar = target:getChar()
local myChar = player:getChar()
if myChar:eq(targetChar) then
-- Handle self-targeting
end
âī¸ High Complexity
-- High: Use in character management system
for _, char in pairs(characterList) do
if char:eq(selectedCharacter) then
-- Process matching character
break
end
end
getID
đ Purpose
Retrieves the unique ID of the character
â° When Called
When you need to identify a specific character instance
âŠī¸ Returns
- number - The character's unique ID
đ Realm
Shared
đĄ Example Usage
đ° Low Complexity
-- Simple: Get character ID
local char = player:getChar()
local charID = char:getID()
print("Character ID: " .. charID)
đ Medium Complexity
-- Medium: Use ID for database operations
local char = player:getChar()
local charID = char:getID()
lia.db.query("SELECT * FROM chardata WHERE charID = " .. charID)
âī¸ High Complexity
-- High: Use ID in networking
net.Start("liaCharInfo")
net.WriteUInt(char:getID(), 32)
net.Send(player)
getPlayer
đ Purpose
Retrieves the player entity associated with this character
â° When Called
When you need to access the player who owns this character
âŠī¸ Returns
- Player - The player entity, or nil if not found
đ Realm
Shared
đĄ Example Usage
đ° Low Complexity
-- Simple: Get the player from character
local char = player:getChar()
local owner = char:getPlayer()
if IsValid(owner) then
print("Player: " .. owner:Name())
end
đ Medium Complexity
-- Medium: Use player for operations
local char = character:getPlayer()
if IsValid(char) then
char:SetPos(Vector(0, 0, 0))
end
âī¸ High Complexity
-- High: Use in networking and validation
local char = character:getPlayer()
if IsValid(char) then
net.Start("liaCharSync")
net.WriteEntity(char)
net.Broadcast()
end
getDisplayedName
đ Purpose
Gets the display name for a character based on recognition system
â° When Called
When displaying character names to other players
âī¸ Parameters
| Parameter | Type | Description |
|---|---|---|
client |
Player | The client who is viewing the character |
âŠī¸ Returns
- string - The name to display (real name, fake name, or "unknown")
đ Realm
Shared
đĄ Example Usage
đ° Low Complexity
-- Simple: Get display name for a player
local char = target:getChar()
local displayName = char:getDisplayedName(player)
print("You see: " .. displayName)
đ Medium Complexity
-- Medium: Use in chat system
local char = speaker:getChar()
local displayName = char:getDisplayedName(listener)
chat.AddText(Color(255, 255, 255), displayName .. ": " .. message)
âī¸ High Complexity
-- High: Use in UI display system
local char = target:getChar()
local displayName = char:getDisplayedName(client)
local nameColor = displayName == "unknown" and Color(128, 128, 128) or Color(255, 255, 255)
draw.SimpleText(displayName, "DermaDefault", x, y, nameColor)
hasMoney
đ Purpose
Checks if the character has enough money for a transaction
â° When Called
Before processing purchases, payments, or money transfers
âī¸ Parameters
| Parameter | Type | Description |
|---|---|---|
amount |
number | The amount of money to check for |
âŠī¸ Returns
- boolean - True if character has sufficient funds, false otherwise
đ Realm
Shared
đĄ Example Usage
đ° Low Complexity
-- Simple: Check if player can afford an item
local char = player:getChar()
if char:hasMoney(100) then
print("Can afford item")
end
đ Medium Complexity
-- Medium: Use in shop system
local char = buyer:getChar()
local itemPrice = 500
if char:hasMoney(itemPrice) then
char:takeMoney(itemPrice)
char:giveItem("item_id")
end
âī¸ High Complexity
-- High: Use in complex transaction system
local char = player:getChar()
local totalCost = calculateTotalCost(items)
if char:hasMoney(totalCost) then
processTransaction(char, items, totalCost)
else
showInsufficientFundsError(char, totalCost)
end
hasFlags
đ Purpose
Checks if the character has any of the specified flags
â° When Called
When checking permissions or access rights for a character
âī¸ Parameters
| Parameter | Type | Description |
|---|---|---|
flagStr |
string | String containing flags to check for |
âŠī¸ Returns
- boolean - True if character has any of the specified flags, false otherwise
đ Realm
Shared
đĄ Example Usage
đ° Low Complexity
-- Simple: Check for admin flag
local char = player:getChar()
if char:hasFlags("a") then
print("Player is admin")
end
đ Medium Complexity
-- Medium: Check multiple flags
local char = player:getChar()
if char:hasFlags("ad") then
-- Player has admin or donator flag
grantSpecialAccess(char)
end
âī¸ High Complexity
-- High: Use in permission system
local char = player:getChar()
local requiredFlags = "adm"
if char:hasFlags(requiredFlags) then
showAdminPanel(player)
else
showAccessDenied(player)
end
getItemWeapon
đ Purpose
Checks if the character has a weapon item equipped
â° When Called
When validating weapon usage or checking equipped items
âī¸ Parameters
| Parameter | Type | Description |
|---|---|---|
requireEquip |
boolean | Whether to check if item is equipped (default: true) |
âŠī¸ Returns
- boolean - True if character has the weapon item, false otherwise
đ Realm
Shared
đĄ Example Usage
đ° Low Complexity
-- Simple: Check if player has weapon
local char = player:getChar()
if char:getItemWeapon() then
print("Player has weapon")
end
đ Medium Complexity
-- Medium: Check weapon with equip requirement
local char = player:getChar()
if char:getItemWeapon(true) then
-- Player has equipped weapon
allowWeaponUse(char)
end
âī¸ High Complexity
-- High: Use in weapon validation system
local char = player:getChar()
local hasWeapon = char:getItemWeapon(requireEquip)
if hasWeapon then
processWeaponAction(char, action)
else
showWeaponRequiredError(char)
end
getAttrib
đ Purpose
Gets the value of a character attribute including boosts
â° When Called
When checking character stats or calculating bonuses
âī¸ Parameters
| Parameter | Type | Description |
|---|---|---|
key |
string | The attribute key to retrieve |
default |
number | Default value if attribute doesn't exist (default: 0) |
âŠī¸ Returns
- number - The attribute value with boosts applied
đ Realm
Shared
đĄ Example Usage
đ° Low Complexity
-- Simple: Get character strength
local char = player:getChar()
local strength = char:getAttrib("str")
print("Strength: " .. strength)
đ Medium Complexity
-- Medium: Use in skill checks
local char = player:getChar()
local intelligence = char:getAttrib("int", 10)
if intelligence > 15 then
grantSpecialAbility(char)
end
âī¸ High Complexity
-- High: Use in complex calculations
local char = player:getChar()
local baseStr = char:getAttrib("str")
local baseInt = char:getAttrib("int")
local totalBonus = baseStr + baseInt
calculateCombatEffectiveness(char, totalBonus)
getBoost
đ Purpose
Gets the boost table for a specific attribute
â° When Called
When checking or modifying attribute boosts
âī¸ Parameters
| Parameter | Type | Description |
|---|---|---|
attribID |
string | The attribute ID to get boosts for |
âŠī¸ Returns
- table - Table containing boost values for the attribute
đ Realm
Shared
đĄ Example Usage
đ° Low Complexity
-- Simple: Get strength boosts
local char = player:getChar()
local strBoosts = char:getBoost("str")
if strBoosts then
print("Has strength boosts")
end
đ Medium Complexity
-- Medium: Check specific boost
local char = player:getChar()
local boosts = char:getBoost("int")
if boosts and boosts["item_boost"] then
print("Has item intelligence boost")
end
âī¸ High Complexity
-- High: Use in boost management system
local char = player:getChar()
local boosts = char:getBoost(attribID)
if boosts then
for boostID, value in pairs(boosts) do
processBoost(char, attribID, boostID, value)
end
end
doesRecognize
đ Purpose
Checks if the character recognizes another character by ID
â° When Called
When determining if one character knows another character's identity
âī¸ Parameters
| Parameter | Type | Description |
|---|---|---|
id |
**number | character** |
âŠī¸ Returns
- boolean - True if character recognizes the other, false otherwise
đ Realm
Shared
đĄ Example Usage
đ° Low Complexity
-- Simple: Check if player recognizes target
local char = player:getChar()
local targetChar = target:getChar()
if char:doesRecognize(targetChar) then
print("Player recognizes target")
end
đ Medium Complexity
-- Medium: Use in recognition system
local char = player:getChar()
local targetID = target:getChar():getID()
if char:doesRecognize(targetID) then
showRealName(char, target)
else
showUnknownName(char, target)
end
âī¸ High Complexity
-- High: Use in complex recognition logic
local char = player:getChar()
for _, otherChar in pairs(characterList) do
if char:doesRecognize(otherChar) then
addToKnownList(char, otherChar)
end
end
doesFakeRecognize
đ Purpose
Checks if the character has fake recognition of another character
â° When Called
When determining if character knows a fake name for another character
âī¸ Parameters
| Parameter | Type | Description |
|---|---|---|
id |
**number | character** |
âŠī¸ Returns
- boolean - True if character has fake recognition, false otherwise
đ Realm
Shared
đĄ Example Usage
đ° Low Complexity
-- Simple: Check fake recognition
local char = player:getChar()
local targetChar = target:getChar()
if char:doesFakeRecognize(targetChar) then
print("Player knows fake name")
end
đ Medium Complexity
-- Medium: Use in disguise system
local char = player:getChar()
local targetID = target:getChar():getID()
if char:doesFakeRecognize(targetID) then
showFakeName(char, target)
else
showUnknownName(char, target)
end
âī¸ High Complexity
-- High: Use in complex identity system
local char = player:getChar()
for _, otherChar in pairs(characterList) do
if char:doesFakeRecognize(otherChar) then
addToFakeKnownList(char, otherChar)
end
end
setData
đ Purpose
Sets character data and optionally syncs it to database and clients
â° When Called
When storing character-specific data that needs persistence
âī¸ Parameters
| Parameter | Type | Description |
|---|---|---|
k |
**string | table** |
v |
any | Value to set (ignored if k is table) |
noReplication |
boolean | Skip client replication (default: false) |
receiver |
Player | Specific client to send to (default: character owner) |
âŠī¸ Returns
- None
đ Realm
Server
đĄ Example Usage
đ° Low Complexity
đ Medium Complexity
-- Medium: Set multiple values
local char = player:getChar()
char:setData({
["level"] = 5,
["experience"] = 1000,
["class"] = "warrior"
})
âī¸ High Complexity
-- High: Use in data management system
local char = player:getChar()
local dataToSet = {
["inventory"] = serializeInventory(inventory),
["position"] = player:GetPos(),
["health"] = player:Health()
}
char:setData(dataToSet, nil, false, specificPlayer)
getData
đ Purpose
Retrieves character data by key or returns all data
â° When Called
When accessing stored character-specific data
âī¸ Parameters
| Parameter | Type | Description |
|---|---|---|
key |
string | The data key to retrieve |
default |
any | Default value if key doesn't exist |
âŠī¸ Returns
- any - The data value, all data table, or default value
đ Realm
Shared
đĄ Example Usage
đ° Low Complexity
-- Simple: Get specific data
local char = player:getChar()
local level = char:getData("level", 1)
print("Level: " .. level)
đ Medium Complexity
-- Medium: Get all character data
local char = player:getChar()
local allData = char:getData()
for key, value in pairs(allData) do
print(key .. ": " .. tostring(value))
end
âī¸ High Complexity
-- High: Use in data processing system
local char = player:getChar()
local inventory = char:getData("inventory", {})
local position = char:getData("position", Vector(0, 0, 0))
processCharacterState(char, inventory, position)
isBanned
đ Purpose
Checks if the character is currently banned
â° When Called
When validating character access or checking ban status
âŠī¸ Returns
- boolean - True if character is banned, false otherwise
đ Realm
Shared
đĄ Example Usage
đ° Low Complexity
-- Simple: Check if character is banned
local char = player:getChar()
if char:isBanned() then
print("Character is banned")
end
đ Medium Complexity
-- Medium: Use in login validation
local char = player:getChar()
if char:isBanned() then
player:Kick("Your character is banned")
return
end
âī¸ High Complexity
-- High: Use in ban management system
local char = player:getChar()
if char:isBanned() then
local banTime = char:getBanned()
local banReason = char:getData("banReason", "No reason provided")
showBanMessage(player, banTime, banReason)
end
recognize
đ Purpose
Makes the character recognize another character (with optional fake name)
â° When Called
When establishing recognition between characters
âī¸ Parameters
| Parameter | Type | Description |
|---|---|---|
character |
**number | character** |
name |
string | Optional fake name to assign (default: nil) |
âŠī¸ Returns
- boolean - True if recognition was successful
đ Realm
Server
đĄ Example Usage
đ° Low Complexity
-- Simple: Recognize another character
local char = player:getChar()
local targetChar = target:getChar()
char:recognize(targetChar)
đ Medium Complexity
-- Medium: Recognize with fake name
local char = player:getChar()
local targetID = target:getChar():getID()
char:recognize(targetID, "John Doe")
âī¸ High Complexity
-- High: Use in recognition system
local char = player:getChar()
for _, otherChar in pairs(characterList) do
if shouldRecognize(char, otherChar) then
char:recognize(otherChar, getFakeName(char, otherChar))
end
end
joinClass
đ Purpose
Makes the character join a specific class (faction job)
â° When Called
When changing character class or job within their faction
âī¸ Parameters
| Parameter | Type | Description |
|---|---|---|
class |
string | The class name to join |
isForced |
boolean | Whether to force the class change (default: false) |
âŠī¸ Returns
- boolean - True if class change was successful, false otherwise
đ Realm
Server
đĄ Example Usage
đ° Low Complexity
đ Medium Complexity
-- Medium: Force class change
local char = player:getChar()
if char:joinClass("police", true) then
print("Successfully joined police force")
end
âī¸ High Complexity
-- High: Use in class management system
local char = player:getChar()
local newClass = determineClass(char, player)
if char:joinClass(newClass) then
updateCharacterUI(player)
notifyClassChange(player, newClass)
else
showClassChangeError(player, newClass)
end
kickClass
đ Purpose
Removes the character from their current class and assigns default class
â° When Called
When removing character from their current job or class
âŠī¸ Returns
- None
đ Realm
Server
đĄ Example Usage
đ° Low Complexity
đ Medium Complexity
-- Medium: Use in demotion system
local char = player:getChar()
if char:getClass() == "police" then
char:kickClass()
notifyDemotion(player)
end
âī¸ High Complexity
-- High: Use in class management system
local char = player:getChar()
local oldClass = char:getClass()
char:kickClass()
logClassChange(player, oldClass, "none")
updateCharacterPermissions(player)
updateAttrib
đ Purpose
Updates a character attribute by adding to the current value
â° When Called
When modifying character stats through gameplay or admin actions
âī¸ Parameters
| Parameter | Type | Description |
|---|---|---|
key |
string | The attribute key to update |
value |
number | The amount to add to the current attribute value |
âŠī¸ Returns
- None
đ Realm
Server
đĄ Example Usage
đ° Low Complexity
đ Medium Complexity
-- Medium: Use in level up system
local char = player:getChar()
char:updateAttrib("int", 2)
char:updateAttrib("str", 1)
notifyStatIncrease(player, "int", 2)
âī¸ High Complexity
-- High: Use in complex attribute system
local char = player:getChar()
local statGains = calculateStatGains(char, experience)
for stat, gain in pairs(statGains) do
char:updateAttrib(stat, gain)
logStatChange(player, stat, gain)
end
setAttrib
đ Purpose
Sets a character attribute to a specific value
â° When Called
When setting character stats to exact values
âī¸ Parameters
| Parameter | Type | Description |
|---|---|---|
key |
string | The attribute key to set |
value |
number | The exact value to set the attribute to |
âŠī¸ Returns
- None
đ Realm
Server
đĄ Example Usage
đ° Low Complexity
đ Medium Complexity
-- Medium: Use in character creation
local char = player:getChar()
char:setAttrib("str", 5)
char:setAttrib("int", 8)
char:setAttrib("dex", 6)
âī¸ High Complexity
-- High: Use in admin system
local char = player:getChar()
local newStats = calculateNewStats(char, adminCommand)
for stat, value in pairs(newStats) do
char:setAttrib(stat, value)
logAdminAction(admin, "set " .. stat .. " to " .. value)
end
addBoost
đ Purpose
Adds a temporary boost to a character attribute
â° When Called
When applying temporary stat bonuses from items, spells, or effects
âī¸ Parameters
| Parameter | Type | Description |
|---|---|---|
boostID |
string | Unique identifier for this boost |
attribID |
string | The attribute to boost |
boostAmount |
number | The amount to boost the attribute by |
âŠī¸ Returns
- boolean - True if boost was added successfully
đ Realm
Server
đĄ Example Usage
đ° Low Complexity
đ Medium Complexity
-- Medium: Use in item system
local char = player:getChar()
local item = char:getItem("strength_potion")
if item then
char:addBoost("item_" .. item:getID(), "str", item:getData("boostAmount", 3))
end
âī¸ High Complexity
-- High: Use in complex boost system
local char = player:getChar()
local boosts = calculateBoosts(char, equipment)
for boostID, boostData in pairs(boosts) do
char:addBoost(boostID, boostData.attrib, boostData.amount)
end
removeBoost
đ Purpose
Removes a temporary boost from a character attribute
â° When Called
When removing temporary stat bonuses from items, spells, or effects
âī¸ Parameters
| Parameter | Type | Description |
|---|---|---|
boostID |
string | Unique identifier for the boost to remove |
attribID |
string | The attribute the boost was applied to |
âŠī¸ Returns
- boolean - True if boost was removed successfully
đ Realm
Server
đĄ Example Usage
đ° Low Complexity
-- Simple: Remove strength boost
local char = player:getChar()
char:removeBoost("potion_str", "str")
đ Medium Complexity
-- Medium: Use in item removal
local char = player:getChar()
local item = char:getItem("strength_potion")
if item then
char:removeBoost("item_" .. item:getID(), "str")
end
âī¸ High Complexity
-- High: Use in boost cleanup system
local char = player:getChar()
local expiredBoosts = getExpiredBoosts(char)
for boostID, attribID in pairs(expiredBoosts) do
char:removeBoost(boostID, attribID)
end
clearAllBoosts
đ Purpose
Removes all attribute boosts from this character
â° When Called
When clearing all effects from a character (e.g., when switching characters)
âŠī¸ Returns
- boolean - True if boosts were cleared successfully
đ Realm
Server
đĄ Example Usage
đ° Low Complexity
đ Medium Complexity
-- Medium: Clear boosts when switching characters
local currentChar = client:getChar()
if currentChar then
currentChar:clearAllBoosts()
end
âī¸ High Complexity
-- High: Clear boosts as part of full effect cleanup
local char = player:getChar()
char:clearAllBoosts()
-- Additional cleanup for other effects...
setFlags
đ Purpose
Sets the character flags to a specific string
â° When Called
When changing character permissions or access rights
âī¸ Parameters
| Parameter | Type | Description |
|---|---|---|
flags |
string | The flags string to set |
âŠī¸ Returns
- None
đ Realm
Server
đĄ Example Usage
đ° Low Complexity
đ Medium Complexity
-- Medium: Use in permission system
local char = player:getChar()
char:setFlags("ad")
notifyPermissionChange(player, "admin and donator")
âī¸ High Complexity
-- High: Use in complex permission management
local char = player:getChar()
local newFlags = calculateFlags(char, role, level)
char:setFlags(newFlags)
updateCharacterPermissions(player)
logPermissionChange(admin, player, newFlags)
giveFlags
đ Purpose
Adds flags to the character without removing existing ones
â° When Called
When granting additional permissions to a character
âī¸ Parameters
| Parameter | Type | Description |
|---|---|---|
flags |
string | The flags to add to the character |
âŠī¸ Returns
- None
đ Realm
Server
đĄ Example Usage
đ° Low Complexity
đ Medium Complexity
-- Medium: Use in reward system
local char = player:getChar()
char:giveFlags("v")
notifyReward(player, "VIP status granted")
âī¸ High Complexity
-- High: Use in complex permission system
local char = player:getChar()
local earnedFlags = calculateEarnedFlags(char, achievements)
char:giveFlags(earnedFlags)
updateCharacterUI(player)
logFlagGrant(admin, player, earnedFlags)
takeFlags
đ Purpose
Removes flags from the character
â° When Called
When revoking permissions or access rights from a character
âī¸ Parameters
| Parameter | Type | Description |
|---|---|---|
flags |
string | The flags to remove from the character |
âŠī¸ Returns
- None
đ Realm
Server
đĄ Example Usage
đ° Low Complexity
đ Medium Complexity
-- Medium: Use in demotion system
local char = player:getChar()
char:takeFlags("a")
notifyDemotion(player, "Admin status revoked")
âī¸ High Complexity
-- High: Use in complex permission system
local char = player:getChar()
local revokedFlags = calculateRevokedFlags(char, violations)
char:takeFlags(revokedFlags)
updateCharacterUI(player)
logFlagRevoke(admin, player, revokedFlags)
save
đ Purpose
Saves the character data to the database
â° When Called
When persisting character changes to the database
âī¸ Parameters
| Parameter | Type | Description |
|---|---|---|
callback |
function | Optional callback function to execute after save |
âŠī¸ Returns
- None
đ Realm
Server
đĄ Example Usage
đ° Low Complexity
đ Medium Complexity
-- Medium: Save with callback
local char = player:getChar()
char:save(function()
print("Character saved successfully")
end)
âī¸ High Complexity
-- High: Use in save system
local char = player:getChar()
char:save(function()
updateCharacterCache(char)
notifySaveComplete(player)
logCharacterSave(char)
end)
sync
đ Purpose
Synchronizes character data with clients
â° When Called
When updating character information on client side
âī¸ Parameters
| Parameter | Type | Description |
|---|---|---|
receiver |
Player | Specific client to sync to (default: all players) |
âŠī¸ Returns
- None
đ Realm
Server
đĄ Example Usage
đ° Low Complexity
đ Medium Complexity
âī¸ High Complexity
-- High: Use in sync system
local char = player:getChar()
char:sync(receiver)
updateCharacterUI(receiver)
logCharacterSync(char, receiver)
setup
đ Purpose
Sets up the character for the player (model, team, inventory, etc.)
â° When Called
When loading a character for a player
âī¸ Parameters
| Parameter | Type | Description |
|---|---|---|
noNetworking |
boolean | Skip networking setup (default: false) |
âŠī¸ Returns
- None
đ Realm
Server
đĄ Example Usage
đ° Low Complexity
đ Medium Complexity
âī¸ High Complexity
-- High: Use in character loading system
local char = player:getChar()
char:setup(noNetworking)
updateCharacterUI(player)
logCharacterLoad(char)
kick
đ Purpose
Kicks the character from the server
â° When Called
When removing a character from the game
âŠī¸ Returns
- None
đ Realm
Server
đĄ Example Usage
đ° Low Complexity
đ Medium Complexity
âī¸ High Complexity
-- High: Use in complex kick system
local char = player:getChar()
char:kick()
logCharacterKick(char, reason)
updateCharacterList()
ban
đ Purpose
Bans the character for a specified time or permanently
â° When Called
When applying a ban to a character
âī¸ Parameters
| Parameter | Type | Description |
|---|---|---|
time |
number | Ban duration in seconds (nil for permanent ban) |
âŠī¸ Returns
- None
đ Realm
Server
đĄ Example Usage
đ° Low Complexity
đ Medium Complexity
âī¸ High Complexity
-- High: Use in ban system
local char = player:getChar()
char:ban(banTime)
logCharacterBan(char, banTime, reason)
notifyBan(admin, player, banTime)
delete
đ Purpose
Deletes the character from the database
â° When Called
When permanently removing a character
âŠī¸ Returns
- None
đ Realm
Server
đĄ Example Usage
đ° Low Complexity
đ Medium Complexity
-- Medium: Use in admin system
local char = target:getChar()
char:delete()
notifyDeletion(admin, target)
âī¸ High Complexity
-- High: Use in complex deletion system
local char = player:getChar()
char:delete()
logCharacterDeletion(char, reason)
updateCharacterList()
destroy
đ Purpose
Destroys the character object and removes it from memory
â° When Called
When cleaning up character data from memory
âŠī¸ Returns
- None
đ Realm
Server
đĄ Example Usage
đ° Low Complexity
đ Medium Complexity
âī¸ High Complexity
-- High: Use in complex cleanup system
local char = player:getChar()
char:destroy()
logCharacterDestroy(char)
updateCharacterCache()
giveMoney
đ Purpose
Gives money to the character
â° When Called
When adding money to a character's account
âī¸ Parameters
| Parameter | Type | Description |
|---|---|---|
amount |
number | The amount of money to give |
âŠī¸ Returns
- boolean - True if money was given successfully
đ Realm
Server
đĄ Example Usage
đ° Low Complexity
đ Medium Complexity
-- Medium: Use in reward system
local char = player:getChar()
char:giveMoney(rewardAmount)
notifyReward(player, "You received $" .. rewardAmount)
âī¸ High Complexity
-- High: Use in complex economy system
local char = player:getChar()
char:giveMoney(amount)
logMoneyTransaction(char, amount, "reward")
updateEconomyStats()
takeMoney
đ Purpose
Takes money from the character
â° When Called
When removing money from a character's account
âī¸ Parameters
| Parameter | Type | Description |
|---|---|---|
amount |
number | The amount of money to take |
âŠī¸ Returns
- boolean - True if money was taken successfully
đ Realm
Server
đĄ Example Usage
đ° Low Complexity
đ Medium Complexity
-- Medium: Use in payment system
local char = player:getChar()
char:takeMoney(itemPrice)
notifyPayment(player, "You paid $" .. itemPrice)
âī¸ High Complexity
-- High: Use in complex economy system
local char = player:getChar()
char:takeMoney(amount)
logMoneyTransaction(char, -amount, "purchase")
updateEconomyStats()