Gamemode.GetSWEPMenu

From GMod Wiki

Jump to: navigation, search
Event Hook
Hook NameGetSWEPMenu
SyntaxGM:GetSWEPMenu( )
DescriptionWhen called upon by your gamemode, should return a datatable structure containing entries referring to SWEPs that have been loaded clientside.
ReturnsTable :datatable
Lua StateNewerClient.png
BBCode[b][url=wiki.garrysmod.com/?title=Gamemode.GetSWEPMenu]Gamemode.GetSWEPMenu [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]


Examples

DescriptionThe standard implementation
Used onNewerClient.png
Code
 
 function GM:GetSWEPMenu() 
 
 	local columns = {} 
 	columns[ 1 ] = "#Name" 
 	columns[ 2 ] = "#Author" 
 	columns[ 3 ] = "#Admin" 
 
 	local ret = {} 
 
 	table.insert( ret, columns ) 
 
 	local weaponlist = weapons.GetList() 
 
 	for k,v in pairs( weaponlist ) do 
 
 		if ( v.Spawnable || v.AdminSpawnable ) then 
 
 			local entry = {} 
 			entry[ 1 ] 	= v.PrintName 
 			entry[ 2 ] 	= v.Author 
 			if ( v.AdminSpawnable && !v.Spawnable ) then entry[ 3 ]  = "ADMIN ONLY" else entry[ 3 ]  = "" end 
 			entry[ "command" ]  = "gm_giveswep "..v.Classname 
 
 			table.insert( ret, entry )		 
 
 		end 
 
 	end 
 
 	return ret 
 
 end 
 
OutputN/A


Additional Notes

See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox