So i created a custom spawn menu as follows.
[lua]
function proplist()
print ("List Opening")
local props = {}
props[1] = "models/props_junk/garbage_milkcarton002a.mdl"
props[2] = "models/props_junk/PopCan01a.mdl"
props[3] = "models/props_junk/garbage_takeoutcarton001a.mdl"
props[4] = "models/props_junk/watermelon01.mdl"
props[5] = "models/props_junk/garbage_metalcan001a.mdl"
props[6] = "models/props_lab/box01a.mdl"
props[7] = "models/props_lab/box01b.mdl"
local slframe = vgui.Create("DFrame")
local IconList = vgui.Create("DPanelList", slframe)
slframe:Center()
slframe:SetSize(250,200)
slframe:SetTitle("Prop Catalog")
slframe:MakePopup()
IconList:EnableVerticalScrollbar( true )
IconList:EnableHorizontal( true )
IconList:SetPadding( 4 )
IconList:SetPos(10,30)
IconList:SetSize(200,160)
for k,v in pairs(props) do
local icon = vgui.Create( "SpawnIcon", IconList )
icon:SetModel( v )
IconList:AddItem( icon )
icon.DoClick = function( icon ) surface.PlaySound( "ui/buttonclickrelease.wav" ) RunConsoleCommand("gm_spawn", v) end
end
end
concommand.Add("slist", proplist)
function GM:OnSpawnMenuOpen( ply )
LocalPlayer():ConCommand("slist")
end
[/lua]
This is all well and good but i'd like to be able to get {Weld, Ballsocket, Remover, Easy Weld, No collide and others} on a stool list on the side.
All help greatly appreciated. I'm making a DarkRP server non mingeable and fun eh?
DarkRP will never bee non-mingeable
Anyways Since i dont know how to do this I will look through sandbox till i find out how! Since i would actually like to know also.
Hehe Doc, i will make it non mingeable!!!
For #1 i renamed it!
Look in
sandbox\gamemode\spawnmenu
theres 3 files,
Toolmenu.lua
Toolmenubutton.lua
and
Toolpanel.lua...Its done weird but there ya go.
[lua]/*---------------------------------------------------------
Name: LoadToolsFromTable
---------------------------------------------------------*/
function PANEL:LoadToolsFromTable( inTable )
local inTable = table.Copy( inTable )
for k, v in pairs( inTable ) do
if ( type( v ) == "table" ) then
// Remove these from the table so we can
// send the rest of the table to the other
// function
local Name = v.ItemName
local Label = v.Text
v.ItemName = nil
v.Text = nil
self:AddCategory( Name, Label, v )
end
end
end
/*---------------------------------------------------------
Name: AddCategory
---------------------------------------------------------*/
function PANEL:AddCategory( Name, Label, tItems )
local Category = vgui.Create( "DCollapsibleCategory", self )
self.List:AddItem( Category )
Category:SetLabel( Label )
Category:SetCookieName( "ToolMenu."..tostring(Name) )
local CategoryContent = vgui.Create( "DPanelList" )
CategoryContent:SetAutoSize( true )
CategoryContent:SetDrawBackground( false )
CategoryContent:SetSpacing( 0 )
CategoryContent:SetPadding( 0 )
Category:SetContents( CategoryContent )
local bAlt = true
for k, v in pairs( tItems ) do
local item = vgui.Create( "ToolMenuButton", self )
item:SetText( v.Text )
item.OnSelect = function( button ) self:EnableControlPanel( button ) end
concommand.Add( Format( "tool_%s", v.ItemName ), function() item:OnSelect() end )
if ( v.SwitchConVar ) then
item:AddCheckBox( v.SwitchConVar )
end
item.ControlPanelBuildFunction = v.CPanelFunction
item.Command = v.Command
item.Name = v.ItemName
item.Controls = v.Controls
item.Text = v.Text
item:SetAlt( bAlt )
bAlt = !bAlt
CategoryContent:AddItem( item )
end
self:InvalidateLayout()
end[/lua]
How garrysmod does it..kinda stupid if you ask me.
Dont have that folder...
[editline]11:43PM[/editline]
But i just wanted a small derma scroller that would let me click them
[editline]11:45PM[/editline]
Found a copy of the files on mah server
Sorry, you need to Log In to post a reply to this thread.