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
/charban remove work on the pool characters that are in memory.gamemaster role, whose characters all go into the pool, and on the server for a player whose request creates a pool character.gamemaster role.gamemaster role, when the client asks for it only for gamemasters, never for anybody else.Functions
gamemastering networked variable set.gamemaster role, which never owns characters.Gamemastery.apply_transform.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.fl_gm_character entity, where a trace from the eyes of the gamemaster along a direction hits, at most 4096 units away.Hooks
Implements hook ActiveRecordReady
Loads the pool of gamemaster characters once the database is ready.
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
Implements hook AddTabMenuItems
Adds the gamemaster panel to the tab menu of players with the 'gamemastery' permission.
Parameters
- menu Panel the tab menu
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
Forgets a world entity of a pool character that has been removed and sends the pool.
Parameters
- entity Entity
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
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
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:62Implements 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:22Implements 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:51Implements 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:107Implements 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:188Implements 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:176Implements 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
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
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
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
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:97Implements 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:89Implements 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:29Implements 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:162Implements 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
Implements hook PostPlayerSpawn
Puts a gamemaster who spawns without an active character into gamemaster mode.
Parameters
- actor Player
Implements hook PostRestoreCharacters
Puts a gamemaster who has just joined into gamemaster mode and sends them the pool.
Parameters
- actor Player
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
Implements hook RegisterPermissions
Registers the 'gamemastery' permission.
Gamemastery:ShouldRestorePlayerSpawn(target, _character, _spawn_point)
server plugins/gamemastery/plugin/sv_hooks.lua:41Implements 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
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
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
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
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
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
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
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
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
Returns the user record that owns the pool characters.
Returns
- User the record, nil until it has been loaded
Returns the player who is playing a pool character.
Parameters
- character Character
Returns
- Player the player, nil when nobody plays the character
Returns the connected players who receive the pool: everyone with the 'gamemastery' permission whose client has initialized.
Returns
- List<Player>
Checks whether a player has the gamemaster role, which never owns characters.
Parameters
- target Player
Returns
- Boolean
Checks whether a player may use the gamemaster tools: a real player with the 'gamemastery' permission.
Parameters
- target Player
Returns
- Boolean
Checks whether a player is in gamemaster mode.
Parameters
- target Player
Returns
- Boolean
Checks whether a character belongs to the pool.
Parameters
- character Character
Returns
- Boolean
Checks whether the pool can take new characters, which it can once its user record has been saved to the database.
Returns
- Boolean
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:292Remembers where a player is and where they look, for Gamemastery.apply_transform.
Parameters
- actor Player
- position Vector optional, defaults to
nilthe position to keep; where the player is when nil - angles Angle optional, defaults to
nilthe view angles to keep; where the player looks when nil
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.
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:367Turns 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
nilwhere the player is put; where they are when nil - angles Angle optional, defaults to
nilwhere 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
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
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:339Removes the world entity of a pool character, if it has one.
Parameters
- character Character
- silent Boolean optional, defaults to
falsedo not send the pool to the gamemasters afterward
Asks the server to delete a pool character.
Parameters
- id Number character ID
Asks the server for the list of pool characters.
Asks the server to let the local player possess a pool character.
Parameters
- id Number character ID
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.
Parameters
- id Number character ID
- direction Vector direction in world space
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
nilthe player to send it to; every gamemaster when nil
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:445Places 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
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
- actor Player
- entity Entity the
fl_gm_characterentity