lia.char
Character creation and management.
NOTE: For the most part you shouldn't use this library unless you know what you're doing. You can very easily corrupt character data using these functions!
Functions
cleanUpForPlayer(client)
This is an internal function! You are able to use it, but you risk unintended side effects if used incorrectly.
Cleans up a player's characters, removing them from memory and database.
Parameters
-
client
Player
The player whose characters to clean up.
create(data, callback)
Creates a character object with its assigned properties and saves it to the database.
Parameters
-
data
Table
Properties to assign to this character. If fields are missing from the table, then it will use the default value for that property
-
callback
Function
Function to call after the character saves
delete(id, client)
Deletes a character from memory and database.
Parameters
-
id
Integer
The ID of the character to delete.
-
client
Player
The player associated with the character.
getCharData(charID, key)
Loads data for a character from the database.
Parameters
-
charID
Integer
The ID of the character to load data for.
-
key
String
optional
key to retrieve a specific value from the character's data.
Returns
-
any
If key is provided, returns the value associated with that key in the character's data. Otherwise, returns the entire data table.
hookVar(varName, hookName, func)
Adds a hook function to be called when a character variable is modified.
Parameters
-
varName
String
The name of the character variable.
-
hookName
String
The name of the hook.
-
func
Function
The function to be called when the character variable is modified.
new(data, id, client, steamID)
This is an internal function! You are able to use it, but you risk unintended side effects if used incorrectly.
Creates a new empty Character object. If you are looking to create a usable character, see lia.char.create.
Parameters
-
data
Table
Character vars to assign
-
id
Integer
Unique ID of the character
-
client
Player
Player that will own the character
-
steamID
String
default: client:SteamID64()
SteamID64 of the player that will own the character
registerVar(key, data)
Registers a character variable with specified data and associated hooks.
Parameters
-
key
The key identifier for the character variable.
-
data
Table
The data associated with the character variable.
restore(client, callback, id)
Loads all of a player's characters into memory.
Parameters
-
client
Player
Player to load the characters for
-
callback
Function
default: nil
Function to call when the characters have been loaded their characters loaded which will skip the database query and load quicker
-
id
Integer
default: nil
The ID of a specific character to load instead of all of the player's characters
setCharData(charID, key, val)
Sets data for a character in the database and in memory.
Parameters
-
charID
Integer
The ID of the character to set data for.
-
key
String
The key of the data to set.
-
val
The value to set for the specified key.
Returns
-
any
True if the data was successfully set, false otherwise.