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.

Methods

number Player:AccountID()
Returns the player's AccountID aka SteamID3. For bots this will return values starting with 0 for the first bot, 1 for the second bot and so on. In singleplayer, this will return no value.
Player:AddCleanup( string type, Entity ent )
Adds an entity to the players clean up list.
Player:AddCount( string str, Entity ent )
Adds an entity to the total count of entities of same class.
Player:AddDeaths( number count )
Add a certain amount to the player's death count
Player:AddFrags( number count )
Add a certain amount to the player's frag count (or kills count)
Player:AddFrozenPhysicsObject( Entity ent, PhysObj physobj )
Adds a entity to the players 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 Enums/ACT
boolean Player:Alive()
Checks if the player is alive.
Player:AllowFlashlight( boolean canFlashlight )
Sets if the player can toggle his flashlight. Function exists on both the server and client but has no effect when ran on the client.
Player:AllowImmediateDecalPainting( boolean allow )
Lets the player spray his decal without delay
Player:AnimResetGestureSlot( number slot )
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.
Player:AnimRestartMainSequence()
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.
boolean Player:CanUseFlashlight()
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 limitType )
Checks if the limit is hit or not. If it is, it will throw a notification saying so.
Player:ConCommand( string command )
Runs the concommand on the player. This does not work on bots. 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.On clientside running a ConCommand on an other player will not throw any warnings or errors but will run the ConCommand on LocalPlayer() instead.
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.
Player:CrosshairDisable()
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.
boolean Player:Crouching()
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.
Player:DetonateTripmines()
Detonates all tripmines belonging to the player.
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.
Player:DoSecondaryAttack()
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 )
Enters the player into specified vehicle
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()
Makes the player exit the vehicle if they're in one.
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.
boolean Player:FlashlightIsOn()
Returns true if the player's flashlight is on.
number Player:Frags()
Returns the amount of kills a player has.
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.
Weapon Player:GetActiveWeapon()
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.
Vector Player:GetAimVector()
Returns the direction that the player is aiming.
boolean Player:GetAllowFullRotation()
Returns true if the players' model is allowed to rotate around the pitch and roll axis.
boolean Player:GetAllowWeaponsInVehicle()
Returns whether the player is allowed to use his 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.
boolean Player:GetAvoidPlayers()
Gets if the player will be pushed out of nocollided players.
boolean Player:GetCanWalk()
Returns true if the player is able to walk using the (default) alt key.
boolean Player:GetCanZoom()
Determines whenever the player is allowed to use the zoom functionality.
number Player:GetClassID()
Returns the player's class id.
Player:GetCount( string type, number minus = 0 )
Gets total count of entities of same class.
number Player:GetCrouchedWalkSpeed()
Returns the crouched walk speed multiplier. See also Player:GetWalkSpeed and Player:SetCrouchedWalkSpeed.
CUserCmd Player:GetCurrentCommand()
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.
Vector Player:GetCurrentViewOffset()
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
Entity Player:GetDrivingEntity()
Gets the entity the player is currently driving.
number Player:GetDrivingMode()
Returns driving mode of the player. See Entity Driving.
number Player:GetDuckSpeed()
Returns a player's duck speed (in seconds)
Entity Player:GetEntityInUse()
Returns the entity the player is currently using, like func_tank mounted turrets or +use prop pickups.
table Player:GetEyeTrace()
Returns a table with information of what the player is looking at. The results of this function are cached every frame. Uses util.GetPlayerTrace internally and is therefore bound by its limits. See also Player:GetEyeTraceNoCursor
table 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 every frame. See also Player:GetEyeTrace
number Player:GetFOV()
Returns the FOV of the player.
string Player:GetFriendStatus()
Returns the steam "relationship" towards the player.
Entity Player:GetHands()
Gets the hands entity of a player
Entity Player:GetHoveredWidget()
Returns the widget the player is hovering with his mouse.
Vector, Vector Player:GetHull()
Gets the bottom base and the top base size of the player's hull.
Vector, Vector Player:GetHullDuck()
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.
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.
number Player:GetJumpPower()
Returns the jump power of the player
number Player:GetLadderClimbSpeed()
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.
number Player:GetLaggedMovementValue()
Returns the timescale multiplier of the player movement.
number Player:GetMaxSpeed()
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.
boolean Player:GetNoCollideWithTeammates()
Returns whenever the player is set not to collide with their teammates.
number Player:GetObserverMode()
Returns the the observer mode of the player
Entity Player:GetObserverTarget()
Returns the entity the player is currently observing. Set using Player:SpectateEntity.
string Player:GetPData( string key, any default = nil )
Returns a Player Data key-value pair from the SQL database. (sv.db when called on server, cl.db when called on client) Internally uses the sql. This function internally uses Player:UniqueID, which can cause collisions (two or more players sharing the same PData entry). It's recommended that you don't use it. See the related wiki page for more information.PData is not networked from servers to clients!
Vector Player:GetPlayerColor()
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. The format is Vector(r,g,b), and each color should be between 0 and 1.
table Player:GetPlayerInfo()
Returns a table containing player information.
Angle Player:GetPreferredCarryAngles( Entity carryEnt )
Returns the preferred carry angles of an object, if any are set. Calls GM:GetPreferredCarryAngles with the target entity and returns the carry angles.
Entity Player:GetPressedWidget()
Returns the widget entity the player is using. Having a pressed widget stops the player from firing his weapon to allow input to be passed onto the widget.
Entity Player:GetPreviousWeapon()
Returns the weapon the player previously had equipped.
Angle Player:GetPunchAngle()
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.
Entity Player:GetRagdollEntity()
Returns players death ragdoll. The ragdoll is created by Player:CreateRagdoll.
Angle Player:GetRenderAngles()
Returns the render angles for the player.
number Player:GetRunSpeed()
Returns the player's sprint speed. See also Player:SetRunSpeed, Player:GetWalkSpeed and Player:GetMaxSpeed.
Vector Player:GetShootPos()
Returns the position of a Player's view This is the same as calling Entity:EyePos on the player.
number Player:GetSlowWalkSpeed()
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.
number Player:GetStepSize()
Returns the maximum height player can step onto.
number Player:GetSuitPower()
Returns the player's HEV suit power. This will only work for the local player when used clientside.
number Player:GetTimeoutSeconds()
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.
table Player:GetTool( string mode = "nil" )
Returns TOOL table of players current tool, or of the one specified.
number Player:GetUnDuckSpeed()
Returns a player's unduck speed (in seconds)
Entity Player:GetUseEntity()
Returns the entity the player would use if they would press their +use keybind.
string Player:GetUserGroup()
Returns the player's user group.
Vehicle Player:GetVehicle()
Gets the vehicle the player is driving, returns NULL ENTITY if the player is not driving.
Entity Player:GetViewEntity()
Returns the entity the player is using to see from (such as the player itself, the camera, or another entity).
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.
Vector Player:GetViewOffset()
Returns the view offset of the player which equals the difference between the players actual position and their view. See also Player:GetViewOffsetDucked.
Vector 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.
Angle Player:GetViewPunchAngles()
Returns players screen punch effect angle.
number Player:GetWalkSpeed()
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
Vector Player:GetWeaponColor()
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.
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, string 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.
boolean Player:HasGodMode()
Returns whether the player has god mode or not, contolled by Player:GodEnable and Player:GodDisable. This is not synced between the client and server. This will cause the client to always return false even in godmode.Issue Tracker: 2038
boolean Player:HasWeapon( string className )
Returns if the player has the specified weapon
boolean Player:InVehicle()
Returns if the player is in a vehicle
string Player:IPAddress()
Returns the player's IP address and connection port in ip:port form
boolean Player:IsAdmin()
Returns whether the player is an admin or not.
boolean Player:IsBot()
Returns if the player is an bot or not
boolean Player:IsConnected()
Returns true from the point when the player is sending client info but not fully in the game until they disconnect.
boolean Player:IsDrivingEntity()
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, contolled by Player:Freeze.
boolean Player:IsFullyAuthenticated()
Returns whether the player identity was confirmed by the steam network.
boolean Player:IsListenServerHost()
Returns if a player is the host of the current session.
boolean Player:IsMuted()
Returns whether or not the player is muted locally.
boolean Player:IsPlayingTaunt()
Returns true if the player is playing a taunt.
boolean Player:IsSpeaking()
Returns whenever the player is heard by the local player.
boolean Player:IsSprinting()
Returns whether the player is currently sprinting or not.
boolean Player:IsSuitEquipped()
Returns whenever the player is equipped with the suit item. This will only work for the local player when used clientside.
boolean Player:IsSuperAdmin()
Returns whether the player is a superadmin.
boolean Player:IsTimingOut()
Returns true if the player is timing out (i.e. is losing connection), false otherwise.
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.
boolean Player:IsVoiceAudible()
Returns if the player can be heard by the local player.
boolean Player:IsWorldClicking()
Returns if the player is in the context menu. Although this is shared, it will only work properly on the CLIENT for the local player. Using this serverside or on other players will return false.
boolean Player:KeyDown( number key )
Gets 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...
number Player:LastHitGroup()
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.
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.
Vector Player:MotionSensorPos( number bone )
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.
string Player:OwnerSteamID64()
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.
number Player:PacketLoss()
Returns the packet loss of the client. It is not networked so it only returns 0 when run clientside.
number Player:PhysgunUnfreeze()
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 Player Data key-value pair from the SQL database. (sv.db when called on server, cl.db when called on client) Internally uses the sql. This function internally uses Player:UniqueID, which can cause collisions (two or more players sharing the same PData entry). It's recommended that you don't use it. See the related wiki page for more information.
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 event or associated equip animations. You can achieve this using Player:SelectWeapon with Entity:GetClass.This will not call GM:PlayerSwitchWeapon.
Player:SetAllowFullRotation( boolean Allowed )
Set if the players' model is allowed to rotate around the pitch and roll axis.
Player:SetAllowWeaponsInVehicle( boolean allow )
Allows player to use his weapons in a vehicle. You need to call this before entering a vehicle. Shooting in a vehicle fires two bullets.Weapon viewpunch does not decay while in a vehicle, leading to incorrect aim angles.
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.
Player:SetEyeAngles( Angle angle )
Sets the 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. Setting both the mins and maxs to Vector(0,0,0) will crash the game.
Player:SetHullDuck( Vector hullMins, Vector hullMaxs )
Sets the mins and maxs of the AABB of the players collision when ducked.
Player:SetJumpPower( number jumpPower )
Sets the jump power, eg. the velocity the player will applied to when he jumps.
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 spawnThere is no weapon counterpart to this, you'll have to hardcode the multiplier in the weapon or call Weapon:SetNextPrimaryFire / Weapon:SetNextSecondaryFire manually from a
Player:SetLastHitGroup( number hitgroup )
Sets the hitgroup where the player was last hit.
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. This only works with Player:Team IDs 1-4. This also has major collision issues. This is fixed in the next update.Issue Tracker: 2757Melee damage, such as from zombie attacks, will not register if this is turned on with Player:Team IDs 1-4. This is fixed in the next update.Issue Tracker: 1820
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 Player Data key-value pair to the SQL database. (sv.db when called on server, cl.db when called on client) Internally uses the sql. This function internally uses Player:UniqueID, which can cause collisions (two or more players sharing the same PData entry). It's recommended that you don't use it. See the related wiki page for more information.PData 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 his weapon to allow input to be passed onto the widget.
Player:SetRenderAngles( Angle ang )
Sets the render angles of a player.
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.
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. See Player:ViewPunch
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 run 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.
boolean Player:ShouldDrawLocalPlayer()
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.
Player:SimulateGravGunDrop( Entity ent )
Signals the entity that it was dropped by the gravity gun.
Player:SimulateGravGunPickup( Entity ent )
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. Using this function while spectating the player's own ragdoll will cause it to teleport it to the center of the map. You will spectate the ragdoll even after it's been teleported. This only happens on the client of the player spectating the ragdoll and is purely client-side.Issue Tracker: 4608
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. Not working - use Player:SetRunSpeed or CMoveData:SetMaxSpeed in a GM:Move hook, instead.Issue Tracker: 2390
Player:SprintEnable()
Enables the sprint on the player. Not working - use Player:SetRunSpeed or CMoveData:SetMaxSpeed in a GM:Move hook, instead.Issue Tracker: 2390
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. In singleplayer, this will be STEAM_ID_PENDING serverside. For Bots this will return BOT on the server and on the client it returns NULL. Use Player:AccountID for a shorter version of the SteamID.
string Player:SteamID64()
Returns the player's 64-bit SteamID aka CommunityID. In singleplayer, this will return no value serverside.In a multirun environment, this will return no value serverside for all "copies" of a player.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.On the client it returns no value for bots. U..
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()
Removes all ammo from the player.
Player:StripWeapon( string weapon )
Removes the specified weapon class from a certain player
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
Player:SwitchToDefaultWeapon()
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.
number Player:TimeConnected()
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, Vector 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.
number Player:TranslateWeaponActivity( number act )
Translates Enums/ACT according to the holdtype of players currently held weapon.
Player:UnfreezePhysicsObjects()
Unfreezes all objects the player has frozen with their Physics Gun. Same as double pressing R while holding Physics Gun.
number Player:UniqueID()
This function has collisions, where more than one player has the same UniqueID. It is highly recommended to use Player:AccountID, Player:SteamID or Player:SteamID64 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 )
Returns a table that will stay allocated for the specific player between connects until the server shuts down. Note, that this table is not synchronized 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.
Player:ViewPunchReset( number tolerance = 0 )
Resets the player's view punch ( Player:ViewPunch ) effect back to normal.
number Player:VoiceVolume()
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.

Page Links


Special Pages


Wikis

?

Render Time: 33ms

DB GetPage 3
Generate Html 4
SaveChanges (1) 9
Render Body 0
Render Sidebar 11