Skip to main content
Server Proxied to ug-core. ug-core stores and loads characters. A multicharacter resource shows the menu and calls this API. Characters belong to the player’s primary identifier.
Without this module, players are loaded as soon as they join, and accounts, jobs and gangs cannot be enabled.

GetAll

UgCharacter[]
The player’s live characters, ordered by creation.

Create

string
required
1 to 64 characters.
table
JSON data, up to 16 KB encoded.
Invalid input returns invalid_args instead of raising, since it usually comes from a player. New characters get the starting balances of every account.

Load

Loads one of the player’s characters. A loaded character is unloaded first. Then accounts, job and gang load, death state is restored when persisted, ug-core:Loaded becomes true, and ug-core:Players:Loaded fires.

Unload

Saves and unloads. The player goes back to not loaded and alive. Characters also unload when the player drops.

Delete

Soft delete: the row stays in ug_characters. The loaded character cannot be deleted.

GetActive

The loaded character. Use UgCore.Players.Get(source).characterId or the ug-core:Player statebag when you only need the id.

GetPosition

The last saved position as a vector4 (x, y, z, heading), or nil before the first save. MUST run in a thread.
  • The position is read from the ped on the server, never from the client.
  • It is saved on unload, disconnect and resource stop, and every positionInterval ms while playing.
  • A ped at the map origin has not spawned yet: the saved position is kept.
  • persistPosition = false in config/characters.lua stops saving.

Errors

Events

Unloaded also fires when the player drops.

Hooks

Statebags

The loaded character id is in UgCore.Enums.StateBags.Player as characterId. See Players.

Example