Skip to content

Instantly share code, notes, and snippets.

@adamnejm
Last active March 17, 2022 01:36
Show Gist options
  • Save adamnejm/3c49c591e90ae314fb7b5ba1a93c2abf to your computer and use it in GitHub Desktop.
Save adamnejm/3c49c591e90ae314fb7b5ba1a93c2abf to your computer and use it in GitHub Desktop.
GMod - Custom Spawnmenu Tab Example
if SERVER then return end
local entries = {
{ nice_name = "Pistol", spawn_name = "weapon_pistol" },
{ nice_name = "Pulse-Rifle", spawn_name = "weapon_ar2" },
}
spawnmenu.AddCreationTab("Example", function()
local content = vgui.Create("ContentContainer")
for _, entry in ipairs(entries) do
local icon = vgui.Create("ContentIcon")
icon:SetName(entry.nice_name)
icon:SetMaterial( "entities/"..entry.spawn_name..".png" )
function icon:DoClick()
RunConsoleCommand("gm_spawnswep", entry.spawn_name)
end
content:Add(icon)
end
return content
end, "icon16/color_wheel.png")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment