SANDBOX/PlayerSpawnSWEP

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
(Undo revision 26326 by Markusmarkusz (talk) - Should never return true in this hook, only false)
m (Fix code style in example)
 
Line 25: Line 25:
 
{{Example
 
{{Example
 
|Description=Stops non-admins from spawning weapons.
 
|Description=Stops non-admins from spawning weapons.
|Code=hook.Add( "PlayerSpawnSWEP", "SpawnBlock", function( ply, class, info )
+
|Code=hook.Add( "PlayerSpawnSWEP", "SpawnBlockSWEP", function( ply, class, info )
if not ply:IsAdmin() then
+
if ( not ply:IsAdmin() ) then
 
return false
 
return false
 
end
 
end
 
end )
 
end )
 
}}
 
}}

Latest revision as of 20:04, 24 June 2019

 SANDBOX:PlayerSpawnSWEP( )

Contents

Description

Called when a player attempts to spawn a weapon from the Q menu. ( Mouse wheel clicks on an icon )

Arguments

Player ply

The player who attempted to spawn a weapon.

Arguments

string weapon

Class name of the weapon the player tried to spawn.

Arguments

table swep

Information about the weapon the player is trying to spawn, see SWEP structure

Returns

boolean

Can the SWEP be spawned

Examples

Example

Stops non-admins from spawning weapons.

hook.Add( "PlayerSpawnSWEP", "SpawnBlockSWEP", function( ply, class, info )
	if ( not ply:IsAdmin() ) then
		return false
	end
end )


Personal tools
Navigation