Garry's Mod Wiki

SANDBOX

This function or feature is only available in the Sandbox gamemode and its derivatives.

This is a list of hooks that are only available in Sandbox or Sandbox derived gamemodes.

Easiest way to tell if a gamemode is Sandbox derived is to check if this variable exists:

-- Replace GAMEMODE with GM if you are in gamemode files. if ( GAMEMODE.IsSandboxDerived ) then -- Do stuff end

Inherits methods from GM.

Events

This is used internally - although you're able to use it you probably shouldn't. This hook is used to add default categories to spawnmenu tool tabs. Do not override or hook this function, use SANDBOX:AddToolMenuCategories!
This is used internally - although you're able to use it you probably shouldn't. This hook is used to add default tool tabs to spawnmenu. Do not override or hook this function, use SANDBOX:AddToolMenuTabs!
This hook is used to add new categories to spawnmenu tool tabs.
SANDBOX:AddToolMenuTabs()
This hook is used to add new tool tabs to spawnmenu.
boolean SANDBOX:CanArmDupe( Player ply )
Called when a player attempts to "arm" a duplication with the Duplicator tool. Return false to prevent the player from sending data to server, and to ignore data if it was somehow sent anyway.
boolean SANDBOX:CanDrive( Player ply, Entity ent )
Called when a player attempts to drive a prop via Prop Drive
boolean SANDBOX:CanTool( Player ply, table tr, string toolname, table tool, number button )
Called when a player attempts to fire their tool gun. Return true to specifically allow the attempt, false to block it.
SANDBOX:ContentSidebarSelection( Panel parent, Panel node )
Called when player selects an item on the spawnmenu sidebar at the left.
Called when the context menu is supposedly closed. This is simply an alias of GM:OnContextMenuClose. This hook will be called even if the Sandbox's context menu doesn't actually exist, i. e. SANDBOX:ContextMenuEnabled blocked its creation.
SANDBOX:ContextMenuCreated( Panel g_ContextMenu )
Called when the context menu is created.
Allows to prevent the creation of the context menu. If the context menu is already created, this will have no effect.
Called when the context menu is trying to be opened.
Called when the context menu is supposedly opened. This is simply an alias of GM:OnContextMenuOpen but will not be called if SANDBOX:ContextMenuOpen prevents the context menu from opening. This hook will be called even if the context menu doesn't actually exist, i. e. SANDBOX:ContextMenuEnabled blocked its creation.
Called to poll if active tool settings should appear in the context menu. Please note that this is only called on initial opening of the context menu, not every frame the context menu is in use.
Called when the Client reverts spawnlist changes
SANDBOX:OnSaveSpawnlist()
Called when a player saves his changes made to the spawnmenu
SANDBOX:OpenToolbox()
This is used internally - although you're able to use it you probably shouldn't. This hook is called when the player edits a category in the Spawnmenu
SANDBOX:PaintNotes()
Called from GM:HUDPaint; does nothing by default. This cannot be used with hook. Add
SANDBOX:PaintWorldTips()
Called from GM:HUDPaint to draw world tips. By default, enabling cl_drawworldtooltips will stop world tips from being drawn here. See AddWorldTip for more information. This cannot be used with hook. Add
SANDBOX:PersistenceLoad( string name )
Called when persistent props are loaded.
SANDBOX:PersistenceSave( string name )
Called when persistent props are saved.
boolean SANDBOX:PlayerGiveSWEP( Player ply, string weapon, table swep )
Called when a player attempts to give themselves a weapon from the Q menu. ( Left mouse clicks on an icon )
SANDBOX:PlayerSpawnedEffect( Player ply, string model, Entity ent )
Called after the player spawned an effect.
SANDBOX:PlayerSpawnedNPC( Player ply, Entity ent )
Called after the player spawned an NPC.
SANDBOX:PlayerSpawnedProp( Player ply, string model, Entity entity )
Called when a player has successfully spawned a prop from the Q menu.
SANDBOX:PlayerSpawnedRagdoll( Player ply, string model, Entity ent )
Called after the player spawned a ragdoll.
SANDBOX:PlayerSpawnedSENT( Player ply, Entity ent )
Called after the player has spawned a scripted entity.
SANDBOX:PlayerSpawnedSWEP( Player ply, Entity ent )
Called after the player has spawned a scripted weapon from the spawnmenu with a middle mouse click. For left mouse click spawns, see SANDBOX:PlayerGiveSWEP.
SANDBOX:PlayerSpawnedVehicle( Player ply, Entity ent )
Called after the player spawned a vehicle.
boolean SANDBOX:PlayerSpawnEffect( Player ply, string model )
Called to ask if player allowed to spawn a particular effect or not.
boolean SANDBOX:PlayerSpawnNPC( Player ply, string npc_type, string weapon )
Called to ask if player allowed to spawn a particular NPC or not.
boolean SANDBOX:PlayerSpawnObject( Player ply, string model, number skin )
Called to ask whether player is allowed to spawn a given model. This includes props, effects, and ragdolls and is called before the respective PlayerSpawn* hook.
boolean SANDBOX:PlayerSpawnProp( Player ply, string model )
Called when a player attempts to spawn a prop from the Q menu.
boolean SANDBOX:PlayerSpawnRagdoll( Player ply, string model )
Called when a player attempts to spawn a ragdoll from the Q menu.
boolean SANDBOX:PlayerSpawnSENT( Player ply, string class )
Called when a player attempts to spawn an Entity from the Q menu.
boolean SANDBOX:PlayerSpawnSWEP( Player ply, string weapon, table swep )
Called when a player attempts to spawn a weapon from the Q menu. ( Mouse wheel clicks on an icon )
boolean SANDBOX:PlayerSpawnVehicle( Player ply, string model, string name, table table )
Called to ask if player allowed to spawn a particular vehicle or not.
SANDBOX:PopulateContent( Panel pnlContent, Panel tree, Panel node )
Called by the spawnmenu when the content tab is generated Creating an error in this Hook will result in a completely broken Content Tab
SANDBOX:PopulateEntities( Panel pnlContent, Panel tree, Panel node )
Called by the spawnmenu when the Entities tab is generated Creating an error in this Hook will result in a completely broken Entites Tab
SANDBOX:PopulateNPCs( Panel pnlContent, Panel tree, Panel node )
Called by the spawnmenu when the NPCs tab is generated Creating an error in this Hook will result in a completely broken NPCs Tab
SANDBOX:PopulatePropMenu()
This hook makes the engine load the spawnlist text files. It calls spawnmenu. PopulateFromEngineTextFiles by default.
SANDBOX:PopulateToolMenu()
Add the Scripted TOOLs to the tool menu. You want to call spawnmenu. AddToolMenuOption in this hook.
SANDBOX:PopulateVehicles( Panel pnlContent, Panel tree, Panel node )
Called by the spawnmenu when the Vehicles tab is generated Creating an error in this Hook will result in a completely broken vehicles Tab
SANDBOX:PopulateWeapons( Panel pnlContent, Panel tree, Panel node )
Called by the spawnmenu when the Weapons tab is generated Creating an error in this Hook will result in a completely broken Weapons Tab
Called right after the Lua Loaded tool menus are reloaded. This is a good place to set up any ControlPanels.
boolean SANDBOX:PreRegisterTOOL( table tool, string class )
Called just before registering a Sandbox scripted tool.
Called right before the Lua Loaded tool menus are reloaded.
Called when changes were made to the spawnmenu like creating a new category.
SANDBOX:SpawnlistOpenGenericMenu( Panel canvas )
This is used internally - although you're able to use it you probably shouldn't. Called when there's one or more items selected in the spawnmenu by the player, to open the multi selection right click menu (DMenu)
If false is returned then the spawn menu is never created. This saves load times if your mod doesn't actually use the spawn menu for any reason.
Called when spawnmenu is trying to be opened. Hiding the spawnmenu will not stop people from being able to use the various console commands to spawn in items, etc. See GM:PlayerSpawn* hooks for blocking actual spawning.
SANDBOX:SpawnMenuOpened()
Called when the spawnmenu is opened. This is an alias of GM:OnSpawnMenuOpen but will not be called if SANDBOX:SpawnMenuOpen prevents the spawnmenu from opening. This hook will be called even if the spawnmenu doesn't actually exist, i. e. SANDBOX:SpawnMenuEnabled blocked its creation.