Gamemastery gives gamemasters a way to run the world without a character of their own. A player with the gamemastery permission who has no active character is in gamemaster mode: alive, in noclip that cannot be left, invulnerable and vanished, with the gamemastering networked variable set. They are not killed and hidden like other players without a character, and the main menu does not open for them after the intro.

Gamemasters share a pool of characters that belong to a dedicated user record. Any of them can possess a pool character, which turns them into it on the spot, release it to go back to gamemaster mode where they stand, place it in the world as an fl_gm_character entity by dragging its card from the tab menu onto the world, and delete it. A pool character is played by one gamemaster at a time. Players of the gamemaster role never own characters: whatever they create goes into the pool. Admins keep their own characters and add to the pool with a button of the main menu.

Summary

Hooks

Loads the pool of gamemaster characters once the database is ready.
Adds a button that returns a gamemaster to gamemaster mode: it closes the main menu for a gamemaster without a character, and releases the pool character of a gamemaster whose pool character has been banned, who is kept dead until they drop it.
Adds the gamemaster panel to the tab menu of players with the 'gamemastery' permission.
Adds the user record of the pool to the records whose characters are searched by name, so that commands such as /charban remove work on the pool characters that are in memory.
Forgets a world entity of a pool character that has been removed and sends the pool.
Lifts the character limit for players of the gamemaster role, whose characters all go into the pool, and on the server for a player whose request creates a pool character.
Gives a character that is created for the pool to the user record of the pool.
Draws the gamemaster mode indicator in the bottom right corner, above the vanish indicator, while the local player is in gamemaster mode.
Forgets who played a pool character that its player drops.
Takes a player out of gamemaster mode once a character has become their active one.
Forgets who played a pool character that its player switches away from.
Lets a character that goes into the pool be created in any faction: the whitelist and the amount of characters its creator may have in the faction do not apply.
Lets gamemasters play pool characters of factions that are full.
Refuses characters of their own to players of the gamemaster role.
Refuses a pool character while the pool is not ready to take it.
Frees the pool character of a player who leaves.
Keeps a player in gamemaster mode from leaving noclip.
Lets gamemasters without an active character stay in the world.
Brings a player whose 'gamemastery' permission has been set individually in line with it.
Brings a player whose role has changed in line with their permission.
Moves a player who has possessed a pool character back to where they possessed it.
Sends the pool to the gamemasters once a new pool character has been saved for the first time and has its ID.
Puts a gamemaster who spawns without an active character into gamemaster mode.
Puts a gamemaster who has just joined into gamemaster mode and sends them the pool.
Decides whether a character that is being created goes into the pool: always for players of the gamemaster role, when the client asks for it only for gamemasters, never for anybody else.
Registers the 'gamemastery' permission.
Keeps the Spawn Saver plugin from moving a player who is about to be put where they possessed a pool character.

Functions

Moves a player to the position and view angles kept in their gm_transform field on the next tick, once whatever spawned them has placed them, and forgets the field.
Deletes a pool character that nobody plays: removes its world entity, destroys its record, frees its name, sends the pool to the gamemasters and tells the staff.
Takes the active character away from a player where they stand: the character is saved and dropped, and the player is spawned again at the same spot.
Puts a player into gamemaster mode: in noclip, invulnerable and vanished, with the gamemastering networked variable set.
Takes a player out of gamemaster mode: they become visible, solid, mortal and walk again.
Finds a pool character by its ID.
Finds a pool character by its whole name, compared without regard to letter case and repeated or surrounding whitespace.
Returns the pool characters.
Returns the user record that owns the pool characters.
Returns the player who is playing a pool character.
Returns the connected players who receive the pool: everyone with the 'gamemastery' permission whose client has initialized.
Checks whether a player has the gamemaster role, which never owns characters.
Checks whether a player may use the gamemaster tools: a real player with the 'gamemastery' permission.
Checks whether a player is in gamemaster mode.
Checks whether a character belongs to the pool.
Checks whether the pool can take new characters, which it can once its user record has been saved to the database.
Checks whether the local player plays a pool character.
Remembers where a player is and where they look, for Gamemastery.apply_transform.
Loads the user record that owns the pool characters, together with the characters, or creates and saves it when it does not exist yet.
Builds the list of pool characters that is sent to the gamemasters: id, name, model, skin, phys_desc, faction (when the character has one), banned, possessed_by (the Steam name of the player who plays the character, nil when nobody does) and in_world (whether the character stands in the world).
Turns a gamemaster into a pool character on the spot.
Brings a player in line with their permission: a gamemaster without a character is put into gamemaster mode, one of the gamemaster role loses their own active character where they stand, and a player who has lost the permission loses the pool character they play or leaves gamemaster mode and gets the main menu.
Makes a player stop playing the pool character they possess and puts them back into gamemaster mode where they stand.
Removes the world entity of a pool character, if it has one.
Asks the server to delete a pool character.
Asks the server for the list of pool characters.
Asks the server to let the local player possess a pool character.
Asks the server to let the local player release the pool character they play.
Asks the server to place a pool character in the world, where a trace from the eyes of the local player along a direction hits.
Sends the list of pool characters to a player, or to every gamemaster.
Checks whether a player belongs in gamemaster mode: a real player with the 'gamemastery' permission and no active character.
Places a pool character in the world as an fl_gm_character entity, where a trace from the eyes of the gamemaster along a direction hits, at most 4096 units away.
Possesses the pool character of a world entity for a gamemaster who has pressed the use key on it, at the position and yaw of the entity.

Hooks

Gamemastery:ActiveRecordReady()

server plugins/gamemastery/plugin/sv_hooks.lua:7

Implements hook ActiveRecordReady

Loads the pool of gamemaster characters once the database is ready.

Gamemastery:AddMainMenuItems(panel, _sidebar)

client plugins/gamemastery/plugin/cl_hooks.lua:25

Implements hook AddMainMenuItems

Adds a button that returns a gamemaster to gamemaster mode: it closes the main menu for a gamemaster without a character, and releases the pool character of a gamemaster whose pool character has been banned, who is kept dead until they drop it. For gamemasters who are not of the gamemaster role it also adds a button that opens the character creation screen for a pool character.

Parameters

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

Gamemastery:AddTabMenuItems(menu)

client plugins/gamemastery/plugin/cl_hooks.lua:7

Implements hook AddTabMenuItems

Adds the gamemaster panel to the tab menu of players with the 'gamemastery' permission.

Parameters

  • menu Panel the tab menu

Gamemastery:CollectLoadedUserRecords(records)

server plugins/gamemastery/plugin/sv_hooks.lua:112

Implements hook CollectLoadedUserRecords

Adds the user record of the pool to the records whose characters are searched by name, so that commands such as /charban remove work on the pool characters that are in memory.

Parameters

  • records List<User> added to in place

Gamemastery:EntityRemoved(entity)

server plugins/gamemastery/plugin/sv_hooks.lua:196

Forgets a world entity of a pool character that has been removed and sends the pool.

Parameters

  • entity Entity

Gamemastery:GetCharacterLimit(target, _limit)

shared plugins/gamemastery/plugin/sh_plugin.lua:94

Implements hook GetCharacterLimit

Lifts the character limit for players of the gamemaster role, whose characters all go into the pool, and on the server for a player whose request creates a pool character.

Parameters

  • target Player
  • _limit Number the value of the character_limit config

Returns

  • Number math.huge when the limit does not apply, otherwise nil

Gamemastery:GetCharacterOwner(target, data)

server plugins/gamemastery/plugin/sv_hooks.lua:149

Implements hook GetCharacterOwner

Gives a character that is created for the pool to the user record of the pool.

Parameters

  • target Player
  • data Map creation data

Returns

  • User the pool record for a pool character, otherwise nil

Gamemastery:HUDPaint()

client plugins/gamemastery/plugin/cl_hooks.lua:63

Draws the gamemaster mode indicator in the bottom right corner, above the vanish indicator, while the local player is in gamemaster mode.

Gamemastery:OnActiveCharacterCleared(owner, character)

server plugins/gamemastery/plugin/sv_hooks.lua:62

Implements hook OnActiveCharacterCleared

Forgets who played a pool character that its player drops.

Parameters

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

Gamemastery:OnActiveCharacterSet(owner, _character)

server plugins/gamemastery/plugin/sv_hooks.lua:22

Implements hook OnActiveCharacterSet

Takes a player out of gamemaster mode once a character has become their active one.

Parameters

  • owner Player
  • _character Character

Gamemastery:OnCharacterChange(owner, _new_char, old_char)

server plugins/gamemastery/plugin/sv_hooks.lua:51

Implements hook OnCharacterChange

Forgets who played a pool character that its player switches away from.

Parameters

  • owner Player
  • _new_char Character the character that is about to become active
  • old_char Character the character that is still active

Gamemastery:PlayerCanBypassFactionCreationLimits(target, data)

shared plugins/gamemastery/plugin/sh_plugin.lua:107

Implements hook PlayerCanBypassFactionCreationLimits

Lets a character that goes into the pool be created in any faction: the whitelist and the amount of characters its creator may have in the faction do not apply. That is every character of a player of the gamemaster role, and a character a gamemaster creates for the pool from the main menu.

Parameters

  • target Player
  • data Map creation data; on the client the extra data of the creation screen

Returns

  • Boolean true when the limits do not apply, otherwise nil

Gamemastery:PlayerCanBypassFactionLimit(actor, _faction_table, _rank_table, character)

server plugins/gamemastery/plugin/sv_hooks.lua:188

Implements hook PlayerCanBypassFactionLimit

Lets gamemasters play pool characters of factions that are full.

Parameters

  • actor Player
  • _faction_table Faction
  • _rank_table Map
  • character Character

Returns

  • Boolean true for a gamemaster and a pool character, otherwise nil

Gamemastery:PlayerCanUseCharacter(actor, character)

server plugins/gamemastery/plugin/sv_hooks.lua:176

Implements hook PlayerCanUseCharacter

Refuses characters of their own to players of the gamemaster role.

Parameters

  • actor Player
  • character Character

Returns

  • Boolean false and String the reason for a character that is not in the pool, otherwise nil

Gamemastery:PlayerCreateCharacter(_actor, data)

server plugins/gamemastery/plugin/sv_hooks.lua:139

Implements hook PlayerCreateCharacter

Refuses a pool character while the pool is not ready to take it.

Parameters

  • _actor Player
  • data Map creation data

Returns

  • Number CHAR_ERR_RECORD when the pool cannot take the character, otherwise nil

Gamemastery:PlayerDisconnected(actor)

server plugins/gamemastery/plugin/sv_hooks.lua:73

Implements hook PlayerDisconnected

Frees the pool character of a player who leaves. The Characters plugin has saved it by then; the pool is sent once the player is gone.

Parameters

  • actor Player

Gamemastery:PlayerExitNoclip(actor)

shared plugins/gamemastery/plugin/sh_plugin.lua:120

Implements hook PlayerExitNoclip

Keeps a player in gamemaster mode from leaving noclip.

Parameters

  • actor Player

Returns

  • Boolean false while the player is in gamemaster mode, otherwise nil

Gamemastery:PlayerNeedsCharacter(target)

shared plugins/gamemastery/plugin/sh_plugin.lua:83

Implements hook PlayerNeedsCharacter

Lets gamemasters without an active character stay in the world.

Parameters

  • target Player

Returns

  • Boolean false for a gamemaster who has no active character, otherwise nil

Gamemastery:PlayerPermissionChanged(target, perm_id, _value)

server plugins/gamemastery/plugin/sv_hooks.lua:97

Implements hook PlayerPermissionChanged

Brings a player whose 'gamemastery' permission has been set individually in line with it.

Parameters

  • target Player
  • perm_id String
  • _value Number

Gamemastery:PlayerUserGroupChanged(target, _group, _old_group)

server plugins/gamemastery/plugin/sv_hooks.lua:89

Implements hook PlayerUserGroupChanged

Brings a player whose role has changed in line with their permission.

Parameters

  • target Player
  • _group Role
  • _old_group Role

Gamemastery:PostCharacterLoaded(owner, _character)

server plugins/gamemastery/plugin/sv_hooks.lua:29

Implements hook PostCharacterLoaded

Moves a player who has possessed a pool character back to where they possessed it.

Parameters

  • owner Player
  • _character Character

Gamemastery:PostCreateCharacter(_owner, char, _char_data)

server plugins/gamemastery/plugin/sv_hooks.lua:162

Implements hook PostCreateCharacter

Sends the pool to the gamemasters once a new pool character has been saved for the first time and has its ID.

Parameters

  • _owner Player
  • char Character
  • _char_data Map

Gamemastery:PostPlayerSpawn(actor)

server plugins/gamemastery/plugin/sv_hooks.lua:13

Implements hook PostPlayerSpawn

Puts a gamemaster who spawns without an active character into gamemaster mode.

Parameters

  • actor Player

Gamemastery:PostRestoreCharacters(actor)

server plugins/gamemastery/plugin/sv_hooks.lua:105

Implements hook PostRestoreCharacters

Puts a gamemaster who has just joined into gamemaster mode and sends them the pool.

Parameters

  • actor Player

Gamemastery:PreCreateCharacter(actor, data)

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

Implements hook PreCreateCharacter

Decides whether a character that is being created goes into the pool: always for players of the gamemaster role, when the client asks for it only for gamemasters, never for anybody else.

Parameters

  • actor Player
  • data Map creation data, changed in place

Gamemastery:RegisterPermissions()

shared plugins/gamemastery/plugin/sh_plugin.lua:71

Implements hook RegisterPermissions

Registers the 'gamemastery' permission.

Gamemastery:ShouldRestorePlayerSpawn(target, _character, _spawn_point)

server plugins/gamemastery/plugin/sv_hooks.lua:41

Implements hook ShouldRestorePlayerSpawn

Keeps the Spawn Saver plugin from moving a player who is about to be put where they possessed a pool character.

Parameters

  • target Player
  • _character Character
  • _spawn_point Map

Returns

  • Boolean false while a position is kept for the player, otherwise nil

Functions

Gamemastery.apply_transform(actor)

server plugins/gamemastery/plugin/sv_plugin.lua:267

Moves a player to the position and view angles kept in their gm_transform field on the next tick, once whatever spawned them has placed them, and forgets the field. A player who is not in gamemaster mode is unstuck if the position puts them into something.

Parameters

  • actor Player

Gamemastery.delete(actor, character)

server plugins/gamemastery/plugin/sv_plugin.lua:558

Deletes a pool character that nobody plays: removes its world entity, destroys its record, frees its name, sends the pool to the gamemasters and tells the staff.

Parameters

  • actor Player the gamemaster who deletes the character
  • character Character the pool character

Returns

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

Gamemastery.drop_character(actor)

server plugins/gamemastery/plugin/sv_plugin.lua:404

Takes the active character away from a player where they stand: the character is saved and dropped, and the player is spawned again at the same spot. A gamemaster enters gamemaster mode; anyone else is left without a character as usual and gets the main menu.

Parameters

  • actor Player

Returns

  • Character the character that was dropped

Gamemastery.enter_mode(actor)

server plugins/gamemastery/plugin/sv_plugin.lua:303

Puts a player into gamemaster mode: in noclip, invulnerable and vanished, with the gamemastering networked variable set. Observer mode is dropped first, as the player is hidden in their own way now. A kept position is applied.

Parameters

  • actor Player

Gamemastery.exit_mode(actor)

server plugins/gamemastery/plugin/sv_plugin.lua:324

Takes a player out of gamemaster mode: they become visible, solid, mortal and walk again. Does nothing for a player who is not in it.

Parameters

  • actor Player

Gamemastery.find_character(id)

shared plugins/gamemastery/plugin/sv_plugin.lua:129

On the server

Finds a pool character by its ID.

Parameters

  • id Number character ID

Returns

  • Character the character, nil if the pool has none with the ID

On the client

Finds a pool character in the list the server has sent.

Parameters

  • id Number character ID

Returns

  • Map the entry, nil when the list has none with the ID

Defined in

Gamemastery.find_character_by_name(name)

server plugins/gamemastery/plugin/sv_plugin.lua:146

Finds a pool character by its whole name, compared without regard to letter case and repeated or surrounding whitespace.

Parameters

  • name String

Returns

  • Character the character, nil when none or more than one has the name; Boolean true as the second value when several characters have it

Gamemastery.get_pool()

shared plugins/gamemastery/plugin/sv_plugin.lua:107

On the server

Returns the pool characters.

Returns

  • List<Character> empty until the pool has been loaded

On the client

Returns the list of pool characters the server has sent last.

Returns

  • List<Map> entries with the id, name, model, skin, phys_desc, faction, banned, possessed_by and in_world fields

Defined in

Gamemastery.get_pool_record()

server plugins/gamemastery/plugin/sv_plugin.lua:92

Returns the user record that owns the pool characters.

Returns

  • User the record, nil until it has been loaded

Gamemastery.get_possessor(character)

server plugins/gamemastery/plugin/sv_plugin.lua:168

Returns the player who is playing a pool character.

Parameters

  • character Character

Returns

  • Player the player, nil when nobody plays the character

Gamemastery.get_receivers()

server plugins/gamemastery/plugin/sv_plugin.lua:211

Returns the connected players who receive the pool: everyone with the 'gamemastery' permission whose client has initialized.

Returns

  • List<Player>

Gamemastery.has_gamemaster_role(target)

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

Checks whether a player has the gamemaster role, which never owns characters.

Parameters

  • target Player

Returns

  • Boolean

Gamemastery.is_gamemaster(target)

shared plugins/gamemastery/plugin/sh_plugin.lua:31

Checks whether a player may use the gamemaster tools: a real player with the 'gamemastery' permission.

Parameters

  • target Player

Returns

  • Boolean

Gamemastery.is_in_mode(target)

shared plugins/gamemastery/plugin/sh_plugin.lua:45

Checks whether a player is in gamemaster mode.

Parameters

  • target Player

Returns

  • Boolean

Gamemastery.is_pool_character(character)

server plugins/gamemastery/plugin/sv_plugin.lua:120

Checks whether a character belongs to the pool.

Parameters

  • character Character

Returns

  • Boolean

Gamemastery.is_pool_ready()

server plugins/gamemastery/plugin/sv_plugin.lua:99

Checks whether the pool can take new characters, which it can once its user record has been saved to the database.

Returns

  • Boolean

Gamemastery.is_possessing(entry)

client plugins/gamemastery/plugin/cl_plugin.lua:27

Checks whether the local player plays a pool character.

Parameters

  • entry Map an entry of the pool list

Returns

  • Boolean

Gamemastery.keep_transform(actor, position, angles)

server plugins/gamemastery/plugin/sv_plugin.lua:292

Remembers where a player is and where they look, for Gamemastery.apply_transform.

Parameters

  • actor Player
  • position Vector optional, defaults to nil the position to keep; where the player is when nil
  • angles Angle optional, defaults to nil the view angles to keep; where the player looks when nil

Gamemastery.load_pool()

server plugins/gamemastery/plugin/sv_plugin.lua:72

Loads the user record that owns the pool characters, together with the characters, or creates and saves it when it does not exist yet. The pool is sent to the gamemasters once it has been loaded.

Gamemastery.pool_to_networkable()

server plugins/gamemastery/plugin/sv_plugin.lua:181

Builds the list of pool characters that is sent to the gamemasters: id, name, model, skin, phys_desc, faction (when the character has one), banned, possessed_by (the Steam name of the player who plays the character, nil when nobody does) and in_world (whether the character stands in the world). Characters that have not been saved yet are left out.

Returns

  • List<Map>

Gamemastery.possess(actor, character, position, angles)

server plugins/gamemastery/plugin/sv_plugin.lua:367

Turns a gamemaster into a pool character on the spot. They keep the given position and view angles, or their own, and leave gamemaster mode. A character that someone else plays is refused, and so is anything that Characters.can_use refuses. The world entity of the character is removed.

Parameters

  • actor Player
  • character Character the pool character
  • position Vector optional, defaults to nil where the player is put; where they are when nil
  • angles Angle optional, defaults to nil where the player looks; where they look when nil

Returns

  • Boolean true when the character was possessed; otherwise false
  • String the reason as a language phrase and Map the arguments of the phrase

Gamemastery.refresh(target)

server plugins/gamemastery/plugin/sv_plugin.lua:604

Brings a player in line with their permission: a gamemaster without a character is put into gamemaster mode, one of the gamemaster role loses their own active character where they stand, and a player who has lost the permission loses the pool character they play or leaves gamemaster mode and gets the main menu. Sends the pool to the player afterward. Does nothing until the player has initialized.

Parameters

  • target Player

Gamemastery.release(actor)

server plugins/gamemastery/plugin/sv_plugin.lua:427

Makes a player stop playing the pool character they possess and puts them back into gamemaster mode where they stand.

Parameters

  • actor Player

Returns

  • Boolean true when a character was released; otherwise false and String the reason as a language phrase. Character the released character as the second value on success

Gamemastery.remove_from_world(character, silent)

server plugins/gamemastery/plugin/sv_plugin.lua:339

Removes the world entity of a pool character, if it has one.

Parameters

  • character Character
  • silent Boolean optional, defaults to false do not send the pool to the gamemasters afterward

Gamemastery.request_delete(id)

client plugins/gamemastery/plugin/cl_plugin.lua:57

Asks the server to delete a pool character.

Parameters

  • id Number character ID

Gamemastery.request_pool()

client plugins/gamemastery/plugin/cl_plugin.lua:32

Asks the server for the list of pool characters.

Gamemastery.request_possess(id)

client plugins/gamemastery/plugin/cl_plugin.lua:38

Asks the server to let the local player possess a pool character.

Parameters

  • id Number character ID

Gamemastery.request_release()

client plugins/gamemastery/plugin/cl_plugin.lua:43

Asks the server to let the local player release the pool character they play.

Gamemastery.request_spawn(id, direction)

client plugins/gamemastery/plugin/cl_plugin.lua:51

Asks the server to place a pool character in the world, where a trace from the eyes of the local player along a direction hits.

Parameters

  • id Number character ID
  • direction Vector direction in world space

Gamemastery.send_pool(target)

server plugins/gamemastery/plugin/sv_plugin.lua:227

Sends the list of pool characters to a player, or to every gamemaster. A player who has received the pool before and has lost the permission since receives an empty list, which takes the pool from their client.

Parameters

  • target Player optional, defaults to nil the player to send it to; every gamemaster when nil

Gamemastery.should_be_in_mode(target)

server plugins/gamemastery/plugin/sv_plugin.lua:259

Checks whether a player belongs in gamemaster mode: a real player with the 'gamemastery' permission and no active character.

Parameters

  • target Player

Returns

  • Boolean

Gamemastery.spawn_in_world(actor, character, direction)

server plugins/gamemastery/plugin/sv_plugin.lua:445

Places a pool character in the world as an fl_gm_character entity, where a trace from the eyes of the gamemaster along a direction hits, at most 4096 units away. A trace that hits a wall puts the character on the floor in front of it. The character faces the gamemaster. A character that already stands in the world is moved; one that somebody plays or that is banned is refused.

Parameters

  • actor Player
  • character Character the pool character
  • direction Vector normalized direction in world space

Returns

  • Boolean true when the character was placed; otherwise false
  • String the reason as a language phrase and Map the arguments of the phrase

Gamemastery.use_entity(actor, entity)

server plugins/gamemastery/plugin/sv_plugin.lua:527

Possesses the pool character of a world entity for a gamemaster who has pressed the use key on it, at the position and yaw of the entity. An entity whose character is gone is removed.

Parameters

Defined in