Skip to content

nut.char

Character Management Library.

This module provides core logic for character creation, storage, validation, and synchronization in the NutScript framework. It manages character variables, metadata, and interactions across the server and client, enabling features like whitelisting, model selection, faction assignment, and inventory linking.

Functions

nut.char.create (data, callback)
nut.char.create

Internal

This is used internally - although you're able to use it you probably shouldn't.

Creates a new character in the database with the given data.

Parameters:

table data The character data table (name, model, faction, etc.)

function callback optional Callback function triggered after creation (receives charID)

nut.char.restore (client, callback, noCache, id)
nut.char.restore

Internal

This is used internally - although you're able to use it you probably shouldn't.

Restores a player's characters from the database.

Parameters:

Client client The player whose characters are being restored

function callback Function to call when restoration is complete

boolean noCache optional If true, skips caching (unused in current implementation)

number id optional Specific character ID to restore

nut.char.cleanUpForPlayer (client)
nut.char.cleanUpForPlayer

Internal

This is used internally - although you're able to use it you probably shouldn't.

Cleans up all character data for a player when they disconnect.

Parameters:

Client client The player whose character data should be cleaned up

nut.char.delete (id, client)
nut.char.delete

Internal

This is used internally - although you're able to use it you probably shouldn't.

Deletes a character from the database and cleans up related data.

Parameters:

number id The character ID to delete

Client client optional Player associated with the character

nut.char.new (data, id, client, steamID)
nut.char.new

Creates a new character object with the given data and metadata.

Parameters:

table data A table containing the character data.

integer id The ID of the character.

Client client The player associated with the character.

string steamID optional The SteamID of the player associated with the character.

Returns:

table The newly created character object.

nut.char.registerVar (key, data)
nut.char.registerVar

Sets up a new character variable.

Parameters:

string key A Unique key for the variable

table data Variable Data