Extensions of the player library: picking a random player, finding players by a part of their name, by their exact name or by SteamID, and looking up the Steam name of a SteamID.

Summary

Functions

Finds a player based on their name or SteamID.
Finds the players a name stands for when it has to match exactly, as for the player arguments of commands.
Requests the Steam name that belongs to a SteamID through steamworks.
random()shared
Selects a random player.

Methods

Sends this player the values of all configs they may see: every config that is not hidden, the private ones only if the player may edit configs, and with those the pending values.

Functions

player.find(name, case_sensitive, return_first)

shared lib/stdlib/sh_player.lua:21

Finds a player based on their name or SteamID. A SteamID has to match exactly. A name is searched for as plain text in both the name and the Steam name of every player; Steam names are always matched case-insensitively.

Parameters

  • name String/Player part of a name, or a SteamID; a valid player is returned as-is
  • case_sensitive Boolean optional, defaults to false match player names case-sensitively
  • return_first Boolean optional, defaults to false return the first match instead of all of them

Returns

  • Player/List<Player> the only match, an array if several players match, nil if none do

player.find_exact(name)

shared lib/stdlib/sh_player.lua:72

Finds the players a name stands for when it has to match exactly, as for the player arguments of commands. A SteamID ('STEAM_0:1:12345', in any case) or SteamID64 finds the player who has it. Any other name is compared, ignoring the case, with the character name of every player (their name without the 'GetPlayerName' hook) and, if no character name is equal to it, with their Steam names. Several players can share a name; all of them are returned then.

Parameters

  • name String SteamID, SteamID64, character name or Steam name

Returns

  • List<Player> the players, empty if nobody has this name

player.name_from_steamid(steamid)

shared lib/stdlib/sh_player.lua:114

Requests the Steam name that belongs to a SteamID through steamworks. The request is asynchronous, so the name is only returned if it is available right away.

Parameters

  • steamid String SteamID, e.g. 'STEAM_0:1:12345678'

Returns

  • String Steam name, or nil if it has not been received by the time this returns

player.random()

shared lib/stdlib/sh_player.lua:6

Selects a random player.

Returns

  • Player random player, or nil if there are no players on the server

Methods

Player:send_config()

server lib/config.lua:645

Sends this player the values of all configs they may see: every config that is not hidden, the private ones only if the player may edit configs, and with those the pending values. Serverside only. Can be called again at any time, for instance after the permissions of the player have changed: a player who may not edit configs (any more) is then told to forget the values of the private configs and the pending values.

Defined in