Player
Physical representation of connected player.
Players are a type of Entity. They are a physical representation of a Character - and can possess at most one Character object at a time that you can interface with.
See the Garry's Mod Wiki for all other methods that the Player class has.
Functions
meta:HasPrivilege(privilegeName)
Checks if the player has a specified CAMI privilege.
Parameters
-
privilegeName
string The name of the privilege to check.
Returns
-
boolean
True if the player has the privilege, false otherwise.
meta:Name()
Returns this player's current name.
Returns
meta:RequestString(title, subTitle, callback, default)
Requests a string input from the player.
Parameters
-
title
String
The title of the request.
-
subTitle
String
The subtitle of the request.
-
callback
Function
The function to call upon receiving the string input.
-
default
String
The default value for the string input.
meta:WhitelistAllClasses()
Whitelists all classes for the player.
meta:WhitelistAllFactions()
Whitelists all factions for the player.
meta:WhitelistEverything()
Whitelists everything (all classes and factions) for the player.
meta:addFlagBlacklist(flags, blacklistInfo)
Adds flags to the player's flag blacklist.
Parameters
-
flags
Table
The flags to add to the blacklist.
-
blacklistInfo
Table
optional
Additional information about the blacklist entry.
meta:addMoney(amount)
Adds money to the player's character.
Parameters
-
amount
Integer
The amount of money to add.
meta:canAfford(amount)
Checks if the player's character can afford a specified amount of money.
Parameters
-
amount
Integer
The amount of money to check.
Returns
-
bool
Whether the player's character can afford the specified amount of money.
meta:chatNotify(message)
Displays a notification for this player in the chatbox.
Parameters
-
message
String
Text to display in the notification
meta:chatNotify(message)
Displays a notification for this player in the chatbox.
Parameters
-
message
String
Text to display in the notification
meta:chatNotifyLocalized(message, ...)
Displays a notification for this player in the chatbox with the given language phrase.
Parameters
-
message
String
ID of the phrase to display to the player
-
...
Arguments to pass to the phrase
meta:chatNotifyLocalized(message, ...)
Displays a notification for this player in the chatbox with the given language phrase.
Parameters
-
message
String
ID of the phrase to display to the player
-
...
Arguments to pass to the phrase
meta:classUnWhitelist(class)
Removes the whitelist status for a specific class from the player.
Parameters
-
class
Integer
The class to remove the whitelist status for.
meta:classWhitelist(class)
Whitelists the player for a specific class.
Parameters
-
class
Integer
The class to whitelist the player for.
meta:createRagdoll(freeze)
Creates a ragdoll entity for the player.
Parameters
-
freeze
Boolean
Whether to freeze the ragdoll initially.
Returns
-
Entity
The created ragdoll entity.
meta:createServerRagdoll(dontSetPlayer)
Creates a ragdoll entity for the player on the server.
Parameters
-
dontSetPlayer
Boolean
optional
Determines whether to associate the player with the ragdoll.
Returns
-
Entity
The created ragdoll entity.
meta:distanceFromEnt(entity)
Calculates the distance from the player to the specified entity.
Parameters
-
entity
Entity
The entity to calculate the distance to.
Returns
-
number
The distance from the player to the entity.
meta:doStaredAction(entity, callback, time, onCancel, distance)
Performs a stared action towards an entity for a certain duration.
Parameters
-
entity
Entity
The entity towards which the player performs the stared action.
-
callback
Function
The function to call when the stared action is completed.
-
time
Integer
optional
The duration of the stared action in seconds.
-
onCancel
Function
optional
The function to call if the stared action is canceled.
-
distance
Integer
optional
The maximum distance for the stared action.
meta:entitiesNearPlayer(radius, playerOnly)
Retrieves entities near the player within a specified radius.
Parameters
-
radius
Integer
The radius within which to search for entities.
-
playerOnly
Boolean
optional
If true, only return player entities.
Returns
-
table
A table containing the entities near the player.
meta:getChar()
Returns this player's currently possessed Character object if it exists.
Returns
-
Character
Currently loaded character
-
nil
If this player has no character loaded
meta:getClass()
Retrieves the class of the player's character.
Returns
-
string or nil
The class of the player's character, or nil if not found.
meta:getClassData()
Retrieves the data of the player's character class.
Returns
-
table or nil
A table containing the data of the player's character class, or nil if not found.
meta:getCurrentVehicle()
Gets the current vehicle the player is in, if any.
Returns
-
Entity or nil
The current vehicle entity, or nil if the player is not in a vehicle.
meta:getEyeEnt(distance)
Retrieves the entity within the player's line of sight.
Parameters
-
distance
Integer
optional
The maximum distance to consider.
Returns
-
Entity or nil
The entity within the player's line of sight, or nil if not found.
meta:getFlagBlacklist()
Retrieves the player's flag blacklist.
Returns
-
string
The player's flag blacklist.
meta:getItemDropPos()
Calculates the position to drop an item from the player's inventory.
Returns
-
Vector
The position to drop an item from the player's inventory.
meta:getItemWeapon()
Retrieves the active weapon item of the player.
Returns
-
Entity or nil
The active weapon entity of the player, or nil if not found.
meta:getItems()
Retrieves the items of the player's character inventory.
Returns
-
table or nil
A table containing the items in the player's character inventory, or nil if not found.
meta:getLiliaData(key, default)
Retrieves a value from the local Lilia data.
Parameters
-
key
String
The key for the data.
-
default
optional
The default value to return if the key does not exist.
Returns
-
any
The value corresponding to the key, or the default value if the key does not exist.
meta:getLiliaData(key, default)
Retrieves a value from the player's Lilia data.
Parameters
-
key
String
The key for the data.
-
default
[opt=nil] The default value to return if the key does not exist.
Returns
-
any
The value corresponding to the key, or the default value if the key does not exist.
meta:getMoney()
Retrieves the amount of money owned by the player's character.
Returns
-
number
The amount of money owned by the player's character.
meta:getPermFlags()
Retrieves the player's permanent flags.
Returns
-
string
The player's permanent flags.
meta:getPlayTime()
Retrieves the player's total playtime.
Returns
-
number
The total playtime of the player.
meta:getPlayTime()
Retrieves the player's total playtime.
Returns
-
number
The total playtime of the player.
meta:getRagdoll()
Returns the player's ragdoll entity if valid.
Returns
-
Entity or nil
The player's ragdoll entity if it exists and is valid, otherwise nil.
meta:getTrace()
Performs a trace from the player's view.
Returns
-
table
A table containing the trace result.
meta:getTracedEntity()
Retrieves the entity traced by the player's aim.
Returns
-
Entity or nil
The entity traced by the player's aim, or nil if not found.
meta:givePermFlags(flags)
Grants permanent flags to the player.
Parameters
-
flags
Table
The permanent flags to grant.
meta:hasAnyFlagBlacklist(flags)
Checks if the player has any of the specified flags blacklisted.
Parameters
-
flags
Table
A table containing the flags to check for in the blacklist.
Returns
-
bool
Whether the player has any of the specified flags blacklisted.
meta:hasClassWhitelist(class)
Checks if the player has whitelisted access to a class.
Parameters
-
class
Integer
The class to check for whitelisting.
Returns
-
bool
Whether the player has whitelisted access to the specified faction.
meta:hasFlagBlacklist(flag)
Checks if the player has a specific flag blacklisted.
Parameters
-
flag
String
The flag to check for in the blacklist.
Returns
-
bool
Whether the player has the specified flag blacklisted.
meta:hasPermFlag(flag)
Checks if the player has a specific permanent flag.
Parameters
-
flag
String
The permanent flag to check.
Returns
-
bool
Whether or not the player has the permanent flag.
meta:hasRagdoll()
Checks if the player has a valid ragdoll entity.
Returns
-
bool
Whether the player has a valid ragdoll entity.
meta:hasSkillLevel(skill, level)
Checks if the player has a skill level equal to or greater than the specified level.
Parameters
-
skill
String
The skill to check.
-
level
Integer
The required skill level.
Returns
-
bool
Whether the player's skill level meets or exceeds the specified level.
meta:hasValidVehicle()
Checks if the player is in a valid vehicle.
Returns
-
bool
true if the player is in a valid vehicle, false otherwise.
meta:hasWhitelist(faction)
Checks if the player has whitelisted access to a faction.
Parameters
-
faction
Integer
The faction to check for whitelisting.
Returns
-
bool
Whether the player has whitelisted access to the specified faction.
meta:isClass(class)
Checks if the player belongs to the specified class.
Parameters
-
class
String
The class to check against.
Returns
-
bool
Whether the player belongs to the specified class.
meta:isFaction(faction)
Checks if the player belongs to the specified faction.
Parameters
-
faction
String
The faction to check against.
Returns
-
bool
Whether the player belongs to the specified faction.
meta:isFemale()
Checks if the player's character is female based on the model.
Returns
-
bool
Whether the player's character is female.
meta:isMoving()
Checks if the player is currently moving.
Returns
-
bool
Whether the player is currently moving.
meta:isNearPlayer(radius, entity)
Checks if the player is near another entity within a specified radius.
Parameters
-
radius
Integer
The radius within which to check for proximity.
-
entity
Entity
The entity to check proximity to.
Returns
-
bool
Whether the player is near the specified entity within the given radius.
meta:isNoClipping()
Checks if the player is currently in noclip mode.
Returns
-
bool
Whether the player is in noclip mode.
meta:isObserving()
Checks if the player is currently observing.
Returns
-
bool
Whether the player is currently observing.
meta:isOutside()
Checks if the player is currently outside (in the sky).
Returns
-
bool
Whether the player is currently outside (in the sky).
meta:isRunning()
Checks if the player is running.
Returns
-
bool
Whether the player is running.
meta:isStaff()
Checks if the player is a staff member.
Returns
-
bool
Whether the player is a staff member.
meta:isStaffOnDuty()
Checks if the staff member is currently on duty (FACTION_STAFF).
Returns
-
bool
Whether the staff member is currently on duty.
meta:isStuck()
Checks if the player is stuck.
Returns
-
bool
Whether the player is stuck.
meta:isUser()
Checks if the player belongs to the "user" user group.
Returns
-
bool
Whether the player belongs to the "user" user group.
meta:isVIP()
Checks if the player is a VIP.
Returns
-
bool
Whether the player is a VIP.
meta:loadLiliaData(callback)
Loads Lilia data for the player from the database.
Parameters
-
callback
Function
optional
Function to call after the data is loaded, passing the loaded data as an argument.
meta:meetsRequiredSkills(requiredSkillLevels)
Checks if the player meets the required skill levels.
Parameters
-
requiredSkillLevels
Table
A table containing the required skill levels.
Returns
-
bool
Whether the player meets all the required skill levels.
meta:notify(message)
Notifies the player with a message.
Parameters
-
message
String
The message to notify the player.
meta:notifyLocalized(message, ...)
Notifies the player with a localized message.
Parameters
-
message
String
The key of the localized message to notify the player.
-
...
Table
Additional arguments to format the localized message.
meta:notifyP(text)
Notifies the player with a message and prints the message to their chat.
Parameters
-
text
String
The message to notify and print.
meta:openPage(url)
Opens a web page for the player.
Parameters
-
url
String
The URL of the web page to open.
meta:openUI(panel)
Opens a UI panel for the player.
Parameters
-
panel
The panel type to create.
Returns
-
Panel
The created UI panel.
meta:openUI(panel)
Opens a VGUI panel for the player.
Parameters
-
panel
The name of the VGUI panel to open.
meta:playSound(sound, pitch)
Plays a sound for the player.
Parameters
-
sound
String
The sound to play.
-
pitch
Integer
optional
The pitch of the sound.
meta:removeFlagBlacklist(flags)
Removes flags from the player's flag blacklist.
Parameters
-
flags
Table
A table containing the flags to remove from the blacklist.
meta:requestString(title, subTitle, callback, default)
Requests a string input from the player.
Parameters
-
title
String
The title of the string input dialog.
-
subTitle
String
The subtitle or description of the string input dialog.
-
callback
Function
The function to call with the entered string.
-
default
optional
The default value for the string input.
Returns
-
Promise
A promise object resolving with the entered string.
meta:saveLiliaData()
Saves the player's Lilia data to the database.
meta:sendMessage(...)
Sends a message to the player.
Parameters
-
...
Table
The message(s) to send.
meta:sendPrint(...)
Sends a message to the player to be printed.
Parameters
-
...
Table
The message(s) to print.
meta:sendPrintTable(...)
Sends a table to the player to be printed.
Parameters
-
...
Table
The table(s) to print.
meta:setAction(text, time, callback, startTime, finishTime)
Sets an action bar for the player.
Parameters
-
text
String
The text to display on the action bar.
-
time
Integer
optional
The duration for the action bar to display, defaults to 5 seconds. Set to 0 or nil to remove the action bar immediately.
-
callback
Function
optional
Function to execute when the action bar timer expires.
-
startTime
Integer
optional
The start time of the action bar, defaults to the current time.
-
finishTime
Integer
optional
The finish time of the action bar, defaults to startTime + time.
meta:setFlagBlacklist(flags)
Sets the player's flag blacklist.
Parameters
-
flags
Table
The flag blacklist to set.
meta:setLiliaData(key, value, noNetworking)
Sets a key-value pair in the player's Lilia data.
Parameters
-
key
String
The key for the data.
-
value
The value to set.
-
noNetworking
Boolean
optional
If true, suppresses network broadcasting of the update.
meta:setLocalVar(key, value)
Sets a local variable for the player.
Parameters
-
key
String
The key of the variable.
-
value
The value of the variable.
meta:setPermFlags(flags)
Sets the player's permanent flags.
Parameters
-
flags
String
The permanent flags to set.
meta:setRagdoll(entity)
Sets the player's ragdoll entity.
Parameters
-
entity
Entity
The entity to set as the player's ragdoll.
meta:setRagdolled(state, time, getUpGrace, getUpMessage)
Sets the player to a ragdolled state or removes the ragdoll.
Parameters
-
state
Boolean
Whether to set the player to a ragdolled state (
true
) or remove the ragdoll (false
).
-
time
Integer
optional
The duration for which the player remains ragdolled.
-
getUpGrace
Integer
optional
The grace period for the player to get up before the ragdoll is removed.
-
getUpMessage
String
optional
The message displayed when the player is getting up.
meta:setWeighPoint(name, vector, onReach)
Sets a waypoint for the player.
Parameters
-
name
String
The name of the waypoint.
-
vector
Vector
The position vector of the waypoint.
-
onReach
Function
[opt=nil] Function to call when the player reaches the waypoint.
meta:setWhitelisted(faction, whitelisted)
Sets whether the player is whitelisted for a faction.
Parameters
-
faction
Integer
The faction ID.
-
whitelisted
Boolean
Whether the player should be whitelisted for the faction.
Returns
-
bool
Whether the operation was successful.
meta:squaredDistanceFromEnt(entity)
Calculates the squared distance from the player to the specified entity.
Parameters
-
entity
Entity
The entity to calculate the distance to.
Returns
-
number
The squared distance from the player to the entity.
meta:stopAction()
Stops the action bar for the player. Removes the action bar currently being displayed.
meta:syncVars()
This is an internal function! You are able to use it, but you risk unintended side effects if used incorrectly.
Synchronizes networked variables with the player.
meta:takeMoney(amount)
Takes money from the player's character.
Parameters
-
amount
Integer
The amount of money to take.
meta:takePermFlags(flags)
Revokes permanent flags from the player.
Parameters
-
flags
Table
The permanent flags to revoke.