GetPlayerId
The player a command names - a pid, a name or a fragment of one - or nil.
The reverse of GetPlayerName, for commands that take a player: "2" or 2 is the pid 2 (returned when that
player is connected); a name is matched case-insensitively - the exact name wins, else a fragment ("hen" for
Henry) when exactly one connected name contains it. nil when nobody matches or two do, so a command can answer
“no player called …” and never guess between two. sscanf’s u letter is this function.
Syntax
Section titled “Syntax”GetPlayerId(name)| Parameter | Type | |
|---|---|---|
name |
string | number | a pid, a name, or a fragment of a name |
Returns
Section titled “Returns”number | nil - the pid
Example
Section titled “Example”elseif cmd == "goto" then local target = GetPlayerId(args) if not target then SendClientMessage(pid, COLOUR_RED, "no player called " .. args) else local x, y, z = GetPlayerPos(target) SetPlayerPos(pid, x + 1, y, z) end return trueSee also
Section titled “See also”GetPlayerName · sscanf · GetPlayers · IsPlayerConnected · the Players group of the index
