Player

Has useful player-related functions.

Summary
PlayerHas useful player-related functions.
Functions
getPickerGets the player directly in front of the specified player
getPlyByIDFinds a user identified by the given ID.
getUniqueIDForPlyFinds a unique ID for a player, suitable for use in getUsers or getUser to uniquely identify the given player.
getUsersFinds users matching an identifier.
getUserFinds a user matching an identifier.

Functions

getPicker

function ULib.getPicker(ply,
radius)

Gets the player directly in front of the specified player

Parameters

plyThe player to look for another player in front of.
radius(Optional, defaults to 30) How narrow to make our checks for players in front of us.

Returns

The player most directly in front of us if one exists with the given constraints, otherwise nil.

Revisions

v2.40Initial.

getPlyByID

function ULib.getPlyByID(id)

Finds a user identified by the given ID.

Parameters

idThe ID to try to match against connected players.  Can be a unique id, ip address, steam id, or user id.

Returns

The player matching the id given or nil if none match.

Revisions

v2.50Initial.

getUniqueIDForPly

Finds a unique ID for a player, suitable for use in getUsers or getUser to uniquely identify the given player.

Parameters

plyThe player we want an ID for

Returns

The id for the player or nil if none are unique.

Revisions

v2.50Initial.
v2.51Added exception for single player since it’s handled differently on client and server.

getUsers

function ULib.getUsers(target,
enable_keywords,
ply)

Finds users matching an identifier.

Parameters

targetA string of what you’d like to target.  Accepts a comma separated list.
enable_keywords(Optional, defaults to false) If true, the keywords “*” for all players, “^” for self, “@” for picker (person in front of you), “#<group>” for those inside a specific group, “%<group>” for users inside a group (counting inheritance), and “$<id>” for users matching a particular ID will be activated.  Any of these can be negated with “!” before it.  IE, “!^” targets everyone but yourself.
ply(Optional) Player needing getUsers, this is necessary for some of the keywords.

Returns

A table of players (false and message if none found).

Revisions

v2.40Rewrite, added more keywords, removed immunity.
v2.50Added “#” and ‘$’ keywords, removed special exception for “%user” (replaced by “#user”).
v2.60Returns false if target is an empty string.

getUser

function ULib.getUser(target,
enable_keywords,
ply)

Finds a user matching an identifier.

Parameters

targetA string of the user you’d like to target.  IE, a partial player name.
enable_keywords(Optional, defaults to false) If true, the keywords “^” for self, “@” for picker (person in front of you), and “$<id>” will be activated.
ply(Optional) Player needing getUsers, this is necessary to use keywords.

Returns

The resulting player target, false and message if no user found.

Revisions

v2.40Rewrite, added keywords, removed immunity.
v2.50Added “$” keyword.
v2.60Returns false if target is an empty string.
function ULib.getPicker(ply,
radius)
Gets the player directly in front of the specified player
function ULib.getPlyByID(id)
Finds a user identified by the given ID.
function ULib.getUsers(target,
enable_keywords,
ply)
Finds users matching an identifier.
function ULib.getUser(target,
enable_keywords,
ply)
Finds a user matching an identifier.
Close