Garry's Mod Wiki

GM

Hooks that are available for all gamemodes based on base gamemode.

See also: Structures/GM

Events

boolean GM:AcceptInput( Entity ent, string input, Entity activator, Entity caller, any value )
Called when a map I/O event occurs. See also Entity:Fire and Entity:Input for functions to fire Inputs on entities.
GM:AddDeathNotice( string attacker, number attackerTeam, string inflictor, string victim, number victimTeam )
Adds a death notice entry. You cannot use hook.Add on this hook yet.Issue Tracker: 2611
number GM:AdjustMouseSensitivity( number defaultSensitivity )
Allows you to adjust the mouse sensitivity.
boolean GM:AllowPlayerPickup( Player ply, Entity ent )
Called when a player tries to pick up something using the "use" key, return to override. See GM:GravGunPickupAllowed for the Gravity Gun pickup variant.
number, number GM:CalcMainActivity( Player ply, Vector vel )
This hook is used to calculate animations for a player. This hook must return the same values at the same time on both, client and server. On client for players to see the animations, on server for hit detection to work properly.This can return the incorrect velocity when on a moving object.Issue Tracker: 3322
table GM:CalcVehicleView( Vehicle veh, Player ply, table view )
Called from GM:CalcView when player is in driving a vehicle. This hook may not be called in gamemodes that override GM:CalcView.
table GM:CalcView( Player ply, Vector origin, Angle angles, number fov, number znear, number zfar )
Allows override of the default view.
Vector, Angle GM:CalcViewModelView( Weapon wep, Entity vm, Vector oldPos, Angle oldAng, Vector pos, Angle ang )
Allows overriding the position and angle of the viewmodel.
boolean GM:CanEditVariable( Entity ent, Player ply, string key, string val, table editor )
Called when a variable is edited on an Entity (called by Edit Properties... menu), to determine if the edit should be permitted. See Editable entities for more details about the system.
boolean GM:CanExitVehicle( Vehicle veh, Player ply )
Determines if the player can exit the vehicle.
boolean GM:CanPlayerEnterVehicle( Player player, Vehicle vehicle, number role )
Determines whether or not the player can enter the vehicle. Called just before GM:PlayerEnteredVehicle.
boolean GM:CanPlayerSuicide( Player player )
Determines if the player can kill themselves using the concommands kill or explode.
boolean GM:CanPlayerUnfreeze( Player player, Entity entity, PhysObj phys )
Determines if the player can unfreeze the entity.
boolean GM:CanUndo( Player ply, table undo )
Called whenever a players tries to undo.
GM:CaptureVideo()
Called each frame to record demos to video using IVideoWriter. This hook is called every frame regardless of whether or not a demo is being recorded
boolean GM:ChatText( number index, string name, string text, string type )
Called when a message is printed to the chat box. Note, that this isn't working with player messages even though there are arguments for it. For player messages see GM:PlayerSay and GM:OnPlayerChat
GM:ChatTextChanged( string text )
Called whenever the content of the user's chat input box is changed.
boolean, string GM:CheckPassword( string steamID64, string ipAddress, string svPassword, string clPassword, string name )
Called when a non local player connects to allow the Lua system to check the password. The default behaviour in the base gamemodes emulates what would normally happen. If sv_password is set and its value matches the password passed in by the client - then they are allowed to join. If it isn't set it lets them in too.
GM:CloseDermaMenus()
Called when derma menus are closed with CloseDermaMenus.
GM:CreateClientsideRagdoll( Entity entity, Entity ragdoll )
Called whenever an entity becomes a clientside ragdoll. See GM:CreateEntityRagdoll for serverside ragdolls.
GM:CreateEntityRagdoll( Entity owner, Entity ragdoll )
Called when a serverside ragdoll of an entity has been created. See GM:CreateClientsideRagdoll for clientside ragdolls.
boolean GM:CreateMove( CUserCmd cmd )
Allows you to change the players movements before they're sent to the server. See Game Movement for an explanation on the move system. Due to this hook being clientside only, it could be overridden by the user allowing them to completely skip your logic, it is recommended to use GM:StartCommand in a shared file instead.
GM:CreateTeams()
Teams are created within this hook using team.SetUp. This hook is called before GM:PreGamemodeLoaded.
number GM:DoAnimationEvent( Player ply, number event, number data = 0 )
Called upon an animation event, this is the ideal place to call player animation functions such as Player:AddVCDSequenceToGestureSlot, Player:AnimRestartGesture and so on.
GM:DoPlayerDeath( Player ply, Entity attacker, CTakeDamageInfo dmg )
Handles the player's death. This hook is not called if the player is killed by Player:KillSilent. See GM:PlayerSilentDeath for that. GM:PlayerDeath is called after this hook GM:PostPlayerDeath is called after that Player:Alive returns true when this is called
GM:DrawDeathNotice( number x, number y )
This hook is called every frame to draw all of the current death notices.
GM:DrawMonitors()
Called every frame before drawing the in-game monitors ( Breencast, in-game TVs, etc ), but doesn't seem to be doing anything, trying to render 2D or 3D elements fail.
GM:DrawOverlay()
Called after all other 2D draw hooks are called. Draws over all VGUI Panels and HUDs. Unlike GM:HUDPaint, this hook is called with the game paused and while the Camera SWEP is equipped. Only gets called when r_drawvgui is enabled.This is a rendering hook which provides a 2d rendering context.
boolean GM:DrawPhysgunBeam( Player ply, Weapon physgun, boolean enabled, Entity target, number physBone, Vector hitPos )
Allows you to override physgun beam drawing. This is still called when physgun_drawbeams is disabled.Issue Tracker: 3294
GM:EndEntityDriving( Entity ent, Player ply )
Called right before an entity stops driving. Overriding this hook will cause it to not call drive.End and the player will not stop driving.
boolean GM:EntityEmitSound( table data )
Called whenever a sound has been played. This will not be called clientside if the server played the sound without the client also calling Entity:EmitSound. This is not called for scripted sequences.Issue Tracker: 1021
boolean GM:EntityFireBullets( Entity entity, table data )
Called every time a bullet is fired from an entity. This hook is called directly from Entity:FireBullets. Due to this, you cannot call Entity:FireBullets inside this hook or an infinite loop will occur crashing the game.
string GM:EntityKeyValue( Entity ent, string key, string value )
Called when a key-value pair is set on an entity, either by the engine (for example when map spawns) or Entity:SetKeyValue. See ENTITY:KeyValue for a hook that works for scripted entities. See WEAPON:KeyValue for a hook that works for scripted weapons.
GM:EntityNetworkedVarChanged( Entity ent, string name, any oldval, any newval )
Called when an NWVar is changed. Currently this hook only works for the NW2Var system (accessed by adding a 2 in between NW and Var for most NWVar functions), which will replace the original one at some point in the futureThis hook is fired before the client value is actually changed. Calling the GetNW function for the specified variable name within this hook will return the old value, not the current/updated one.
GM:EntityRemoved( Entity ent )
Called right before the removal of an entity. This hook is called during clientside full updates. See ENTITY:OnRemove for more information.Issue Tracker: 4675
boolean GM:EntityTakeDamage( Entity target, CTakeDamageInfo dmg )
Called when an entity takes damage. You can modify all parts of the damage info in this hook.
Entity GM:FindUseEntity( Player ply, Entity defaultEnt )
This hook polls the entity the player use action should be applied to. The default behavior of this hook is in CBasePlayer::FindUseEntity. Despite CBasePlayer::FindUseEntity being defined shared, it is only called serverside in practice, so this hook will be only called serverside, as well. It is possible for modules to call it clientside, so the Lua code should still be treated as shared.
GM:FinishChat()
Runs when user cancels/finishes typing.
boolean GM:FinishMove( Player ply, CMoveData mv )
Called after GM:Move, applies all the changes from the CMoveData to the player. See Game Movement for an explanation on the move system.
string GM:ForceDermaSkin()
Called to allow override of the default Derma skin for all panels. This hook is only called on Lua start up, changing its value (or adding new hooks) after it has been already called will not have any effect.
GM:GameContentChanged()
Called to refresh menu content once it has initialized or something has been mounted.
number GM:GetFallDamage( Player ply, number speed )
Called when a player takes damage from falling, allows to override the damage.
string GM:GetGameDescription()
Called when the game(server) needs to update the text shown in the server browser as the gamemode. This hook (and the sv_gamename_override command) may not work on some popular gamemodes like DarkRP or Trouble Terrorist Town. This is not a bug, it's just how it works. See here for more information.This hook only works on dedicated servers.
number, number, number, number GM:GetMotionBlurValues( number horizontal, number vertical, number forward, number rotational )
Allows you to modify the Source Engine's motion blur shaders.
Angle GM:GetPreferredCarryAngles( Entity ent )
Called to determine preferred carry angles for the entity. It works for both, +use pickup and gravity gun pickup. Due to nature of the gravity gun coding in multiplayer, this hook MAY seem to not work ( but rest assured it does ), due to clientside prediction not knowing the carry angles. The +use pickup doesn't present this issue as it doesn't predict the player carrying the object clientside ( as you may notice by the prop lagging behind in multiplayer )This hook can not override preferred carry angles..
table GM:GetTeamColor( Entity ent )
Returns the color for the given entity's team. This is used in chat and deathnotice text.
table GM:GetTeamNumColor( number team )
Returns the team color for the given team index.
GM:GrabEarAnimation( Player ply )
Override this hook to disable/change ear-grabbing in your gamemode.
GM:GravGunOnDropped( Player ply, Entity ent )
Called when an entity is released by a gravity gun.
GM:GravGunOnPickedUp( Player ply, Entity ent )
Called when an entity is picked up by a gravity gun.
boolean GM:GravGunPickupAllowed( Player ply, Entity ent )
Called every tick to poll whether a player is allowed to pick up an entity with the gravity gun or not. See GM:AllowPlayerPickup for the +USE pickup variant. Calls ENTITY:GravGunPickupAllowed on the entity being hovered every frame in Sandbox-derived gamemodes.
boolean GM:GravGunPunt( Player ply, Entity ent )
Called when an entity is about to be punted with the gravity gun (primary fire). By default this function makes ENTITY:GravGunPunt work in Sandbox derived gamemodes.
GM:GUIMouseDoublePressed( number mouseCode, Vector aimVector )
Called when the mouse has been double clicked on any panel derived from CGModBase, such as the panel used by gui.EnableScreenClicker and the panel used by Panel:ParentToHUD. By default this hook calls GM:GUIMousePressed.
GM:GUIMousePressed( number mouseCode, Vector aimVector )
Called whenever a players presses a mouse key on the context menu in Sandbox or on any panel derived from CGModBase, such as the panel used by gui.EnableScreenClicker and the panel used by Panel:ParentToHUD. See GM:VGUIMousePressed for a hook that is called on all VGUI elements.
GM:GUIMouseReleased( number mouseCode, Vector aimVector )
Called whenever a players releases a mouse key on the context menu in Sandbox or on any panel derived from CGModBase, such as the panel used by gui.EnableScreenClicker and the panel used by Panel:ParentToHUD.
boolean GM:HandlePlayerDriving( Player ply )
Allows to override player driving animations.
boolean GM:HandlePlayerDucking( Player ply, number velocity )
Allows to override player crouch animations.
boolean GM:HandlePlayerJumping( Player ply, number velocity )
Called every frame by the player model animation system. Allows to override player jumping animations.
boolean GM:HandlePlayerLanding( Player ply, number velocity, boolean onGround )
Allows to override player landing animations.
boolean GM:HandlePlayerNoClipping( Player ply, number velocity )
Allows to override player noclip animations.
boolean GM:HandlePlayerSwimming( Player ply, number velocity )
Allows to override player swimming animations.
boolean GM:HandlePlayerVaulting( Player ply, number velocity )
Allows to override player flying ( in mid-air, not noclipping ) animations.
GM:HideTeam()
Hides the team selection panel.
GM:HUDAmmoPickedUp( string itemName, number amount )
Called when the client has picked up ammo. Override to disable default HUD notification.
GM:HUDDrawPickupHistory()
Renders the HUD pick-up history. Override to hide default or draw your own HUD.
GM:HUDDrawScoreBoard()
Called every frame to render the scoreboard. It is recommended to use Derma and VGUI for this job instead of this hook. Called right after GM:HUDPaint. This is a rendering hook which provides a 2d rendering context.
GM:HUDDrawTargetID()
Called from GM:HUDPaint to draw player info when you hover over a player with your crosshair or mouse.
GM:HUDItemPickedUp( string itemName )
Called when an item has been picked up. Override to disable the default HUD notification.
GM:HUDPaint()
Called whenever the HUD should be drawn. Called right before GM:HUDDrawScoreBoard and after GM:HUDPaintBackground. Not called when the Camera SWEP is equipped. See also GM:DrawOverlay. Gets called only when r_drawvgui and CHudGMod are enabled and the game is not pausedThis is a rendering hook which provides a 2d rendering context.
GM:HUDPaintBackground()
Called before GM:HUDPaint when the HUD background is being drawn. Things rendered in this hook will always appear behind things rendered in GM:HUDPaint. This is a rendering hook which provides a 2d rendering context.
boolean GM:HUDShouldDraw( string name )
Called when the Gamemode is about to draw a given element on the client's HUD (heads-up display). This hook is called HUNDREDS of times per second (more than 5 times per frame on average). You shouldn't be performing any computationally intensive operations.
GM:HUDWeaponPickedUp( Weapon weapon )
Called when a weapon has been picked up. Override to disable the default HUD notification.
GM:Initialize()
Called after the gamemode loads and starts.
GM:InitPostEntity()
Called after all the entities are initialized. Starting from this hook LocalPlayer will return valid object. At this point the client only knows about the entities that are within the spawnpoints' PVS. For instance, if the server sends an entity that is not within this PVS, the client will receive it as NULL entity.When this hook is called on the client, net messages will reliably be received.
boolean GM:InputMouseApply( CUserCmd cmd, number x, number y, Angle ang )
Allows you to modify the supplied User Command with mouse input. This could be used to make moving the mouse do funky things to view angles.
boolean GM:IsSpawnpointSuitable( Player ply, Entity spawnpoint, boolean makeSuitable )
Check if a player can spawn at a certain spawnpoint.
GM:KeyPress( Player ply, number key )
Called whenever a player pressed a key included within the IN keys. For a more general purpose function that handles all kinds of input, see GM:PlayerButtonDown. Due to this being a predicted hook, ParticleEffects created only serverside from this hook will not be networked to the client, so make sure to do that on both realms.
GM:KeyRelease( Player ply, number key )
Runs when a IN key was released by a player. For a more general purpose function that handles all kinds of input, see GM:PlayerButtonUp.
GM:LoadGModSave( string data, string map, number timestamp )
This is used internally - although you're able to use it you probably shouldn't. Called from gm_load when the game should load a map.
GM:MenuStart()
Called when menu.lua has finished loading.
GM:MouthMoveAnimation( Player ply )
Override this gamemode function to disable mouth movement when talking on voice chat.
boolean GM:Move( Player ply, CMoveData mv )
The Move hook is called for you to manipulate the player's MoveData. You shouldn't adjust the player's position in any way in the move hook. This is because due to prediction errors, the netcode might run the move hook multiple times as packets arrive late. Therefore you should only adjust the movedata construct in this hook. Generally you shouldn't have to use this hook - if you want to make a custom move type you should look at the drive system. This hook is called after GM:PlayerTick. See Game Movement..
boolean GM:NeedsDepthPass()
Returning true in this hook will cause it to render depth buffers defined with render.GetResolvedFullFrameDepth.
GM:NetworkEntityCreated( Entity ent )
Called when an entity has been created over the network.
GM:NetworkIDValidated( string name, string steamID )
Called when a player has been validated by Steam.
GM:NotifyShouldTransmit( Entity ent, boolean shouldtransmit )
Called whenever this entity changes its transmission state for this LocalPlayer, such as exiting or re entering the PVS. This is the best place to handle the reset of Entity:SetPredictable, as this would be usually called when the player lags and requests a full packet updateWhen the entity stops transmitting, Entity:IsDormant will only return true after this hook
GM:OnAchievementAchieved( Player ply, number achievement )
Called when a player has achieved an achievement. You can get the name and other information from an achievement ID with the achievements library.
string GM:OnChatTab( string text )
Called when the local player presses TAB while having their chatbox opened.
boolean GM:OnCleanup( string name )
Called when the player cleans up something.
GM:OnContextMenuClose()
Called when the context menu keybind (+menu_context) is released, which by default is C. This hook will not run if input.IsKeyTrapping returns true. See also GM:OnContextMenuOpen.
GM:OnContextMenuOpen()
Called when the context menu keybind (+menu_context) is pressed, which by default is c. See also GM:OnContextMenuClose.
GM:OnCrazyPhysics( Entity ent, PhysObj physobj )
Called when the crazy physics detection detects an entity with Crazy Physics.
GM:OnDamagedByExplosion( Player ply, CTakeDamageInfo dmginfo )
Called when a player has been hurt by an explosion. Override to disable default sound effect.
GM:OnEntityCreated( Entity entity )
Called when the entity is created. Some entities on initial map spawn are passed through this hook, and then removed in the same frame. This is used by the engine to precache things like models and sounds, so always check their validity with IsValid.Removing the created entity during this event can lead to unexpected problems. Use timer.Simple( 0, .... ) to safely remove the entity.
GM:OnEntityWaterLevelChanged( Entity entity, number old, number new )
Called when the Entity:WaterLevel of an entity is changed. This hook can be considered a physics callback, so changing collision rules (Entity:SetSolidFlags) in it may lead to a crash!
GM:OnGamemodeLoaded()
Called when the gamemode is loaded. LocalPlayer() returns NULL at the time this is run.
GM:OnLuaError( string error, number realm, table stack, string name, number id )
Called when a Lua error occurs, only works in the Menu realm. Modify menu state Lua code at your own risk!
GM:OnNPCKilled( NPC npc, Entity attacker, Entity inflictor )
Called whenever an NPC is killed.
boolean GM:OnPhysgunFreeze( Entity weapon, PhysObj physobj, Entity ent, Player ply )
Called when a player freezes an entity with the physgun. This is not called for players or NPCs being held with the physgun.Issue Tracker: 723
GM:OnPhysgunPickup( Player ply, Entity ent )
Called to when a player has successfully picked up an entity with their Physics Gun. Not to be confused with GM:PhysgunPickup which is called multiple times to ask if the player should be able to pick up an entity.
boolean GM:OnPhysgunReload( Weapon physgun, Player ply )
Called when a player reloads with the physgun. Override this to disable default unfreezing behavior.
GM:OnPlayerChangedTeam( Player ply, number oldTeam, number newTeam )
We advise against using this. It may be changed or removed in a future update. Use GM:PlayerChangedTeam instead, which works for every Player:SetTeam call. Called when a player has changed team using GM:PlayerJoinTeam. This hook will not work with hook.Add and it is only called manually from GM:PlayerJoinTeam by the base gamemode
boolean GM:OnPlayerChat( Player ply, string text, boolean teamChat, boolean isDead )
Called whenever a player sends a chat message. For the serverside equivalent, see GM:PlayerSay. The text input of this hook depends on GM:PlayerSay. If it is suppressed on the server, it will be suppressed on the client. This also means, that a message surpressed with this hook will be still visible to other clients.
boolean GM:OnPlayerHitGround( Entity player, boolean inWater, boolean onFloater, number speed )
Called when a player makes contact with the ground after a jump or a fall.
GM:OnReloaded()
Called when gamemode has been reloaded by auto refresh. It seems that this event can be triggered more than once for a single refresh event.
GM:OnScreenSizeChanged( number oldWidth, number oldHeight )
Called when the player's screen resolution of the game changes. ScrW and ScrH will return the new values when this hook is called.
GM:OnSpawnMenuClose()
Called when a player releases the +menu bind on their keyboard, which is bound to Q by default.
GM:OnSpawnMenuOpen()
Called when a player presses the +menu bind on their keyboard, which is bound to Q by default.
GM:OnTextEntryGetFocus( Panel panel )
Called when a DTextEntry gets focus. This hook is run from DTextEntry:OnGetFocus and PANEL:OnMousePressed of DTextEntry.
GM:OnTextEntryLoseFocus( Panel panel )
Called when DTextEntry loses focus.
boolean GM:OnUndo( string name, string customText )
Called when the player undoes something.
GM:OnViewModelChanged( Entity viewmodel, string oldModel, string newModel )
Called when the player changes their weapon to another one - and their viewmodel model changes. This is not always called clientside.Issue Tracker: 2473
GM:PhysgunDrop( Player ply, Entity ent )
Called when a player drops an entity with the Physgun.
boolean GM:PhysgunPickup( Player player, Entity entity )
Called to determine if a player should be able to pick up an entity with the Physics Gun. See GM:OnPhysgunPickup for a hook which is called when a player has successfully picked up an entity.
GM:PlayerAmmoChanged( Player ply, number ammoID, number oldCount, number newCount )
Called when player's reserve ammo count changes.
GM:PlayerAuthed( Player ply, string steamid, string uniqueid )
Called once when the player is authenticated. CurTime returns 0 in this hook.Issue Tracker: 3026
boolean GM:PlayerBindPress( Player ply, string bind, boolean pressed )
Runs when a bind has been pressed. Allows to block commands. By using the "alias" console command, this hook can be effectively circumvented. To prevent this use input.TranslateAlias. To stop the user from using +attack, +left and any other movement commands of the sort, please look into using GM:StartCommand instead.The third argument will always be true.Issue Tracker: 1176This does not run for function keys binds (F1-F12).Issue Tracker: 2888
GM:PlayerButtonDown( Player ply, number button )
Called when a player presses a button. This will not be called if player has a panel opened with keyboard input enabled, use PANEL:OnKeyCodePressed instead.
GM:PlayerButtonUp( Player ply, number button )
Called when a player releases a button. This will not be called if player has a panel opened with keyboard input enabled, use PANEL:OnKeyCodeReleased instead.
boolean, boolean GM:PlayerCanHearPlayersVoice( Player listener, Player talker )
Decides whether a player can hear another player using voice chat. This hook is called several times a tick, so ensure your code is efficient.
boolean GM:PlayerCanJoinTeam( Player ply, number team )
Returns whether or not a player is allowed to join a team
boolean GM:PlayerCanPickupItem( Player ply, Entity item )
Returns whether or not a player is allowed to pick an item up.
boolean GM:PlayerCanPickupWeapon( Player ply, Weapon weapon )
Returns whether or not a player is allowed to pick up a weapon.
boolean GM:PlayerCanSeePlayersChat( string text, boolean teamOnly, Player listener, Player speaker )
Returns whether or not the player can see the other player's chat. The speaker parameter does not have to be a valid Player object which happens when console messages are displayed for example.
GM:PlayerChangedTeam( Player ply, number oldTeam, number newTeam )
Called when a player has changed team using Player:SetTeam. Avoid calling Player:SetTeam in this hook as it may cause an infinite loop!
boolean GM:PlayerCheckLimit( Player ply, string limitName, number current, number defaultMax )
Called whenever a player is about to spawn something to see if they hit a limit for whatever they are spawning. This hook will not be called in singleplayer, as singleplayer does not have limits.
GM:PlayerClassChanged( Player ply, number newID )
This is used internally - although you're able to use it you probably shouldn't. Called whenever a player's class is changed on the server-side with player_manager.SetPlayerClass.
GM:PlayerConnect( string name, string ip )
Executes when a player connects to the server. Called before the player has been assigned a UserID and entity. See the player_connect gameevent for a version of this hook called after the player entity has been created. This is only called clientside for listen server hosts.This is not called clientside for the local player.
GM:PlayerDeath( Player victim, Entity inflictor, Entity attacker )
Called when a player is killed by Player:Kill or any other normal means. This hook is not called if the player is killed by Player:KillSilent. See GM:PlayerSilentDeath for that. GM:DoPlayerDeath is called before this hook. GM:PostPlayerDeath is called after this hook. See Player:LastHitGroup if you need to get the last hit hitgroup of the player. Player:Alive will return true in this hook.
boolean GM:PlayerDeathSound()
Returns whether or not the default death sound should be muted.
boolean GM:PlayerDeathThink( Player ply )
Called every think while the player is dead. The return value will determine if the player respawns. Overwriting this function will prevent players from respawning by pressing space or clicking. This hook is not called for players with the FL_FROZEN flag applied.Issue Tracker: 1577
GM:PlayerDisconnected( Player ply )
Called when a player leaves the server. See the player_disconnect gameevent for a shared version of this hook. Player:SteamID, Player:SteamID64, and the like can return nil here.This is not called in single-player or listen servers for the host.Issue Tracker: 3523
GM:PlayerDriveAnimate( Player ply )
Called to update the player's animation during a drive.
GM:PlayerDroppedWeapon( Player owner, Weapon wep )
Called when a weapon is dropped by a player via Player:DropWeapon. Also called when a weapon is removed from a player via Player:StripWeapon. See also GM:WeaponEquip for a hook when a player picks up a weapon. The weapon's Entity:GetOwner will be NULL at the time this hook is called. WEAPON:OnDrop will be called before this hook is.
GM:PlayerEndVoice( Player ply )
Called when player stops using voice chat.
GM:PlayerEnteredVehicle( Player ply, Vehicle veh, number role )
Called when a player enters a vehicle. Called just after GM:CanPlayerEnterVehicle. See also GM:PlayerLeaveVehicle.
boolean GM:PlayerFireAnimationEvent( Player ply, Vector pos, Angle ang, number event, string name )
Called before firing clientside animation events on a player model. See GM:PlayerHandleAnimEvent for the serverside version.
boolean GM:PlayerFootstep( Player ply, Vector pos, number foot, string sound, number volume, CRecipientFilter filter )
Called whenever a player steps. Return true to mute the normal sound. This hook is called on all clients.
GM:PlayerFrozeObject( Player ply, Entity ent, PhysObj physobj )
Called when a player freezes an object.
GM:PlayerHandleAnimEvent ( Player ply, number event, number eventTime, number cycle, number type, string options )
Called before firing serverside animation events on the player models. See GM:PlayerFireAnimationEvent for the clientside version.
GM:PlayerHurt( Player victim, Entity attacker, number healthRemaining, number damageTaken )
Called when a player gets hurt.
GM:PlayerInitialSpawn( Player player, boolean transition )
Called when the player spawns for the first time. See GM:PlayerSpawn for a hook called every player spawn. This hook is called before the player has fully loaded, when the player is still in seeing the Starting Lua screen. For example, trying to use the Entity:GetModel function will return the default model (models/player.mdl).Due to the above note, sending net messages to the spawned player in this hook are highly unreliable, and they most likely won't be received. See https://github.com/Facepunch/garrys..
GM:PlayerJoinTeam( Player ply, number team )
Makes the player join a specified team. This is a convenience function that calls Player:SetTeam and runs the GM:OnPlayerChangedTeam hook.
GM:PlayerLeaveVehicle( Player ply, Vehicle veh )
Called when a player leaves a vehicle. For vehicles with exit animations, this will be called at the end of the animation, not at the start!This is not called when a different vehicle is immediately entered with Player:EnterVehicle.Issue Tracker: 2619
GM:PlayerLoadout( Player ply )
Called to give players the default set of weapons. This function may not work in your custom gamemode if you have overridden your GM:PlayerSpawn and you do not use self.BaseClass.PlayerSpawn or hook.Call.
boolean GM:PlayerNoClip( Player ply, boolean desiredState )
Called when a player tries to switch noclip mode.
GM:PlayerPostThink( Player ply )
Called after the player's think.
GM:PlayerRequestTeam( Player ply, number team )
Request a player to join the team. This function will check if the team is available to join or not. This hook is called when the player runs "changeteam" in the console. To prevent the player from changing teams, see GM:PlayerCanJoinTeam
string GM:PlayerSay( Player sender, string text, boolean teamChat )
Called when a player dispatched a chat message. For the clientside equivalent, see GM:OnPlayerChat.
Entity GM:PlayerSelectSpawn( Player ply, boolean transition )
Called to determine a spawn point for a player to spawn at.
Entity GM:PlayerSelectTeamSpawn( number team, Player ply )
Find a team spawn point entity for this player.
GM:PlayerSetHandsModel( Player ply, Entity ent )
Called whenever view model hands needs setting a model. By default this calls PLAYER:GetHandsModel and if that fails, sets the hands model according to his player model.
GM:PlayerSetModel( Player ply )
Called whenever a player spawns and must choose a model. A good place to assign a model to a player. This function may not work in your custom gamemode if you have overridden your GM:PlayerSpawn and you do not use self.BaseClass.PlayerSpawn or hook.Call.
boolean GM:PlayerShouldTakeDamage( Player ply, Entity attacker )
Returns true if the player should take damage from the given attacker.
boolean GM:PlayerShouldTaunt( Player ply, number act )
Allows to suppress player taunts.
GM:PlayerSilentDeath( Player ply )
Called when the player is killed by Player:KillSilent. The player is already considered dead when this hook is called. See GM:PlayerDeath for a hook which handles all other death causes. GM:PostPlayerDeath is called after this hook. Player:Alive will return true in this hook.
GM:PlayerSpawn( Player player, boolean transition )
Called whenever a player spawns, including respawns. See GM:PlayerInitialSpawn for a hook called only the first time a player spawns. See the player_spawn gameevent for a shared version of this hook. By default, in "base" derived gamemodes, this hook will also call GM:PlayerLoadout and GM:PlayerSetModel, which may override your Entity:SetModel and Player:Give calls. Consider using the other hooks or a 0-second timer.
GM:PlayerSpawnAsSpectator( Player ply )
Called to spawn the player as a spectator.
boolean GM:PlayerSpray( Player sprayer )
Determines if the player can spray using the impulse 201 console command.
GM:PlayerStartTaunt( Player ply, number act, number length )
Called when player starts taunting.
GM:PlayerStartVoice( Player ply )
Called when a player starts using voice chat.
number GM:PlayerStepSoundTime( Player ply, number type, boolean walking )
Allows you to override the time between footsteps. This hook is called on all clients.
boolean GM:PlayerSwitchFlashlight( Player ply, boolean enabled )
Called whenever a player attempts to either turn on or off their flashlight, returning false will deny the change. Also gets called when using Player:Flashlight.
boolean GM:PlayerSwitchWeapon( Player player, Weapon oldWeapon, Weapon newWeapon )
Called when a player attempts to switch their weapon. Primary usage of this hook is to prevent/allow weapon switching, not to detect weapon switching. It will not be called for Player:SetActiveWeapon.
GM:PlayerTick( Player player, CMoveData mv )
The Move hook is called for you to manipulate the player's CMoveData. This hook is called moments before GM:Move and GM:PlayerNoClip. This hook will not run when inside a vehicle. GM:VehicleMove will be called instead.
boolean GM:PlayerTraceAttack( Player ply, CTakeDamageInfo dmginfo, Vector dir, table trace )
Called when a player has been hit by a trace and damaged (such as from a bullet). Returning true overrides the damage handling and prevents GM:ScalePlayerDamage from being called.
GM:PlayerUnfrozeObject( Player ply, Entity ent, PhysObj physobj )
Called when a player unfreezes an object.
boolean GM:PlayerUse( Player ply, Entity ent )
Triggered when the player presses use on an object. Continuously runs until USE is released but will not activate other Entities until the USE key is released; dependent on activation type of the Entity.
GM:PopulateMenuBar( Panel menubar )
Called when it's time to populate the context menu menu bar at the top.
GM:PostCleanupMap()
Called right after the map has cleaned up (usually because game.CleanUpMap was called) See also GM:PreCleanupMap.
GM:PostDraw2DSkyBox()
Called right after the 2D skybox has been drawn - allowing you to draw over it. This is a rendering hook which provides a 3d rendering context.
GM:PostDrawEffects()
Called after rendering effects. This is where halos are drawn. Called just before GM:PreDrawHUD. This is a rendering hook which provides a 2d rendering context.
GM:PostDrawHUD()
Called after GM:PreDrawHUD, GM:HUDPaintBackground and GM:HUDPaint but before GM:DrawOverlay. This is a rendering hook which provides a 2d rendering context.
GM:PostDrawOpaqueRenderables( boolean bDrawingDepth, boolean bDrawingSkybox )
Called after drawing opaque entities. See also GM:PostDrawTranslucentRenderables and GM:PreDrawOpaqueRenderables. This is a rendering hook which provides a 3d rendering context.
GM:PostDrawPlayerHands( Entity hands, Entity vm, Player ply, Weapon weapon )
Called after the player hands are drawn.
GM:PostDrawSkyBox()
Called after drawing the 3D skybox. This will not be called if skybox rendering was prevented via the GM:PreDrawSkyBox hook. See also GM:PostDraw2DSkyBox. This is a rendering hook which provides a 3d rendering context.
GM:PostDrawTranslucentRenderables( boolean bDrawingDepth, boolean bDrawingSkybox )
Called after all translucent entities are drawn. See also GM:PostDrawOpaqueRenderables and GM:PreDrawTranslucentRenderables. This is a rendering hook which provides a 3d rendering context.This is still called when r_drawentities or r_drawopaquerenderables is disabled.Issue Tracker: 3295This is not called when r_drawtranslucentworld is disabled.Issue Tracker: 3296
GM:PostDrawViewModel( Entity viewmodel, Player player, Weapon weapon )
Called after view model is drawn. This is a rendering hook which provides a 3d rendering context.The 3D rendering context in this event is different from the main view. Every render operation will only be accurate with the view model entity.
GM:PostEntityTakeDamage( Entity ent, CTakeDamageInfo dmg, boolean took )
Called when an entity receives a damage event, after passing damage filters, etc.
GM:PostGamemodeLoaded()
Called after the gamemode has loaded.
GM:PostPlayerDeath( Player ply )
Called right after GM:DoPlayerDeath, GM:PlayerDeath and GM:PlayerSilentDeath. This hook will be called for all deaths, including Player:KillSilent The player is considered dead when this is hook is called, Player:Alive will return false.
GM:PostPlayerDraw( Player ply, number flags )
Called after the player was drawn. This is a rendering hook which provides a 3d rendering context.
boolean GM:PostProcessPermitted( string ppeffect )
Allows you to suppress post processing effect drawing.
GM:PostRender()
Called after the frame has been rendered.
GM:PostRenderVGUI()
Called after the VGUI has been drawn. This is a rendering hook which provides a 2d rendering context.
GM:PreCleanupMap()
Called right before the map cleans up (usually because game.CleanUpMap was called) See also GM:PostCleanupMap.
GM:PreDrawEffects()
Called just after GM:PreDrawViewModel and can technically be considered "PostDrawAllViewModels". This is a rendering hook which provides a 3d rendering context.
GM:PreDrawHalos()
Called before rendering the halos. This is the place to call halo.Add. This hook is actually running inside of GM:PostDrawEffects. This is a rendering hook which provides a 3d rendering context.
GM:PreDrawHUD()
Called just after GM:PostDrawEffects. Drawing anything in it seems to work incorrectly. This is a rendering hook which provides a 2d rendering context.
boolean GM:PreDrawOpaqueRenderables( boolean isDrawingDepth, boolean isDrawSkybox )
Called before all opaque entities are drawn. See also GM:PreDrawTranslucentRenderables and GM:PostDrawOpaqueRenderables. This is a rendering hook which provides a 3d rendering context.
boolean GM:PreDrawPlayerHands( Entity hands, Entity vm, Player ply, Weapon weapon )
Called before the player hands are drawn.
boolean GM:PreDrawSkyBox()
Called before the 3D sky box is drawn. This will not be called for maps with no 3D skybox, or when the 3d skybox is disabled. (r_3dsky 0) See also GM:PostDrawSkyBox This is a rendering hook which provides a 3d rendering context.
boolean GM:PreDrawTranslucentRenderables( boolean isDrawingDepth, boolean isDrawSkybox )
Called before all the translucent entities are drawn. See also GM:PreDrawOpaqueRenderables and GM:PostDrawTranslucentRenderables. This is a rendering hook which provides a 3d rendering context.This is still called when r_drawentities or r_drawopaquerenderables is disabled.Issue Tracker: 3295This is not called when r_drawtranslucentworld is disabled.Issue Tracker: 3296
boolean GM:PreDrawViewModel( Entity vm, Player ply, Weapon weapon )
Called before the view model has been drawn. This hook by default also calls this on weapons, so you can use WEAPON:PreDrawViewModel. You can use GM:PreDrawEffects as a "PostDrawViewModel" hook as it is called just after the view model(s) are drawn. This is a rendering hook which provides a 3d rendering context.
GM:PreDrawViewModels()
Called before view models and entities with RENDERGROUP_VIEWMODEL are drawn. You can use GM:PreDrawEffects as a PostDrawViewModel hook as it is called just after the view model(s) are drawn. This is a rendering hook which provides a 3d rendering context.
GM:PreGamemodeLoaded()
Called before the gamemode is loaded.
boolean GM:PrePlayerDraw( Player player, number flags )
Called before the player is drawn.
boolean GM:PreRender()
Called before the renderer is about to start rendering the next frame.
boolean GM:PreventScreenClicks()
This will prevent in_attack from sending to server when player tries to shoot from C menu.
GM:PropBreak( Player attacker, Entity prop )
Called when a prop has been destroyed.
boolean GM:RenderScene( Vector origin, Angle angles, number fov )
Render the scene. Used by the Stereoscopy post-processing effect. Materials rendered in this hook require $ignorez parameter to draw properly.
GM:RenderScreenspaceEffects()
Used to render post processing effects. This is a rendering hook which provides a 2d rendering context.
GM:Restored()
Called when the game is reloaded from a Source Engine save system ( not the Sandbox saves or dupes ). See GM:Saved for a hook that is called when such a save file is created.
GM:Saved()
Called when the game is saved using the Source Engine save system (not the Sandbox saves or dupes). See GM:Restored for a hook that is called when such a save file is loaded. See also the saverestore for relevant functions.
GM:ScaleNPCDamage( NPC npc, number hitgroup, CTakeDamageInfo dmginfo )
Called when an NPC takes damage. This hook is called only when a specific hit group of the NPC is hit. In cases where the hitgroup doesn't matter, you should use GM:EntityTakeDamage instead!
boolean GM:ScalePlayerDamage( Player ply, number hitgroup, CTakeDamageInfo dmginfo )
This hook allows you to change how much damage a player receives when one takes damage to a specific body part. This is called only for bullet damage a player receives, you should use GM:EntityTakeDamage instead if you need to detect ALL damage.
GM:ScoreboardHide()
Called when player released the scoreboard button. ( TAB by default )
GM:ScoreboardShow()
Called when player presses the scoreboard button. ( TAB by default )
GM:SetPlayerSpeed( Player ply, number walkSpeed, number runSpeed )
Sets player run and sprint speeds. This is not a hook. Treat this as a utility function to set the player's speed.
GM:SetupMove( Player ply, CMoveData mv, CUserCmd cmd )
SetupMove is called before the engine process movements. This allows us to override the players movement. See Game Movement for an explanation on the move system.
GM:SetupPlayerVisibility( Player ply, Entity viewEntity )
Allows you to add extra positions to the player's PVS. This is the place to call AddOriginToPVS.
boolean GM:SetupSkyboxFog( number scale )
Allows you to use render.Fog* functions to manipulate skybox fog.
boolean GM:SetupWorldFog()
Allows you to use render.Fog* functions to manipulate world fog.
boolean GM:ShouldCollide( Entity ent1, Entity ent2 )
Called to decide whether a pair of entities should collide with each other. This is only called if Entity:SetCustomCollisionCheck was used on one or both entities. Where applicable, consider using constraint.NoCollide or a logic_collision_pair entity instead - they are considerably easier to use and may be more appropriate in some situations. This hook must return the same value consistently for the same pair of entities. If an entity changed in such a way that its collision rules change, you must call En..
boolean GM:ShouldDrawLocalPlayer( Player ply )
Called to determine if the LocalPlayer should be drawn. Due to an optimization, this hook is only called once per frame. This is problematic if you need to have the player drawn only in certain contexts, such as within render.RenderView or based on the render target. As a workaround, you can call cam.Start3D and cam.End3D within this hook to force the engine to call it every time.Issue Tracker: 3092If you're using this hook to draw a player for a GM:CalcView hook, then you may want to consider using the d..
GM:ShowHelp( Player ply )
Called when a player executes gm_showhelp console command. ( Default bind is F1 )
GM:ShowSpare1( Player ply )
Called when a player executes gm_showspare1 console command. ( Default bind is F3 )
GM:ShowSpare2( Player ply )
Called when a player executes gm_showspare2 console command. ( Default bind is F4 )
GM:ShowTeam( Player ply )
Called when a player executes gm_showteam console command. ( Default bind is F2 )
GM:ShutDown()
Called whenever the Lua environment is about to be shut down, for example on map change, or when the server is going to shut down. Player:SteamID, Player:SteamID64, and the like will return nil for the listen host here but work fine for other players.
GM:SpawniconGenerated( string lastmodel, string imagename, number modelsleft )
Called when spawn icon is generated.
boolean GM:StartChat( boolean isTeamChat )
Runs when the user tries to open the chat box. Returning true won't stop the chatbox from taking VGUI focus.Issue Tracker: 855
GM:StartCommand( Player ply, CUserCmd ucmd )
Allows you to change the players inputs before they are processed by the server. This is basically a shared version of GM:CreateMove. This function is also called for bots, making it the best solution to control them so farThis hook is predicted, but not by usual means, this hook is called when a CUserCmd is generated on the client, and on the server when it is received, so it is necessary for this hook to be called clientside even on singleplayer
GM:StartEntityDriving( Entity ent, Player ply )
Called right before an entity starts driving. Overriding this hook will cause it to not call drive.Start and the player will not begin driving the entity.
GM:StartGame()
Called when you start a new game via the menu.
GM:Think()
Called every frame on client and server. This will be the same as GM:Tick on the server when there is no lag, but will only be called once every processed server frame during lag. See GM:Tick for a hook that runs every tick on both the client and server. This hook WILL NOT run if the server is empty, unless you set the ConVar sv_hibernate_think to 1
GM:Tick()
Called every server tick. Serverside, this is similar to GM:Think. This hook WILL NOT run if the server is empty, unless you set the ConVar sv_hibernate_think to 1
number GM:TranslateActivity( Player ply, number act )
Allows you to translate player activities.
GM:UpdateAnimation( Player ply, Vector velocity, number maxSeqGroundSpeed )
Animation updates (pose params etc) should be done here.
GM:VariableEdited( Entity ent, Player ply, string key, string val, table editor )
Called when a variable is edited on an Entity (called by Edit Properties... menu). See Editable Entities for more information.
GM:VehicleMove( Player ply, Vehicle veh, CMoveData mv )
Called when you are driving a vehicle. This hook works just like GM:Move. This hook is called before GM:Move and will be called when GM:PlayerTick is not.
boolean GM:VGUIMousePressAllowed( number button )
Called when user clicks on a VGUI panel.
GM:VGUIMousePressed( Panel pnl, number mouseCode )
Called when a mouse button is pressed on a VGUI element or menu.
GM:WeaponEquip( Weapon weapon, Player owner )
Called as a weapon entity is picked up by a player. See also GM:PlayerDroppedWeapon. At the time when this hook is called Entity:GetOwner will return NULL. The owner is set on the next frame.This will not be called when picking up a weapon you already have as the weapon will be removed and WEAPON:EquipAmmo will be called instead.
GM:WorkshopDownloadedFile( number id, string title )
Called when an addon from the Steam workshop finishes downloading. Used by default to update details on the workshop downloading panel.
GM:WorkshopDownloadFile( number id, number imageID, string title, number size )
Called when an addon from the Steam workshop begins downloading. Used by default to place details on the workshop downloading panel.
GM:WorkshopDownloadProgress( number id, number imageID, string title, number downloaded, number expected )
Called while an addon from the Steam workshop is downloading. Used by default to update details on the fancy workshop download panel.
GM:WorkshopDownloadTotals( number remain, number total )
Called after GM:WorkshopStart.
GM:WorkshopEnd()
Called when downloading content from Steam workshop ends. Used by default to hide fancy workshop downloading panel.
GM:WorkshopExtractProgress( number id, number ImageID, string title, number percent )
Called while an addon from the Steam workshop is extracting. Used by default to update details on the fancy workshop download panel.
GM:WorkshopStart()
Called when downloading content from Steam workshop begins. Used by default to show fancy workshop downloading panel. The order of Workshop hooks is this: WorkshopStart WorkshopDownloadTotals These are called for each new item: *** WorkshopDownloadFile *** WorkshopDownloadProgress - This is called until the file is finished *** WorkshopDownloadedFile WorkshopEnd
GM:WorkshopSubscriptionsProgress( number num, number max )
This is used internally - although you're able to use it you probably shouldn't. Called by the engine when the game initially fetches subscriptions to be displayed on the bottom of the main menu screen.

Page Links


Special Pages


Wikis

?

Render Time: 45ms

DB GetPage 4
Generate Html 9
SaveChanges (1) 10
Render Body 0
Render Sidebar 17