Characters lets every player own several characters and play one of them at a time. A character is a Character record that belongs to the player's user record and stores a name, gender, physical description, model and skin, along with the health, armor and reserve ammo its player had when it was last saved. Players create, load and delete their characters in the main menu, which opens after the intro when they join; until a character is loaded the player stays hidden and dead and the HUD is not drawn. The Characters functions create, save, delete, ban and edit characters on the server, and the Player extensions return a player's characters and the fields of the active one.

A player may have as many characters as the character_limit config allows, and a name that a player picks has to be unlike the name of any other character. Staff can ban a character with /charban add: it can then be neither loaded nor deleted until /charban remove lifts the ban. Players change their own description with CharPhysDesc.

Other plugins build on it through hooks: PlayerCreateCharacter validates the data of a new character, PostCreateCharacter and SaveCharacterData let them keep their own fields on a character, OnActiveCharacterSet and PostCharacterLoaded tell them that a character has been loaded, and AddCharacterCreationMenuStages and AddMainMenuItems add stages to the character creation screen and buttons to the main menu. GetCharacterLimit changes the limit for a player, and PlayerCanUseCharacter, PlayerCanSwitchCharacter and PlayerCanDeleteCharacter can refuse a request to load or delete a character with a reason. PlayerNeedsCharacter lets a player stay in the world without a character, GetCharacterOwner gives a new character to another user record than its creator's, and Characters.activate and Player:clear_active_character let a player play a character of another record and drop it again, which runs OnActiveCharacterCleared. A plugin that only needs to remember something about a character can keep it in the generic character data (Player:set_character_data) instead of adding a column.

Summary

Hooks

Reads the names of all characters from the database, so that Characters.is_name_taken also knows the characters of players who are not connected.
Adds the general stage (gender, name, description and model) to character creation.
Adds the continue, create character, load character and disconnect buttons to the main menu.
Adds the main menu entry to the tab menu.
Adds the physical description to the lines drawn when looking at a player.
Holds the loading screen at 75% until the character list has arrived from the server.
Spawns the player and applies the character's model, skin, health, armor and ammo, then runs the PostCharacterLoaded hook.
Saves the player's current character before they switch to another one.
Opens the main menu after the intro if the local player has no character and needs one (see Characters.needs_character), retrying on a timer until the panel can be created.
Registers the main menu and character creation panels with the theme, and recreates the main menu if it is currently open.
Applies the character's skin to the model shown in a character panel.
Refuses to let a player switch characters while they are dead or ragdolled.
Validates character creation data: the presence of the player's database record, the character limit, the length of the name, the length of the description unless it was generated, gender, model and skin and, unless the name was generated, that no other character has the name.
Saves the character of a player who died, unless the character is banned: a banned character has nothing of its player to keep, and Characters.set_banned saves it before it kills the player.
Keeps a player whose active character is banned from respawning.
Saves the disconnecting player's character and stops any further saving of their data.
Opens the intro panel if the local player has no active character.
Saves the player's character; called once a minute for every player.
Sends the character list to the player as soon as they have initialized, then runs the PostRestoreCharacters hook.
Forwards the PostCharacterLoaded hook to the player's client, passing the character ID.
Replaces line breaks in the new character's physical description with ' | '.
Hides, locks and silently kills players who spawn without an active character or with a banned one, unless Characters.needs_character exempts them.
Adds the Steam name to a scoreboard player card and, unless an IsCharacterCardVisible hook returns false, the player's model icon and physical description.
Registers the 'character' condition, which compares a player's active character ID.
Writes the health, armor and reserve ammo of the player into their active character before it is saved.
Saves the active character of every connected player.
Keeps the loading screen visible until the intro panel has been created.
Hides the HUD while the local player has no active character and needs one.
Makes the mapscene render while the intro panel or main menu is open.
Lets the scoreboard hide only when the local player has an active character or does not need one.
Lets the scoreboard show only when the local player has an active character or does not need one.
Tick()client
Mutes the menu music while the game window is unfocused and fades it out and stops it once the intro panel is gone.

Functions

Makes a character the active character of a player.
Returns the networkable data of every character of a player.
Checks whether a player may delete one of their characters.
Checks whether a player may load one of their characters.
Changes the physical description of a player's active character on their own request.
Creates a character for a player unless a PlayerCreateCharacter hook rejects the data.
Destroys one of the player's characters, removes it from their record, frees its name and resends the character list to the player.
Finds the characters that have a name, compared without regard to letter case.
Records that a character no longer bears a name.
Returns a value from the generic data of a character.
Returns how many characters a player may have: the character_limit config, unless a GetCharacterLimit hook returns another number.
Returns the player a character belongs to, if they are on the server.
Checks whether a key of the generic character data is sent to the owner of the character.
Checks whether a character of any player, connected or not, already has a name.
Checks whether a player has as many characters as they may have.
Checks whether a player has to have an active character to be in the world.
Makes the server send a key of the generic character data to the owner of the character.
Opens the main menu on the client of a player, or refreshes its buttons when it is already open, and optionally shows a message in it.
Records that a character bears a name, so that Characters.is_name_taken knows it.
Gives a player the health, armor and reserve ammo saved with a character.
Runs the SaveCharacterData hook and saves the player's record to the database, unless a PreSaveCharacter hook returns false.
Sends the networkable data of all of a player's characters to that player.
Bans or unbans a character and saves it.
Sets a value in the generic data of a character.
Changes the physical description of the player's active character, networks it and runs the CharacterDescChanged hook.
Changes the gender of the player's active character, networks it and runs the CharacterGenderChanged hook.
Changes the model of the player and of their active character, networks it and runs the CharacterModelChanged hook.
Changes the name of the player's active character, networks it and runs the CharacterNameChanged hook.
Writes the health, armor and reserve ammo of a player into a character.
Builds the table of character fields that is sent to the owning client: id, user_id, steam_id, name, gender, phys_desc, model, skin, banned and custom_data, which holds the keys of the generic data registered with Characters.network_data.

Hooks

Characters:ActiveRecordReady()

server plugins/characters/plugin/sv_hooks.lua:8

Implements hook ActiveRecordReady

Reads the names of all characters from the database, so that Characters.is_name_taken also knows the characters of players who are not connected.

Characters:AddCharacterCreationMenuStages(panel)

client plugins/characters/plugin/cl_hooks.lua:228

Implements hook AddCharacterCreationMenuStages

Adds the general stage (gender, name, description and model) to character creation.

Parameters

  • panel Panel the character creation menu

Characters:AddMainMenuItems(panel, _sidebar)

client plugins/characters/plugin/cl_hooks.lua:252

Implements hook AddMainMenuItems

Adds the continue, create character, load character and disconnect buttons to the main menu. There is no continue button while the active character is banned, and the create button only shows a notice once the player has as many characters as they may have.

Parameters

  • panel Panel the main menu
  • _sidebar Panel the main menu sidebar

Characters:AddTabMenuItems(menu)

client plugins/characters/plugin/cl_hooks.lua:118

Implements hook AddTabMenuItems

Adds the main menu entry to the tab menu.

Parameters

  • menu Panel the tab menu

Characters:GetDrawPlayerInfo(target, _x, _y, _distance, lines)

client plugins/characters/plugin/cl_hooks.lua:238

Implements hook GetDrawPlayerInfo

Adds the physical description to the lines drawn when looking at a player.

Parameters

  • target Player
  • _x Number
  • _y Number
  • _distance Number
  • lines Map line definitions keyed by ID, modified in place

Characters:GetLoadingScreenMessage()

client plugins/characters/plugin/cl_hooks.lua:52

Implements hook GetLoadingScreenMessage

Holds the loading screen at 75% until the character list has arrived from the server.

Returns

  • String message
  • Number percentage; nothing once the characters have arrived

Characters:OnActiveCharacterSet(owner, character)

server plugins/characters/plugin/sv_hooks.lua:140

Implements hook OnActiveCharacterSet

Spawns the player and applies the character's model, skin, health, armor and ammo, then runs the PostCharacterLoaded hook.

Parameters

  • owner Player
  • character Character

Characters:OnCharacterChange(owner, _new_char, _old_char)

server plugins/characters/plugin/sv_hooks.lua:161

Implements hook OnCharacterChange

Saves the player's current character before they switch to another one.

Parameters

  • owner Player
  • _new_char Character
  • _old_char Character

Characters:OnIntroPanelRemoved()

client plugins/characters/plugin/cl_hooks.lua:68

Implements hook OnIntroPanelRemoved

Opens the main menu after the intro if the local player has no character and needs one (see Characters.needs_character), retrying on a timer until the panel can be created.

Characters:OnThemeLoaded(current_theme)

client plugins/characters/plugin/cl_hooks.lua:91

Implements hook OnThemeLoaded

Registers the main menu and character creation panels with the theme, and recreates the main menu if it is currently open.

Parameters

  • current_theme ThemeBase

Characters:PanelCharacterSet(panel, char_data)

client plugins/characters/plugin/cl_hooks.lua:313

Implements hook PanelCharacterSet

Applies the character's skin to the model shown in a character panel.

Parameters

  • panel Panel the character panel
  • char_data Map networked character data

Characters:PlayerCanSwitchCharacter(actor, _character, _current)

server plugins/characters/plugin/sv_hooks.lua:67

Implements hook PlayerCanSwitchCharacter

Refuses to let a player switch characters while they are dead or ragdolled.

Parameters

  • actor Player
  • _character Character the character the player wants to load
  • _current Character the active character of the player

Returns

  • Boolean false and String the reason when the switch is refused, otherwise nil

Characters:PlayerCreateCharacter(actor, data)

server plugins/characters/plugin/sv_hooks.lua:185

Implements hook PlayerCreateCharacter

Validates character creation data: the presence of the player's database record, the character limit, the length of the name, the length of the description unless it was generated, gender, model and skin and, unless the name was generated, that no other character has the name. Text that is not valid UTF-8 is rejected.

Parameters

  • actor Player
  • data Map character creation data

Returns

  • Number CHAR_ERR_* code when the data is rejected, otherwise nil

Characters:PlayerDeath(victim, _inflictor, _attacker)

server plugins/characters/plugin/sv_hooks.lua:56

Saves the character of a player who died, unless the character is banned: a banned character has nothing of its player to keep, and Characters.set_banned saves it before it kills the player.

Parameters

  • victim Player
  • _inflictor Entity
  • _attacker Entity

Characters:PlayerDeathThink(actor)

server plugins/characters/plugin/sv_hooks.lua:44

Implements hook PlayerDeathThink

Keeps a player whose active character is banned from respawning.

Parameters

  • actor Player

Returns

  • Boolean false while the active character is banned, otherwise nil

Characters:PlayerDisconnected(actor)

server plugins/characters/plugin/sv_hooks.lua:92

Implements hook PlayerDisconnected

Saves the disconnecting player's character and stops any further saving of their data.

Parameters

  • actor Player

Characters:PlayerInitialized()

client plugins/characters/plugin/cl_hooks.lua:40

Implements hook PlayerInitialized

Opens the intro panel if the local player has no active character.

Characters:PlayerOneMinute(actor)

server plugins/characters/plugin/sv_hooks.lua:167

Implements hook PlayerOneMinute

Saves the player's character; called once a minute for every player.

Parameters

  • actor Player

Characters:PlayerRestored(actor)

server plugins/characters/plugin/sv_hooks.lua:100

Implements hook PlayerRestored

Sends the character list to the player as soon as they have initialized, then runs the PostRestoreCharacters hook.

Parameters

  • actor Player

Characters:PostCharacterLoaded(owner, character)

shared plugins/characters/plugin/sv_hooks.lua:132

Implements hook PostCharacterLoaded

On the server

Forwards the PostCharacterLoaded hook to the player's client, passing the character ID.

Parameters

  • owner Player
  • character Character

On the client

Closes the main menu after a character has been loaded.

Parameters

  • _char_id Number

Defined in

Characters:PostCreateCharacter(_owner, char, _char_data)

server plugins/characters/plugin/sv_hooks.lua:125

Implements hook PostCreateCharacter

Replaces line breaks in the new character's physical description with ' | '.

Parameters

  • _owner Player
  • char Character the character being created
  • _char_data Map character creation data

Characters:PostPlayerSpawn(actor)

server plugins/characters/plugin/sv_hooks.lua:26

Implements hook PostPlayerSpawn

Hides, locks and silently kills players who spawn without an active character or with a banned one, unless Characters.needs_character exempts them.

Parameters

  • actor Player

Characters:RebuildScoreboardPlayerCard(card, target)

client plugins/characters/plugin/cl_hooks.lua:172

Implements hook RebuildScoreboardPlayerCard

Adds the Steam name to a scoreboard player card and, unless an IsCharacterCardVisible hook returns false, the player's model icon and physical description.

Parameters

  • card Panel the scoreboard player card
  • target Player

Characters:RegisterConditions()

shared plugins/characters/plugin/sh_plugin.lua:38

Implements hook RegisterConditions

Registers the 'character' condition, which compares a player's active character ID.

Characters:SaveCharacterData(owner, character)

server plugins/characters/plugin/sv_hooks.lua:82

Implements hook SaveCharacterData

Writes the health, armor and reserve ammo of the player into their active character before it is saved. Nothing is written for a banned character, whose player stays dead, or before the saved values have been given to the player.

Parameters

  • owner Player
  • character Character the character that is being saved

Characters:SaveData()

server plugins/characters/plugin/sv_hooks.lua:172

Implements hook SaveData

Saves the active character of every connected player.

Characters:ShouldDrawLoadingScreen()

client plugins/characters/plugin/cl_hooks.lua:140

Implements hook ShouldDrawLoadingScreen

Keeps the loading screen visible until the intro panel has been created.

Returns

  • Boolean true while there is no intro panel, otherwise nil

Characters:ShouldHUDPaint()

client plugins/characters/plugin/cl_hooks.lua:148

Implements hook ShouldHUDPaint

Hides the HUD while the local player has no active character and needs one.

Returns

  • Boolean false when no character is loaded and one is needed, otherwise nil

Characters:ShouldMapsceneRender()

client plugins/characters/plugin/cl_hooks.lua:60

Implements hook ShouldMapsceneRender

Makes the mapscene render while the intro panel or main menu is open.

Returns

  • Boolean true while the panel is valid, otherwise nil

Characters:ShouldScoreboardHide()

client plugins/characters/plugin/cl_hooks.lua:157

Implements hook ShouldScoreboardHide

Lets the scoreboard hide only when the local player has an active character or does not need one.

Returns

  • Boolean

Characters:ShouldScoreboardShow()

client plugins/characters/plugin/cl_hooks.lua:164

Implements hook ShouldScoreboardShow

Lets the scoreboard show only when the local player has an active character or does not need one.

Returns

  • Boolean

Mutes the menu music while the game window is unfocused and fades it out and stops it once the intro panel is gone.

Functions

Characters.activate(target, character)

server plugins/characters/plugin/sv_plugin.lua:15

Makes a character the active character of a player. Runs OnCharacterChange if another character was active, networks the basic character data and runs OnActiveCharacterSet. The character does not have to belong to the player: one of another user record is sent to the player on its own, so that their client knows the character it is playing. Nothing is checked here: the requests of players go through Characters.can_use first, which is what keeps banned characters from being loaded.

Parameters

  • target Player
  • character Character any character record; nothing happens when it is not a table

Characters.all_to_networkable(target)

server plugins/characters/plugin/lib/sh_character.lua:664

Returns the networkable data of every character of a player. Server only.

Parameters

  • target Player

Returns

  • List<Map> one entry per character, empty when the player has no record

See also

Characters.can_delete(actor, character)

server plugins/characters/plugin/lib/sh_character.lua:469

Checks whether a player may delete one of their characters. The active character and banned characters are always refused; anything else has to pass the PlayerCanDeleteCharacter hook. Server only.

Parameters

  • actor Player
  • character Character the character to delete; refused when nil

Returns

  • Boolean true when the character may be deleted; otherwise false
  • String the reason as a language phrase and Map the arguments of the phrase

Characters.can_use(actor, character)

server plugins/characters/plugin/lib/sh_character.lua:412

Checks whether a player may load one of their characters. A banned character and the character that is already active are always refused. A player who is switching away from a character that is not banned has to pass the PlayerCanSwitchCharacter hook, and every load the PlayerCanUseCharacter hook. Server only.

Parameters

  • actor Player
  • character Character the character to load; refused when nil

Returns

  • Boolean true when the character may be loaded; otherwise false
  • String the reason as a language phrase and Map the arguments of the phrase

Characters.change_desc(actor, text)

server plugins/characters/plugin/lib/sh_character.lua:619

Changes the physical description of a player's active character on their own request. Control characters other than line breaks become spaces, the text is trimmed, its line breaks are replaced with ' | ', and it is refused when its length is outside of the character_min_desc_len and character_max_desc_len configs, when the player has no character or when they changed it less than a second ago. The player is notified of the outcome. Server only.

Parameters

  • actor Player
  • text String the new description

Returns

  • Boolean true when the description was changed

Characters.create(target, data)

shared plugins/characters/plugin/lib/sh_character.lua:161

Creates a character for a player unless a PlayerCreateCharacter hook rejects the data. On the server the character is then saved and sent to its owner.

local status = Characters.create(target, {
  name = 'John Doe',
  phys_desc = 'A tall man in a worn coat.',
  gender = CHAR_GENDER_MALE,
  model = 'models/humans/group01/male_02.mdl',
  skin = 0
})

if status != CHAR_SUCCESS then
  -- status is one of the CHAR_ERR_* codes
end

The new character belongs to the user record of the player unless a GetCharacterOwner hook hands it to another User record; only for a character of the player's own is their character list sent to them again.

Parameters

  • target Player the player the character is created for, its owner unless a GetCharacterOwner hook names another record
  • data Map creation data: name, phys_desc, gender, model and optionally skin. Set name_generated to true when the name was not chosen by the player, which lets it repeat the name of another character, and description_generated to true when the description was not written by the player, which frees it from the length limits

Returns

  • Number CHAR_SUCCESS, or the CHAR_ERR_* code returned by the hook

Characters.delete(target, id)

server plugins/characters/plugin/lib/sh_character.lua:730

Destroys one of the player's characters, removes it from their record, frees its name and resends the character list to the player. Nothing is checked here: the requests of players go through Characters.can_delete first. Server only.

Parameters

  • target Player
  • id Number character ID

Characters.find_by_name(name, callback)

server plugins/characters/plugin/lib/sh_character.lua:354

Finds the characters that have a name, compared without regard to letter case. The characters of the user records that are loaded are searched first: those of connected players and those that a CollectLoadedUserRecords handler adds. Only when none of them matches are the characters of offline players loaded from the database, which makes the callback run later. Server only.

Parameters

  • name String
  • callback Function receives a List<Character>, empty when nothing was found

Returns

  • Any what the callback returns if a loaded character matches, nil otherwise

Characters.forget_name(name)

server plugins/characters/plugin/lib/sh_character.lua:318

Records that a character no longer bears a name. Characters.delete and Characters.set_name call it themselves. Server only.

Parameters

  • name String

Characters.get_custom_data(character, key, default)

shared plugins/characters/plugin/lib/sh_character.lua:77

Returns a value from the generic data of a character. On the client only the keys registered with Characters.network_data are known, and only for the characters of the local player.

Parameters

  • character Character/Map character record, or networked character data on the client
  • key String
  • default Any optional, defaults to nil value to return when nothing is stored under the key

Returns

  • Any

Characters.get_limit(target)

shared plugins/characters/plugin/lib/sh_character.lua:91

Returns how many characters a player may have: the character_limit config, unless a GetCharacterLimit hook returns another number.

Parameters

  • target Player

Returns

  • Number

Characters.get_owner(character)

server plugins/characters/plugin/lib/sh_character.lua:261

Returns the player a character belongs to, if they are on the server. A character whose user record has no connected player belongs to the connected player who has it as their active character, if there is one. Server only.

Parameters

  • character Character

Returns

  • Player the owner, or nil when nobody on the server has the character

Characters.is_data_networked(key)

shared plugins/characters/plugin/lib/sh_character.lua:66

Checks whether a key of the generic character data is sent to the owner of the character.

Parameters

  • key String key of the character data

Returns

  • Boolean

Characters.is_name_taken(name, except)

server plugins/characters/plugin/lib/sh_character.lua:333

Checks whether a character of any player, connected or not, already has a name. Names are compared without regard to letter case and surrounding or repeated whitespace. The names are read from the database when the server starts. Server only.

Parameters

  • name String
  • except Character optional, defaults to nil character whose own name does not count, for renaming it

Returns

  • Boolean

Characters.limit_reached(target)

shared plugins/characters/plugin/lib/sh_character.lua:132

Checks whether a player has as many characters as they may have. On the server the player must have their database record, on the client only the local player can be checked.

Parameters

  • target Player

Returns

  • Boolean true when the player cannot create another character

See also

Characters.needs_character(target)

shared plugins/characters/plugin/lib/sh_character.lua:115

Checks whether a player has to have an active character to be in the world. A player who does is kept hidden and dead, without a HUD or a scoreboard, until they load one, and the main menu opens for them after the intro. Plugins exempt a player through the PlayerNeedsCharacter hook, which is how gamemasters stay in the world without a character.

Parameters

  • target Player

Returns

  • Boolean false when a PlayerNeedsCharacter handler has returned false, otherwise true

Characters.network_data(key)

shared plugins/characters/plugin/lib/sh_character.lua:57

Makes the server send a key of the generic character data to the owner of the character. Without it the data never leaves the server. Once a key is registered, its value is part of the character list that the owner receives and is sent again whenever it is set, so the owner can read it with Player:get_character_data; other players never receive it. Call it while the plugin that owns the key loads. It only has an effect on the server, but may be called on both realms.

Characters.network_data('flags')

Parameters

  • key String key of the character data

Characters.open_menu(target, message, arguments)

server plugins/characters/plugin/lib/sh_character.lua:503

Opens the main menu on the client of a player, or refreshes its buttons when it is already open, and optionally shows a message in it. Server only.

Parameters

  • target Player
  • message String optional, defaults to nil text or language phrase to show in the menu
  • arguments Map optional, defaults to nil values to substitute into the phrase

Characters.remember_name(name)

server plugins/characters/plugin/lib/sh_character.lua:307

Records that a character bears a name, so that Characters.is_name_taken knows it. Characters.create and Characters.set_name call it themselves. Server only.

Parameters

  • name String

Characters.restore_vitals(owner, character)

server plugins/characters/plugin/lib/sh_character.lua:540

Gives a player the health, armor and reserve ammo saved with a character. Without saved health the player keeps full health. Server only.

Parameters

  • owner Player
  • character Character

Characters.save(target, character)

server plugins/characters/plugin/lib/sh_character.lua:703

Runs the SaveCharacterData hook and saves the player's record to the database, unless a PreSaveCharacter hook returns false. A character that belongs to another user record than the player's is saved on its own, together with its own relations. Server only.

Parameters

  • target Player the player whose data goes into the character
  • character Character

Characters.send_to_client(target)

server plugins/characters/plugin/lib/sh_character.lua:656

Sends the networkable data of all of a player's characters to that player. Server only.

Parameters

  • target Player

Characters.set_banned(character, banned)

server plugins/characters/plugin/lib/sh_character.lua:565

Bans or unbans a character and saves it. A banned character cannot be loaded or deleted by its owner and is marked as banned in their character list. If the character is the active one of a connected player, its health, armor and ammo are saved first, the player is killed silently and kept from respawning, and the main menu opens for them so that they can pick another character. Unbanning the active character of a connected player respawns them with what was saved. Runs the CharacterBanChanged hook. Server only.

Parameters

  • character Character a record of a connected or an offline player
  • banned Boolean

Characters.set_custom_data(character, key, value)

server plugins/characters/plugin/lib/sh_character.lua:289

Sets a value in the generic data of a character. The value is written to the database the next time the character is saved; values must be serializable, so no functions. If the key is registered with Characters.network_data and the owner of the character is connected, the new value is sent to them. A table that is changed in place has to be set again to be sent. Server only.

Characters.set_custom_data(character, 'spawn_position', target:GetPos())

Parameters

  • character Character
  • key String nothing happens when it is not a string
  • value Any nil removes the key

Characters.set_desc(target, new_desc)

server plugins/characters/plugin/lib/sh_character.lua:786

Changes the physical description of the player's active character, networks it and runs the CharacterDescChanged hook. Server only.

Parameters

  • target Player
  • new_desc String ignored when it is not a string

Characters.set_gender(target, new_gender)

server plugins/characters/plugin/lib/sh_character.lua:839

Changes the gender of the player's active character, networks it and runs the CharacterGenderChanged hook. Server only.

Parameters

  • target Player
  • new_gender Number/String CHAR_GENDER_* value, or 'male', 'female' or 'no_gender'

Characters.set_model(target, model)

server plugins/characters/plugin/lib/sh_character.lua:812

Changes the model of the player and of their active character, networks it and runs the CharacterModelChanged hook. Server only.

Parameters

  • target Player
  • model String model path; ignored when it is not a string

Characters.set_name(target, new_name)

server plugins/characters/plugin/lib/sh_character.lua:755

Changes the name of the player's active character, networks it and runs the CharacterNameChanged hook. The name is not checked against the names of other characters; use Characters.is_name_taken first where that matters. Server only.

Parameters

  • target Player
  • new_name String ignored when it is not a string

Characters.store_vitals(owner, character)

server plugins/characters/plugin/lib/sh_character.lua:514

Writes the health, armor and reserve ammo of a player into a character. A player who is dead leaves the character without saved health, armor and ammo, so that it is loaded with full health next time. Server only.

Parameters

  • owner Player
  • character Character

Characters.to_networkable(target, char)

server plugins/characters/plugin/lib/sh_character.lua:681

Builds the table of character fields that is sent to the owning client: id, user_id, steam_id, name, gender, phys_desc, model, skin, banned and custom_data, which holds the keys of the generic data registered with Characters.network_data. Server only.

Parameters

  • target Player owner of the character
  • char Character

Returns

  • Map character data, or nil if the player or the character is not valid

Defined in