Garry's Mod Wiki

Player

This is a list of all methods only available for players. It is also possible to call Entity functions on the Player.

Inherits methods from Entity.

Methods

number Player:AccountID()
Returns the player's AccountID part of their full SteamID. Since this does not include other vital parts of the SteamID such as "Account Type" and "Account Instance", it should be avoided, as AccountIDs are finite, and can theoretically be the same for multiple valid accounts. See Player:SteamID for the text representation of the full SteamID. See Player:SteamID64 for a 64bit representation of the full SteamID. In a -multirun environment, this will return -1 for all "copies" of a player because they are not authenticated with Steam. For bots this will return values starting with 0 for the first bot, 1 for the second bot and so on.
Player:AddCleanup( string type, Entity ent )
This function is only available in Sandbox and its derivatives. Adds an entity to the player's clean up list. This uses cleanup. Add internally.
Player:AddCount( string str, Entity ent )
This function is only available in Sandbox and its derivatives. Adds an entity to the player's list of entities of the same type. See Player:GetCount to get the current count of entities of an entity type added with this function.
Player:AddDeaths( number count )
Adds the provided amount to the player's death count.
Player:AddFrags( number count )
Adds the provided amount to the player's frag/kill count.
Player:AddFrozenPhysicsObject( Entity ent, PhysObj physobj )
Adds an entity to the player's list of frozen objects.
Player:AddPlayerOption( string name, number timeout, function vote_callback, function draw_callback )
Sets up the voting system for the player. This is a really barebone system. By calling this a vote gets started, when the player presses 0-9 the callback function gets called along with the key the player pressed. Use the draw callback to draw the vote panel.
Player:AddVCDSequenceToGestureSlot( number slot, number sequenceId, number cycle, boolean autokill = false )
Plays a sequence directly from a sequence number, similar to Player:AnimRestartGesture. This function has the advantage to play sequences that haven't been bound to an existing ACT enum This is not automatically networked. This function has to be called on the client to be seen by said client.
boolean Player:Alive()
Checks if the player is alive.
Player:AllowFlashlight( boolean canFlashlight )
Sets if the player can toggle their flashlight. Function exists on both the server and client but has no effect when ran on the client.
Lets the player spray their decal without delay
Resets player gesture in selected slot.
Player:AnimRestartGesture( number slot, number activity, boolean autokill = false )
Restart a gesture on a player, within a gesture slot. This is not automatically networked. This function has to be called on the client to be seen by said client.
Restarts the main animation on the player, has the same effect as calling Entity:SetCycle( 0 ).
Player:AnimSetGestureSequence( number slot, number sequenceID )
Sets the sequence of the animation playing in the given gesture slot.
Player:AnimSetGestureWeight( number slot, number weight )
Sets the weight of the animation playing in the given gesture slot.
number Player:Armor()
Returns the player's armor.
Player:Ban( number minutes, boolean kick = false )
Bans the player from the server for a certain amount of minutes.
Returns true if the player's flashlight hasn't been disabled by Player:AllowFlashlight. This is not synchronized between clients and server automatically!
Player:ChatPrint( string message )
Prints a string to the chatbox of the client. Just like the usermessage, this function is affected by the 255 byte limit!
boolean Player:CheckLimit( string str )
Checks if the limit of an entity type added by Player:AddCount is hit or not. If it's hit, it will call the GM:PlayerCheckLimit hook, and call Player:LimitHit if the hook doesn't return false. This will always return true in singleplayer, as singleplayer does not have limits. This function is only available in Sandbox and its derivatives.
Player:ConCommand( string command )
Runs the concommand on the player. This does not work on bots. If used clientside, always runs the command on the local player. If you wish to directly modify the movement input of bots, use GM:StartCommand instead. Some commands/convars are blocked from being ran/changed using this function, usually to prevent harm/annoyance to clients. For a list of blocked commands, see Blocked ConCommands.
Player:CreateRagdoll()
Creates the player's death ragdoll entity and deletes the old one. This is normally used when a player dies, to create their death ragdoll. The ragdoll will be created with the player's properties such as Position, Angles, PlayerColor, Velocity and Model. You can retrieve the entity this creates with Player:GetRagdollEntity.
Disables the default player's crosshair. Can be reenabled with Player:CrosshairEnable. This will affect WEAPON:DoDrawCrosshair.
Player:CrosshairEnable()
Enables the player's crosshair, if it was previously disabled via Player:CrosshairDisable.
Returns whether the player is crouching or not (FL_DUCKING flag).
number Player:Deaths()
Returns the player's death count
Player:DebugInfo()
Prints the players' name and position to the console.
Detonates all tripmines belonging to the player.
Player:DisableWorldClicking( boolean disable )
Disables world clicking for given player. See Panel:SetWorldClicker and Player:IsWorldClickingDisabled.
Player:DoAnimationEvent( number data )
Sends a third person animation event to the player. Calls GM:DoAnimationEvent with PLAYERANIMEVENT_CUSTOM_GESTURE as the event, data as the given data.
Player:DoAttackEvent()
Starts the player's attack animation. The attack animation is determined by the weapon's HoldType. Similar to other animation event functions, calls GM:DoAnimationEvent with PLAYERANIMEVENT_ATTACK_PRIMARY as the event and no extra data.
Player:DoCustomAnimEvent( number event, number data )
Sends a specified third person animation event to the player. Calls GM:DoAnimationEvent with specified arguments.
Player:DoReloadEvent()
Sends a third person reload animation event to the player. Similar to other animation event functions, calls GM:DoAnimationEvent with PLAYERANIMEVENT_RELOAD as the event and no extra data.
Sends a third person secondary fire animation event to the player. Similar to other animation event functions, calls GM:DoAnimationEvent with PLAYERANIMEVENT_ATTACK_SECONDARY as the event and no extra data.
Player:DrawViewModel( boolean draw, number vm = 0 )
Show/Hide the player's weapon's viewmodel.
Player:DrawWorldModel( boolean draw )
Show/Hide the player's weapon's worldmodel.
Player:DropNamedWeapon( string class, Vector target = nil, Vector velocity = nil )
Drops the players' weapon of a specific class.
Player:DropObject()
Drops any object the player is currently holding with either gravitygun or +Use (E key)
Player:DropWeapon( Weapon weapon = nil, Vector target = nil, Vector velocity = nil )
Forces the player to drop the specified weapon
Player:EnterVehicle( Vehicle vehicle )
Force puts the player into a specified vehicle. This does not bypass GM:CanPlayerEnterVehicle.
Player:EquipSuit()
Equips the player with the HEV suit. Allows the player to zoom, walk slowly, sprint, pickup armor batteries, use the health and armor stations and also shows the HUD. The player also emits a flatline sound on death, which can be overridden with GM:PlayerDeathSound. The player is automatically equipped with the suit on spawn, if you wish to stop that, use Player:RemoveSuit.
Player:ExitVehicle()
Forces the player to exit the vehicle if they're in one. This function will bypass GM:CanExitVehicle. See also GM:PlayerLeaveVehicle
Player:Flashlight( boolean isOn )
Enables/Disables the player's flashlight. Player:CanUseFlashlight must be true in order for the player's flashlight to be changed.
Returns true if the player's flashlight is on.
number Player:Frags()
Returns the amount of frags a player has. The value will change depending on the player's kill or suicide: +1 for a kill, -1 for a suicide.
Player:Freeze( boolean frozen = false )
Freeze the player. Frozen players cannot move, look around, or attack. Key bindings are still called. Similar to Player:Lock but the player can still take damage. Adds or removes the FL_FROZEN flag from the player. Frozen bots will still be able to look around.
Returns the player's active weapon. If used on a LocalPlayer() and the player is spectating another player with OBS_MODE_IN_EYE, the weapon returned will be of the spectated player.
Returns the player's current activity.
Returns the direction that the player is aiming.
Returns true if the players' model is allowed to rotate around the pitch and roll axis.
Returns whether the player is allowed to use their weapons in a vehicle or not.
table Player:GetAmmo()
Returns a table of all ammo the player has.
number Player:GetAmmoCount( any ammotype )
Gets the amount of ammo the player has.
Gets if the player will be pushed out of nocollided players.
Returns true if the player is able to walk using the (default) alt key.
Determines whenever the player is allowed to use the zoom functionality.
Returns the player's class id.
number Player:GetCount( string type, number minus = 0 )
This function is only available in Sandbox and its derivatives. Gets the total amount of entities of an entity type added by Player:AddCount. Default types: balloons buttons cameras dynamite emitters hoverballs lamps lights props ragdolls thrusters wheels
Returns the crouched walk speed multiplier. See also Player:GetWalkSpeed and Player:SetCrouchedWalkSpeed.
Returns the last command which was sent by the specified player. This can only be called on the player which GetPredictionPlayer() returns. When called clientside in singleplayer during WEAPON:Think, it will return nothing as the hook is not technically predicted in that instance. See the note on the page. This will fail in GM:StartCommand. Issue Tracker: 3302
Gets the actual view offset which equals the difference between the players actual position and their view when standing. Do not confuse with Player:GetViewOffset and Player:GetViewOffsetDucked
Gets the entity the player is currently driving via the drive library.
Returns driving mode of the player. See Entity Driving.
Returns a player's duck speed (in seconds)
Returns the entity the player is currently using, like func_tank mounted turrets or +use prop pickups.
Returns a table with information of what the player is looking at. The results of this function are cached clientside every frame. Uses util. GetPlayerTrace internally and is therefore bound by its limits. See also Player:GetEyeTraceNoCursor.
Returns the trace according to the players view direction, ignoring their mouse (holding c and moving the mouse in Sandbox). The results of this function are cached clientside every frame. Uses util. GetPlayerTrace internally and is therefore bound by its limits. See also Player:GetEyeTrace.
number Player:GetFOV()
Returns the FOV of the player.
Returns the steam "relationship" towards the player.
Entity Player:GetHands()
Gets the hands entity of a player
Returns the widget the player is hovering with their mouse.
Gets the bottom base and the top base size of the player's hull.
Gets the bottom base and the top base size of the player's crouch hull.
string Player:GetInfo( string cVarName )
Retrieves the value of a client-side ConVar. The ConVar must have a FCVAR_USERINFO flag for this to work. The returned value is truncated to 31 bytes. On client this function will return value of the local player, regardless of which player the function was called on!
number Player:GetInfoNum( string cVarName, number default )
Retrieves the numeric value of a client-side convar, returns nil if value is not convertible to a number. The ConVar must have a FCVAR_USERINFO flag for this to work.
Returns the jump power of the player
Returns the player's ladder climbing speed. See Player:GetWalkSpeed for normal walking speed, Player:GetRunSpeed for sprinting speed and Player:GetSlowWalkSpeed for slow walking speed.
Returns the timescale multiplier of the player movement.
Returns the maximum amount of armor the player should have. Default value is 100.
Returns the player's maximum movement speed. See also Player:SetMaxSpeed, Player:GetWalkSpeed and Player:GetRunSpeed.
string Player:GetName()
Returns the player's name, this is an alias of Player:Nick. This function overrides Entity:GetName (in the Lua metatable, not in c++), keep it in mind when dealing with ents. FindByName or any engine function which requires the mapping name.
Returns whenever the player is set not to collide with their teammates.
Returns the the observer mode of the player
Returns the entity the player is currently observing. Set using Player:SpectateEntity.
string Player:GetPData( string key, any default = nil )
Returns a Persistent Data key-value pair from the SQL database. (sv. db when called on server, cl. db when called on client) Internally uses the sql library. See util. GetPData for cases when the player is not currently on the server. This function internally uses Player:SteamID64, it previously utilized Player:UniqueID which can cause collisions (two or more players sharing the same PData entry). Player:SetPData now replaces all instances of Player:UniqueID with Player:SteamID64 when running Player:SetPDataPData is not networked from servers to clients!
Returns a player model's color. The part of the model that is colored is determined by the model itself, and is different for each model.
Returns a table containing player information.
Returns the preferred carry angles of an object, if any are set. Calls GM:GetPreferredCarryAngles with the target entity and returns the carry angles.
Returns the widget entity the player is using. Having a pressed widget stops the player from firing their weapon to allow input to be passed onto the widget.
Returns the weapon the player previously had equipped.
We advise against using this. It may be changed or removed in a future update. You should use Player:GetViewPunchAngles instead. Returns players screen punch effect angle. See Player:ViewPunch and Player:SetViewPunchAngles
Returns players death ragdoll. The ragdoll is created by Player:CreateRagdoll. Calling Entity:GetPos server-side with this function then will return the position when Player:CreateRagdoll was used.
Returns the render angles for the player.
Returns the player's sprint speed. See also Player:SetRunSpeed, Player:GetWalkSpeed and Player:GetMaxSpeed.
Returns the position of a Player's view This is the same as calling Entity:EyePos on the player.
Returns the player's slow walking speed, which is activated via +walk keybind. See Player:GetWalkSpeed for normal walking speed, Player:GetRunSpeed for sprinting speed and Player:GetLadderClimbSpeed for ladder climb speed.
Returns the maximum height player can step onto.
Returns the player's HEV suit power. This will only work for the local player when used clientside. Issue Tracker: 3449
Returns the number of seconds that the player has been timing out for. You can check if a player is timing out with Player:IsTimingOut. This function is relatively useless because it is tied to the value of the sv_timeout ConVar, which is irrelevant to the description above. This is not considered as a bug.
table Player:GetTool( string mode = "nil" )
Returns TOOL table of players current tool, or of the one specified.
Returns a player's unduck speed (in seconds)
Returns the entity the player would use if they would press their +use keybind. Because entity physics objects usually do not exist on the client, the client's use entity will resolve to whatever the crosshair is placed on within a little less than 72 units of the player's eye position. This differs from the entity returned by the server, which has fully physical use checking. See util. TraceHull. Issue tracker: 5027
Returns the player's user group. By default, player user groups are loaded from garrysmod/settings/users. txt.
Gets the vehicle the player is driving, returns NULL ENTITY if the player is not driving.
Returns the entity the player is using to see from (such as the player itself, the camera, or another entity). This function will return a [NULL Entity] until Player:SetViewEntity has been used
Entity Player:GetViewModel( number index = 0 )
Returns the player's view model entity by the index. Each player has 3 view models by default, but only the first one is used. To use the other viewmodels in your SWEP, see Entity:SetWeaponModel. In the Client realm, other players' viewmodels are not available unless they are being spectated.
Returns the view offset of the player which equals the difference between the players actual position and their view. See also Player:GetViewOffsetDucked.
Returns the view offset of the player which equals the difference between the players actual position and their view when ducked. See also Player:GetViewOffset.
Returns players screen punch effect angle.
Returns client's view punch velocity. See Player:ViewPunch and Player:SetViewPunchVelocity
Returns the current voice volume scale for given player on client.
Returns the player's normal walking speed. Not sprinting, not slow walking. (+walk) See also Player:SetWalkSpeed, Player:GetMaxSpeed and Player:GetRunSpeed.
Weapon Player:GetWeapon( string className )
Returns the weapon for the specified class
Returns a player's weapon color. The part of the model that is colored is determined by the model itself, and is different for each model. The format is Vector(r,g,b), and each color should be between 0 and 1.
table Player:GetWeapons()
Returns a table of the player's weapons. This function returns a sequential table, meaning it should be looped with ipairs instead of pairs for efficiency reasons.
Weapon Player:Give( string weaponClassName, boolean bNoAmmo = false )
Gives the player a weapon. While this function is meant for weapons/pickupables only, it is not restricted to weapons. Any entity can be spawned using this function, including NPCs and SENTs.
number Player:GiveAmmo( number amount, any type, boolean hidePopup = false )
Gives ammo to a player
Player:GodDisable()
Disables god mode on the player.
Player:GodEnable()
Enables god mode on the player.
Returns whether the player has god mode or not, contolled by Player:GodEnable and Player:GodDisable.
boolean Player:HasWeapon( string className )
Returns if the player has the specified weapon
Returns if the player is in a vehicle
string Player:IPAddress()
Returns the player's IP address and connection port in ip:port form Returns Error! for bots.
boolean Player:IsAdmin()
Returns whether the player is an admin or not. It will also return true if the player is Player:IsSuperAdmin by default. Internally this is determined by Player:IsUserGroup.
boolean Player:IsBot()
Returns if the player is an bot or not
Returns true from the point when the player is sending client info but not fully in the game until they disconnect.
Used to find out if a player is currently 'driving' an entity (by which we mean 'right click > drive' ).
boolean Player:IsFrozen()
Returns whether the players movement is currently frozen, controlled by Player:Freeze.
Returns whether the player identity was confirmed by the steam network. See also GM:PlayerAuthed.
Returns if a player is the host of the current session.
boolean Player:IsMuted()
Returns whether or not the player is muted locally.
Returns true if the player is playing a taunt.
Returns whenever the player is heard by the local player clientside, or if the player is speaking serverside.
Returns whether the player is currently sprinting or not, specifically if they are holding their sprint key and are allowed to sprint. This will not check if the player is currently sprinting into a wall. (i. e. holding their sprint key but not moving)
Returns whenever the player is equipped with the suit item. This will only work for the local player when used clientside. Issue Tracker: 3449
Returns whether the player is a super admin. Internally this is determined by Player:IsUserGroup. See also Player:IsAdmin.
Returns true if the player is timing out (i. e. is losing connection), false otherwise. A player is considered timing out when more than 4 seconds has elapsed since a network packet was received from given player.
boolean Player:IsTyping()
Returns whether the player is typing in their chat. This may not work properly if the server uses a custom chatbox.
boolean Player:IsUserGroup( string groupname )
Returns true/false if the player is in specified group or not. See Player:GetUserGroup for a way to get player's usergroup.
Returns if the player can be heard by the local player.
Returns if the player currently walking. (+walk keybind)
Returns whether the player is using the world clicking feature, see Panel:SetWorldClicker
Returns whether the world clicking is disabled for given player or not. See Player:DisableWorldClicking.
boolean Player:KeyDown( number key )
Returns whether a key is down. This is not networked to other players, meaning only the local client can see the keys they are pressing.
boolean Player:KeyDownLast( number key )
Gets whether a key was down one tick ago.
boolean Player:KeyPressed( number key )
Gets whether a key was just pressed this tick.
boolean Player:KeyReleased( number key )
Gets whether a key was just released this tick.
Player:Kick( string reason = "No reason given" )
Kicks the player from the server. This can not be run before the player has fully joined in. Use game. KickID for that.
Player:Kill()
Kills a player and calls GM:PlayerDeath.
Player:KillSilent()
Kills a player without notifying the rest of the server. This will call GM:PlayerSilentDeath instead of GM:PlayerDeath.
Player:LagCompensation( boolean lagCompensation )
This allows the server to mitigate the lag of the player by moving back all the entities that can be lag compensated to the time the player attacked with his weapon. This technique is most commonly used on things that hit other entities instantaneously, such as traces. Entity:FireBullets calls this function internally. Lag compensation only works for players and entities that have been enabled with Entity:SetLagCompensated Despite being defined shared, it can only be used server-side in a Predicted Hook. This function NEEDS to be disabled after you're done with it or it will break the movement of the entities affected!Lag compensation does not support pose parameters. Issue Tracker: 3683
Returns the hitgroup where the player was last hit.
Player:LimitHit( string type )
Shows "limit hit" notification in sandbox. This function is only available in Sandbox and its derivatives.
Returns the direction a player is looking as a entity/local-oriented angle. Unlike Entity:EyeAngles, this function does not include angles of the Player's Entity:GetParent.
Player:Lock()
Stops a player from using any inputs, such as moving, turning, or attacking. Key binds are still called. Similar to Player:Freeze but the player takes no damage. Adds the FL_FROZEN and FL_GODMODE flags to the player. Frozen bots will still be able to look around.
Returns the position of a Kinect bone.
string Player:Name()
Returns the players name. Identical to Player:Nick and Player:GetName.
string Player:Nick()
Returns the player's nickname.
Returns the 64-bit SteamID aka CommunityID of the Steam Account that owns the Garry's Mod license this player is using. This is useful for detecting players using Steam Family Sharing. If player is not using Steam Family Sharing, this will return the player's actual SteamID64(). This data will only be available after the player has fully authenticated with Steam. See Player:IsFullyAuthenticated.
Returns the packet loss of the client. It is not networked so it only returns 0 when run clientside.
Unfreezes the props player is looking at. This is essentially the same as pressing reload with the physics gun, including double press for unfreeze all.
Player:PickupObject( Entity entity )
This makes the player hold ( same as pressing e on a small prop ) the provided entity. Don't get this confused with picking up items like ammo or health kitsThis picks up the passed entity regardless of its mass or distance from the player
boolean Player:PickupWeapon( Weapon wep, boolean ammoOnly = false )
Forces the player to pickup an existing weapon entity. The player will not pick up the weapon if they already own a weapon of given type, or if the player could not normally have this weapon in their inventory. This function will bypass GM:PlayerCanPickupWeapon.
number Player:Ping()
Returns the player's ping to server.
Player:PlayStepSound( number volume )
Plays the correct step sound according to what the player is staying on.
Player:PrintMessage( number type, string message )
Displays a message either in their chat, console, or center of the screen. See also PrintMessage. When called serverside, this uses the archaic user message system (the umsg) and hence is limited to ≈250 characters. HUD_PRINTCENTER will not work when this is called clientside.
Player:RemoveAllAmmo()
Removes all ammo from a certain player
Player:RemoveAllItems()
Removes all weapons and ammo from the player.
Player:RemoveAmmo( number ammoCount, string ammoName )
Removes the amount of the specified ammo from the player.
boolean Player:RemovePData( string key )
Removes a Persistent Data key-value pair from the SQL database. (sv. db when called on server, cl. db when called on client) Internally uses the sql library. See util. RemovePData for cases when the player is not currently on the server. This function internally uses Player:SteamID64, it previously utilized Player:UniqueID which can cause collisions (two or more players sharing the same PData entry). Player:SetPData now replaces all instances of Player:UniqueID with Player:SteamID64 when running Player:SetPDataPData is not networked from servers to clients!
Player:RemoveSuit()
Strips the player's suit item.
Player:ResetHull()
Resets both normal and duck hulls to their default values.
Player:Say( string text, boolean teamOnly = false )
Forces the player to say whatever the first argument is. Works on bots too. This function ignores the default chat message cooldown
Player:ScreenFade( number flags, number clr = color_white, number fadeTime, number fadeHold )
Fades the screen
Player:SelectWeapon( string className )
Sets the active weapon of the player by its class name. This will switch the weapon out of prediction, causing delay on the client and WEAPON:Deploy and WEAPON:Holster to be called out of prediction. Try using CUserCmd:SelectWeapon or input. SelectWeapon, instead. This will trigger the weapon switch event and associated animations. To switch weapons silently, use Player:SetActiveWeapon.
Player:SendHint( string name, number delay )
Sends a hint to a player. This function is only available in Sandbox and its derivatives. Since this adds #Hint_ to the beginning of each message, you should only use it with default hint messages, or those cached with language. Add. For hints with custom text, look at notification. AddLegacy.
Player:SendLua( string script )
Executes a simple Lua string on the player. If you need to use this function more than once consider using net library. Send net message and make the entire code you want to execute in net. Receive on client. The string is limited to 254 bytes. Consider using the net library for more advanced server-client interaction.
Player:SetActiveWeapon( Weapon weapon )
Sets the player's active weapon. You should use CUserCmd:SelectWeapon or Player:SelectWeapon, instead in most cases. This function will not trigger the weapon switch events or associated equip animations. It will bypass GM:PlayerSwitchWeapon and the currently active weapon's WEAPON:Holster return value.
Player:SetActivity( number act )
Sets the player's activity.
Player:SetAllowFullRotation( boolean Allowed )
Set if the players' model is allowed to rotate around the pitch and roll axis.
Allows player to use their weapons in a vehicle. You need to call this before entering a vehicle. Shooting in a vehicle fires two bullets. Issue Tracker: 1277
Player:SetAmmo( number ammoCount, any ammoType )
Sets the amount of the specified ammo for the player.
Player:SetArmor( number Amount )
Sets the player armor to the argument.
Player:SetAvoidPlayers( boolean avoidPlayers )
Pushes the player away from another player whenever it's inside the other players bounding box.
Player:SetCanWalk( boolean abletowalk )
Set if the player should be allowed to walk using the (default) alt key.
Player:SetCanZoom( boolean canZoom )
Sets whether the player can use the HL2 suit zoom ("+zoom" bind) or not.
Player:SetClassID( number classID )
Sets the player's class id.
Player:SetCrouchedWalkSpeed( number speed )
Sets the crouched walk speed multiplier. Doesn't work for values above 1. See also Player:SetWalkSpeed and Player:GetCrouchedWalkSpeed.
Player:SetCurrentViewOffset( Vector viewOffset )
Sets the actual view offset which equals the difference between the players actual position and their view when standing. Do not confuse with Player:SetViewOffset and Player:SetViewOffsetDucked
Player:SetDeaths( number deathcount )
Sets a player's death count
Player:SetDrivingEntity( Entity drivingEntity = NULL, number drivingMode )
This is used internally - although you're able to use it you probably shouldn't. Sets the driving entity and driving mode. Use drive. PlayerStartDriving instead, see Entity Driving.
Player:SetDSP( number soundFilter, boolean fastReset )
Applies the specified sound filter to the player.
Player:SetDuckSpeed( number duckSpeed )
Sets how quickly a player ducks. This will not work for values >= 1. Issue Tracker: 2722
Player:SetEyeAngles( Angle angle )
Sets the local angle of the player's view (may rotate body too if angular difference is large)
Player:SetFOV( number fov, number time = 0, Entity requester = self )
Set a player's FOV (Field Of View) over a certain amount of time.
Player:SetFrags( number fragcount )
Sets a player's frags (kills)
Player:SetHands( Entity hands )
Sets the hands entity of a player. The hands entity is an entity introduced in Garry's Mod 13 and it's used to show the player's hands attached to the viewmodel. This is similar to the approach used in L4D and CS:GO, for more information on how to implement this system in your gamemode visit Using Viewmodel Hands.
Player:SetHoveredWidget( Entity widget = NULL )
Sets the widget that is currently hovered by the player's mouse.
Player:SetHull( Vector hullMins, Vector hullMaxs )
Sets the mins and maxs of the AABB of the players collision. See Player:SetHullDuck for the hull while crouching/ducking.
Player:SetHullDuck( Vector hullMins, Vector hullMaxs )
Sets the mins and maxs of the AABB of the players collision when ducked. See Player:SetHull for setting the hull while standing.
Player:SetJumpPower( number jumpPower )
Sets the jump power, eg. the velocity that will be applied to the player when they jump.
Player:SetLadderClimbSpeed( number speed )
Sets the player's ladder climbing speed. See Player:SetWalkSpeed for normal walking speed, Player:SetRunSpeed for sprinting speed and Player:SetSlowWalkSpeed for slow walking speed.
Player:SetLaggedMovementValue( number timescale )
Slows down the player movement simulation by the timescale, this is used internally in the HL2 weapon stripping sequence. It achieves such behavior by multiplying the FrameTime by the specified timescale at the start of the movement simulation and then restoring it afterwards. This is reset to 1 on spawn. There is no weapon counterpart to this, you'll have to hardcode the multiplier in the weapon or call Weapon:SetNextPrimaryFire / Weapon:SetNextSecondaryFire manually.
Player:SetLastHitGroup( number hitgroup )
Sets the hitgroup where the player was last hit.
Player:SetMaxArmor( number maxarmor )
Sets the maximum amount of armor the player should have. This affects default built-in armor pickups, but not Player:SetArmor.
Player:SetMaxSpeed( number walkSpeed )
Sets the maximum speed which the player can move at. This is called automatically by the engine. If you wish to limit player speed without setting their run/sprint speeds, see CMoveData:SetMaxClientSpeed.
Player:SetMuted( boolean mute )
Sets if the player should be muted locally.
Player:SetNoCollideWithTeammates( boolean shouldNotCollide )
Sets whenever the player should not collide with their teammates, based on their Player:Team. This will only work for teams with ID 1 to 4 due to internal Engine limitations. This causes traces with COLLISION_GROUP_PLAYER to pass through players.
Player:SetNoTarget( boolean visibility )
Sets the players visibility towards NPCs. Internally this toggles the FL_NOTARGET flag, which you can manually test for using Entity:IsFlagSet
Player:SetObserverMode( number mode )
Sets the players observer mode. You must start the spectating first with Player:Spectate.
boolean Player:SetPData( string key, any value )
Writes a Persistent Data key-value pair to the SQL database. (sv. db when called on server, cl. db when called on client) Internally uses the sql library. See util. SetPData for cases when the player is not currently on the server. This function internally uses Player:SteamID64, it previously utilized Player:UniqueID which can cause collisions (two or more players sharing the same PData entry). Player:SetPData now replaces all instances of Player:UniqueID with Player:SteamID64 when running Player:SetPDataPData is not networked from servers to clients!
Player:SetPlayerColor( Vector Color )
Sets the player model's color. The part of the model that is colored is determined by the model itself, and is different for each model.
Player:SetPressedWidget( Entity pressedWidget = NULL )
Sets the widget that is currently in use by the player's mouse. Having a pressed widget stops the player from firing their weapon to allow input to be passed onto the widget.
Player:SetRenderAngles( Angle ang )
Sets the render angles of a player. Value set by this function is reset to player's angles (Entity:GetAngles) right after GM:UpdateAnimation.
Player:SetRunSpeed( number runSpeed )
Sets the player's sprint speed. See also Player:GetRunSpeed, Player:SetWalkSpeed and Player:SetMaxSpeed. player_default class run speed is: 600
Player:SetSlowWalkSpeed( number speed )
Sets the player's slow walking speed, which is activated via +walk keybind. See Player:SetWalkSpeed for normal walking speed, Player:SetRunSpeed for sprinting speed and Player:SetLadderClimbSpeed for ladder climb speed.
Player:SetStepSize( number stepHeight )
Sets the maximum height a player can step onto without jumping.
Player:SetSuitPower( number power )
Sets the player's HEV suit power. This will only work for the local player when used clientside. Issue Tracker: 3449
Player:SetSuppressPickupNotices( boolean doSuppress )
Sets whenever to suppress the pickup notification for the player.
Player:SetTeam( number Team )
Sets the player to the chosen team.
Player:SetUnDuckSpeed( number UnDuckSpeed )
Sets how quickly a player un-ducks
Player:SetupHands( Entity ent )
Sets up the players view model hands. Calls GM:PlayerSetHandsModel to set the model of the hands.
Player:SetUserGroup( string groupName )
Sets the usergroup of the player.
Player:SetViewEntity( Entity viewEntity )
Attaches the players view to the position and angles of the specified entity.
Player:SetViewOffset( Vector viewOffset )
Sets the desired view offset which equals the difference between the players actual position and their view when standing. If you want to set actual view offset, use Player:SetCurrentViewOffset See also Player:SetViewOffsetDucked for desired view offset when crouching.
Player:SetViewOffsetDucked( Vector viewOffset )
Sets the desired view offset which equals the difference between the players actual position and their view when crouching. If you want to set actual view offset, use Player:SetCurrentViewOffset See also Player:SetViewOffset for desired view offset when standing.
Player:SetViewPunchAngles( Angle punchAngle )
Sets client's view punch angle, but not the velocity. See Player:ViewPunch
Player:SetViewPunchVelocity( Angle punchVel )
Sets client's view punch velocity. See Player:ViewPunch and Player:SetViewPunchAngles
Sets the voice volume scale for given player on client. This value will persist from server to server, but will be reset when the game is shut down. This doesn't work on bots, their scale will always be 1.
Player:SetWalkSpeed( number walkSpeed )
Sets the player's normal walking speed. Not sprinting, not slow walking +walk. See also Player:SetSlowWalkSpeed, Player:GetWalkSpeed, Player:SetCrouchedWalkSpeed, Player:SetMaxSpeed and Player:SetRunSpeed. Using a speed of 0 can lead to prediction errors. Issue Tracker: 2030player_default class walk speed is: 400.
Player:SetWeaponColor( Vector Color )
Sets the player weapon's color. The part of the model that is colored is determined by the model itself, and is different for each model.
Returns whether the player's player model will be drawn at the time the function is called.
Player:ShouldDropWeapon( boolean drop )
Sets whether the player's current weapon should drop on death. This is reset on spawn to the player class's DropWeaponOnDie field by player_manager. OnPlayerSpawn.
Player:ShowProfile()
Opens the player steam profile page in the steam overlay browser.
Signals the entity that it was dropped by the gravity gun.
Player:SimulateGravGunPickup( Entity ent, boolean lightning = false )
Signals the entity that it was picked up by the gravity gun. This call is only required if you want to simulate the situation of picking up objects.
Player:Spectate( number mode )
Starts spectate mode for given player. This will also affect the players movetype in some cases.
Player:SpectateEntity( Entity entity )
Makes the player spectate the entity. To get the applied spectated entity, use Player:GetObserverTarget.
Player:SprayDecal( Vector sprayOrigin, Vector sprayEndPos )
Makes a player spray their decal.
Player:SprintDisable()
Disables the sprint on the player.
Player:SprintEnable()
Enables the sprint on the player.
Player:StartSprinting()
We advise against using this. It may be changed or removed in a future update. This appears to be a direct binding to internal functionality that is overridden by the engine every frame so calling these functions may not have any or expected effect. Doesn't appear to do anything.
Player:StartWalking()
We advise against using this. It may be changed or removed in a future update. This appears to be a direct binding to internal functionality that is overridden by the engine every frame so calling these functions may not have any or expected effect. When used in a GM:SetupMove hook, this function will force the player to walk, as well as preventing the player from sprinting.
string Player:SteamID()
Returns the player's SteamID. See Player:AccountID for a shorter version of the SteamID and Player:SteamID64 for the full SteamID. It is recommended to use Player:SteamID64 over the other SteamID formats whenever possible. In a -multirun environment, this will return STEAM_0:0:0 (serverside) or NULL (clientside) for all "copies" of a player because they are not authenticated with Steam. For Bots this will return BOT.
string Player:SteamID64()
Returns the player's full 64-bit SteamID, also known as CommunityID. Information on how data is packed into this value can be found here. See Player:AccountID for a function that returns only the Account ID part of the SteamID and Player:SteamID for the text version of the SteamID. In a -multirun environment, this will return "0" for all "copies" of a player because they are not authenticated with Steam. For bots, this will return 90071996842377216 (equivalent to STEAM_0:0:0) for the first bot to join. For each additional bot, the number increases by 1. So the next bot will be 90071996842377217 (STEAM_0:1:0) then 90071996842377218 (STEAM_0:0:1) and so on.
Player:StopSprinting()
We advise against using this. It may be changed or removed in a future update. This appears to be a direct binding to internal functionality that is overridden by the engine every frame so calling these functions may not have any or expected effect. When used in a GM:SetupMove hook, this function will prevent the player from sprinting. When +walk is engaged, the player will still be able to sprint to half speed (normal run speed) as opposed to full sprint speed without this function.
Player:StopWalking()
We advise against using this. It may be changed or removed in a future update. This appears to be a direct binding to internal functionality that is overridden by the engine every frame so calling these functions may not have any or expected effect. When used in a GM:SetupMove hook, this function behaves unexpectedly by preventing the player from sprinting similar to Player:StopSprinting.
Player:StopZooming()
Turns off the zoom mode of the player. (+zoom console command) Basically equivalent of entering "-zoom" into player's console.
Player:StripAmmo()
We advise against using this. It may be changed or removed in a future update. Alias of Player:RemoveAllAmmo Removes all ammo from the player.
Player:StripWeapon( string weapon )
Removes the specified weapon class from a certain player this function will call the Entity:OnRemove but if you try use Entity:GetOwner it will return nil
Player:StripWeapons()
Removes all weapons from a certain player
Player:SuppressHint( string name )
Prevents a hint from showing up. This function is only available in Sandbox and its derivatives
Attempts to switch the player weapon to the one specified in the "cl_defaultweapon" convar, if the player does not own the specified weapon nothing will happen. If you want to switch to a specific weapon, use: Player:SetActiveWeapon
number Player:Team()
Returns the player's team ID. Returns 0 clientside when the game is not fully loaded.
Returns the time in seconds since the player connected. Bots will always return value 0.
Entity Player:TraceHullAttack( Vector startPos, Vector endPos, Vector mins, Vector maxs, number damage, number damageFlags, number damageForce, boolean damageAllNPCs )
Performs a trace hull and applies damage to the entities hit, returns the first entity hit. Hitting the victim entity with this function in ENTITY:OnTakeDamage can cause infinite loops.
Translates ACT enum according to the holdtype of players currently held weapon.
Unfreezes all objects the player has frozen with their Physics Gun. Same as double pressing R while holding Physics Gun.
number Player:UniqueID()
We advise against using this. It may be changed or removed in a future update. This function has collisions, where more than one player can have the same UniqueID. It is highly recommended to use Player:SteamID64 or Player:SteamID instead, which are guaranteed to be unique to each player. Returns a 32 bit integer that remains constant for a player across joins/leaves and across different servers. This can be used when a string is inappropriate - e. g. in a database primary key. In Singleplayer, this function will always return 1.
table Player:UniqueIDTable( any key )
We advise against using this. It may be changed or removed in a future update. This is based on Player:UniqueID which is deprecated and vulnerable to collisions. Returns a table that will stay allocated for the specific player serveside between connects until the server shuts down. On client it has no such special behavior. This table is not synchronized (networked) between client and server.
Player:UnLock()
Unlocks the player movement if locked previously. Will disable godmode for the player if locked previously.
Player:UnSpectate()
Stops the player from spectating another entity.
number Player:UserID()
Returns the player's ID. You can use Player() to get the player by their ID.
Player:ViewPunch( Angle PunchAngle )
Simulates a push on the client's screen. This adds view punch velocity, and does not touch the current view punch angle, for which you can use Player:SetViewPunchAngles.
Player:ViewPunchReset( number tolerance = 0 )
Resets the player's view punch (and the view punch velocity, read more at Player:ViewPunch) effect back to normal.
Returns the players voice volume, how loud the player's voice communication currently is, as a normal number. Doesn't work on local player unless the voice_loopback convar is set to 1.