Player class
Part of Admin Mod
Player extensions of the admin plugin: the player's role, their individual and temporary
permissions, those of their active character, and the staff level checks. The engine's
GetUserGroup, IsAdmin and IsSuperAdmin are overridden so that other addons see Flux
roles and permissions.
Summary
Functions
Methods
Bolt:get_permission_layer.Functions
Overrides the engine method to return the player's Flux role ID.
Parameters
- self Player
Returns
- String role ID
Overrides the engine method so that other addons recognize Flux admins.
Parameters
- self Player
Returns
- Boolean
Overrides the engine method so that other addons recognize Flux super admins.
Parameters
- self Player
Returns
- Boolean
Methods
Returns the value of one of the permissions set on the player's active character.
Parameters
- perm String permission ID
Returns
- Number PERM_ value
- PERM_NO if the permission is not set or no character is loaded
Returns the permissions set on the player's active character, not counting those of the player and of their role. They are networked to every client while the character is loaded. The table is empty when no character is loaded; it must not be modified.
Returns
- Map PERM_ values keyed by permission ID
Returns one of the temporary permissions of the player's active character.
Parameters
- perm String permission ID
Returns
- Map table with value (PERM_ value) and expires (unix timestamp), or nil if not set
Returns the temporary permissions of the player's active character.
Returns
- Map tables with value and expires (unix timestamp) fields, keyed by permission ID; empty when no character is loaded. The table must not be modified
Returns the value of one of the player's individual permissions.
Parameters
- perm String permission ID
Returns
- Number PERM_ value
- PERM_NO if the permission is not set
Returns the permissions set on the player individually, not counting those of their role.
Returns
- Map PERM_ values keyed by permission ID
Returns the ID of the player's role.
Returns
- String role ID, 'user' if none has been set
Returns the player's role object.
Returns
- Role the role, or an empty table if it is not registered
Returns one of the player's temporary permissions.
Parameters
- perm String permission ID
Returns
- Map table with value (PERM_ value) and expires (unix timestamp), or nil if not set
Returns the player's temporary permissions.
Returns
- Map tables with value and expires (unix timestamp) fields, keyed by permission ID
Makes a vanished player invisible and not solid again after they have respawned, unless they are in observer mode, which hides them in its own way. Server-side only.
Checks whether the player is an admin: a super admin or anyone with the 'moderate' permission.
Returns
- Boolean
Checks whether the player is at least an assistant: an admin or anyone with the 'staff' permission.
Returns
- Boolean
Checks whether the player has the 'staff' permission.
Returns
- Boolean
Checks whether the player is a super admin: a root player or anyone with the 'administrate' permission.
Returns
- Boolean
Runs a command as this player, with the usual permission checks.
Parameters
- cmd String command name and arguments without the leading slash, e.g. 'getup 5'
Writes the player's current name and role to their database record, if they have one.
Player:set_character_permission(perm_id, value)
server plugins/admin/plugin/lib/meta/sv_player.lua:174Sets one of the permissions of the player's active character, which apply together with
the player's own permissions while that character is loaded, see
Bolt:get_permission_layer. Writes it to the database and runs the PlayerPermissionChanged
hook if the character's value has changed.
Parameters
- perm_id String permission ID
- value Number PERM_ALLOW or PERM_NEVER, or PERM_NO to remove the permission
Returns
- Boolean false if no character is loaded or an argument is not valid
See also
Player:set_character_temp_permission(perm_id, value, duration)
server plugins/admin/plugin/lib/meta/sv_player.lua:185Gives the player's active character a temporary permission value that takes precedence over its lasting permissions until it expires.
Parameters
- perm_id String permission ID
- value Number PERM_ALLOW or PERM_NEVER
- duration Number seconds until the permission expires
Returns
- Boolean false if no character is loaded or an argument is not valid
See also
Sets one of the player's individual permissions: updates the Permission records on the player's database record (PERM_NO destroys the record and takes it off the list) and the networked table, then runs the PlayerPermissionChanged hook.
Parameters
- perm_id String permission ID
- value Number PERM_ALLOW or PERM_NEVER, or PERM_NO to remove the permission
Replaces the player's networked table of individual permissions. Does not touch the database.
Parameters
- perm_table Map PERM_ values keyed by permission ID
Player:set_temp_permission(perm_id, value, duration)
server plugins/admin/plugin/lib/meta/sv_player.lua:122Gives the player a temporary permission value that takes precedence over their regular
permissions until it expires. Updates the TempPermission records and the networked table.
Giving the value the player already has temporarily adds the duration to the time that is
left, up to Bolt.max_temp_duration from now; any other value starts counting from now.
The config is sent to the player again if that has changed their right to edit configs.
Parameters
- perm_id String permission ID
- value Number PERM_ value, normally PERM_ALLOW or PERM_NEVER
- duration Number seconds until the permission expires
Replaces the player's networked table of temporary permissions. Does not touch the database.
Parameters
- perm_table Map tables with value and expires (unix timestamp) fields, keyed by permission ID
Hides the player from everyone without the 'moderate' permission, or shows them again. A player in observer mode keeps the look the Observer plugin gave them; anyone else is made invisible and not solid, and gets their previous color back when they reappear. The weapon is only drawn again when the player carries nothing, since the engine drops the carried object as soon as the weapon is drawn and draws the weapon by itself once the object is let go of. A player who leaves vanish while in observer mode stays hidden as an observer. Sets the player's is_vanished field and notifies nobody.
Parameters
- should_vanish Boolean true to hide the player, false to show them again
Sets the player's role, overriding the engine method. Networks the role, calls on_role_taken / on_role_set on the roles involved, saves the role to the database unless one of them returns a value, and runs the PlayerUserGroupChanged hook.
Parameters
- group String optional, defaults to
'user'role ID
Moves the player to a position and unsticks them. The previous position is kept in prev_pos, which the Return command uses.
Parameters
- pos Vector
Starts or stops networking the player, together with everything attached to them such as their weapons, to one other player, going by whether the player is hidden and whether the receiver has the 'moderate' permission, which lets them see hidden players.
Parameters
- receiver Player
Applies whether the player is hidden to the networking of the player to everyone else and sets their own 'transmission_prevented' net var. Called whenever the player is hidden or shown, and again whenever something new is attached to a hidden player.