Gamemode Hooks

From GMod Wiki

Revision as of 17:17, 18 June 2011 by Wizard (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

How Gamemode Hooks Work

Hooks are how you make functions run when certain things happen in-game. For example, whenever a player dies the "PlayerDeath" hook is called on the server. In order to make these functions useful, each hook sends different arguments to the functions you add to the hook, like the player who's dying, the player who killed him, and the weapon that was used. The hooks below are all default hooks you find in their respective gamemodes. To use these hooks, you can either use hook.Add which runs in addition to all existing hooks, or override the function entirely using GAMEMODE:hook_Name/GM:hook_name which ignores all other hooks from hook. Add or those established in the gamemode.

The format for adding a gamemode hook is hook.Add( String hook_name, String unique_name, Function callback ).

To override, use GM:hook_name. ( ie GM:PlayerSpawn(ply) ).

For hook_name, use the name you want from the list below. Unique name is used to make sure that if your code is loaded twice, it's still only hooked once, For callback specify the function you wish to be called for the hook event. See Internal gamemode workings for information on the working of gamemodes.

If you're making your own gamemode, it'd be better to override some of these functions.



All Gamemodes

These hooks are for use with all gamemodes.

Server

NewerServer.png AcceptStream
NewerServer.png AllowPlayerPickup
NewerServer.png CanExitVehicle
NewerServer.png CanPlayerSuicide
NewerServer.png CanPlayerUnfreeze
NewerServer.png CreateEntityRagdoll
NewerServer.png DoPlayerDeath
NewerServer.png EntityTakeDamage
NewerServer.png GetFallDamage
NewerServer.png GetGameDescription
NewerServer.png GravGunOnDropped
NewerServer.png GravGunOnPickedUp
NewerServer.png GravGunPickupAllowed
NewerServer.png IsSpawnpointSuitable
NewerServer.png NetworkIDValidated
NewerServer.png OnDamagedByExplosion
NewerServer.png OnNPCKilled
NewerServer.png OnPhysgunFreeze
NewerServer.png OnPhysgunReload
NewerServer.png OnPlayerChangedTeam
NewerServer.png PlayerCanHearPlayersVoice
NewerServer.png PlayerCanJoinTeam
NewerServer.png PlayerCanPickupItem
NewerServer.png PlayerCanPickupWeapon
NewerServer.png PlayerCanSeePlayersChat
NewerServer.png PlayerDeath
NewerServer.png PlayerDeathSound
NewerServer.png PlayerDeathThink
NewerServer.png PlayerDisconnected
NewerServer.png PlayerHurt
NewerServer.png PlayerInitialSpawn
NewerServer.png PlayerJoinTeam
NewerServer.png PlayerLeaveVehicle
NewerServer.png PlayerLoadout
NewerServer.png PlayerRequestTeam
NewerServer.png PlayerSay
NewerServer.png PlayerSelectSpawn
NewerServer.png PlayerSelectTeamSpawn
NewerServer.png PlayerSetModel
NewerServer.png PlayerShouldAct
NewerServer.png PlayerShouldTakeDamage
NewerServer.png PlayerSilentDeath
NewerServer.png PlayerSpawn
NewerServer.png PlayerSpawnAsSpectator
NewerServer.png PlayerSpray
NewerServer.png PlayerSwitchFlashlight
NewerServer.png PlayerUse
NewerServer.png ScaleNPCDamage
NewerServer.png ScalePlayerDamage
NewerServer.png SetPlayerSpeed
NewerServer.png SetupPlayerVisibility
NewerServer.png ShowHelp
NewerServer.png ShowSpare1
NewerServer.png ShowSpare2
NewerServer.png ShowTeam
NewerServer.png WeaponEquip

Shared

NewerShared.png CalcMainActivity
NewerShared.png CanPlayerEnterVehicle
NewerShared.png CompletedIncomingStream
NewerShared.png ContextScreenClick
NewerShared.png CreateTeams
NewerShared.png DoAnimationEvent
NewerShared.png EntityKeyValue
NewerShared.png EntityRemoved
NewerShared.png FinishMove
NewerShared.png GravGunPunt
NewerShared.png HandlePlayerDriving
NewerShared.png HandlePlayerDucking
NewerShared.png HandlePlayerJumping
NewerShared.png HandlePlayerSwimming
NewerShared.png Initialize
NewerShared.png InitPostEntity
NewerShared.png KeyPress
NewerShared.png KeyRelease
NewerShared.png Move
NewerShared.png OnEntityCreated
NewerShared.png OnPlayerHitGround
NewerShared.png PhysgunDrop
NewerShared.png PhysgunPickup
NewerShared.png PlayerAuthed
NewerShared.png PlayerConnect
NewerShared.png PlayerEnteredVehicle
NewerShared.png PlayerFootstep
NewerShared.png PlayerNoClip
NewerShared.png PlayerStepSoundTime
NewerShared.png PlayerTraceAttack
NewerShared.png PostGamemodeLoaded
NewerShared.png PropBreak
NewerShared.png Restored
NewerShared.png Saved
NewerShared.png SetupMove
NewerShared.png ShouldCollide
NewerShared.png ShutDown
NewerShared.png Think
NewerShared.png Tick
NewerShared.png TranslateActivity
NewerShared.png UpdateAnimation

Client

NewerClient.png AddDeathNotice
NewerClient.png AdjustMouseSensitivity
NewerClient.png CalcVehicleThirdPersonView
NewerClient.png CalcView
NewerClient.png CallScreenClickHook
NewerClient.png ChatText
NewerClient.png ChatTextChanged
NewerClient.png CreateMove
NewerClient.png DrawDeathNotice
NewerClient.png DrawMonitors
NewerClient.png FinishChat
NewerClient.png ForceDermaSkin
NewerClient.png GetMotionBlurValues
NewerClient.png GetTeamColor
NewerClient.png GetTeamNumColor
NewerClient.png GetTeamScoreInfo
NewerClient.png GetVehicles
NewerClient.png GUIMouseDoublePressed
NewerClient.png GUIMousePressed
NewerClient.png GUIMouseReleased
NewerClient.png HUDAmmoPickedUp
NewerClient.png HUDDrawPickupHistory
NewerClient.png HUDDrawScoreBoard
NewerClient.png HUDDrawTargetID
NewerClient.png HUDItemPickedUp
NewerClient.png HUDPaint
NewerClient.png HUDPaintBackground
NewerClient.png HUDShouldDraw
NewerClient.png HUDWeaponPickedUp
NewerClient.png InputMouseApply
NewerClient.png OnAchievementAchieved
NewerClient.png OnChatTab
NewerClient.png OnContextMenuClose
NewerClient.png OnContextMenuOpen
NewerClient.png OnPlayerChat
NewerClient.png OnSpawnMenuClose
NewerClient.png OnSpawnMenuOpen
NewerClient.png PlayerBindPress
NewerClient.png PlayerEndVoice
NewerClient.png PlayerStartVoice
NewerClient.png PopulateToolMenu
NewerClient.png PostDrawEffects
NewerClient.png PostDrawHUD
NewerClient.png PostDrawOpaqueRenderables
NewerClient.png PostDrawSkyBox
NewerClient.png PostDrawTranslucentRenderables
NewerClient.png PostDrawViewModel
NewerClient.png PostPlayerDraw
NewerClient.png PostProcessPermitted
NewerClient.png PostReloadToolsMenu
NewerClient.png PostRenderVGUI
NewerClient.png PreDrawEffects
NewerClient.png PreDrawHUD
NewerClient.png PreDrawOpaqueRenderables
NewerClient.png PreDrawSkyBox
NewerClient.png PreDrawTranslucentRenderables
NewerClient.png PreDrawViewModel
NewerClient.png PrePlayerDraw
NewerClient.png PreReloadToolsMenu
NewerClient.png RenderScene
NewerClient.png RenderScreenspaceEffects
NewerClient.png ScoreboardHide
NewerClient.png ScoreboardShow
NewerClient.png ShouldDrawLocalPlayer
NewerClient.png StartChat
NewerClient.png SuppressHint
NewerClient.png VGUIMousePressed



Sandbox Hooks

These hooks only work in the Sandbox gamemode and it's derivations.

Server

NewerServer.png CanTool
NewerServer.png PlayerGiveSWEP
NewerServer.png PlayerSpawnedEffect
NewerServer.png PlayerSpawnedNPC
NewerServer.png PlayerSpawnedProp
NewerServer.png PlayerSpawnedRagdoll
NewerServer.png PlayerSpawnedSENT
NewerServer.png PlayerSpawnedVehicle
NewerServer.png PlayerSpawnEffect
NewerServer.png PlayerSpawnNPC
NewerServer.png PlayerSpawnObject
NewerServer.png PlayerSpawnProp
NewerServer.png PlayerSpawnRagdoll
NewerServer.png PlayerSpawnSENT
NewerServer.png PlayerSpawnSWEP
NewerServer.png PlayerSpawnVehicle


Client

NewerClient.png AddHint
NewerClient.png AddNotify
NewerClient.png GetSENTMenu
NewerClient.png GetSWEPMenu
NewerClient.png PaintNotes
NewerClient.png PopulateSTOOLMenu
NewerClient.png SpawnMenuEnabled




Fretta Hooks

These hooks only work in the Fretta Game Base.

Server

NewerServer.png AutoTeam
NewerServer.png CanStartRound
NewerServer.png CheckPlayerDeathRoundEnd
NewerServer.png CheckRoundEnd
NewerServer.png EndOfGame
NewerServer.png FinishGamemodeVote
NewerServer.png GetTeamAliveCounts
NewerServer.png GetWinningFraction
NewerServer.png GetWinningGamemode
NewerServer.png GetWinningMap
NewerServer.png InRound
NewerServer.png IsValidGamemode
NewerServer.png OnRoundEnd
NewerServer.png OnRoundStart
NewerServer.png PlayerJoinClass
NewerServer.png PlayerRequestClass
NewerServer.png PreRoundStart
NewerServer.png RecountVotes
NewerServer.png RoundEnd
NewerServer.png RoundEndWithResult
NewerServer.png RoundTimerEnd
NewerServer.png SetInRound
NewerServer.png SetRoundResult
NewerServer.png SetRoundWinner
NewerServer.png StartGamemodeVote
NewerServer.png StartRoundBasedGame
NewerServer.png VotePlayGamemode

Shared

NewerShared.png TeamHasEnoughPlayers

Client

NewerClient.png DrawPlayerRing
NewerClient.png PaintSplashScreen
NewerClient.png ShowClassChooser
NewerClient.png ShowGamemodeChooser
NewerClient.png ShowMapChooser
NewerClient.png ShowSplash

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox