print("Custom Inventory Loaded") local invxsize = 800 local invysize = 500 local bPanelWidth = invxsize * 0.25 local bPanelHeight = invysize * 0.8 local dPanelWidth = 540 local dPanelHeight = 400 local curDisplay = nil local buttons = { { txt = "Inventory", admin = false, }, { txt = "Structures", admin = false, }, { txt = "Combinations", admin = false, }, { txt = "Equipment", admin = false, }, { txt = "Props", admin = false, }, { txt = "Tools", admin = false, }, { txt = "Prop Protection", admin = false, }, { txt = "Tribes", admin = false, }, { txt = "Admin", admin = true, }, } surface.CreateFont( "gmNameFont", { font = "Century", -- Use the font-name which is shown to you by your operating system Font Viewer, not the file name size = 21, weight = 500, blursize = 0, scanlines = 0, antialias = true, underline = false, italic = false, strikeout = false, symbol = false, rotary = false, shadow = false, additive = false, outline = false, } ) surface.CreateFont( "ButtonText", { font = "Century", -- Use the font-name which is shown to you by your operating system Font Viewer, not the file name size = 25, weight = 500, blursize = 0, scanlines = 0, antialias = true, underline = false, italic = false, strikeout = false, symbol = false, rotary = false, shadow = false, additive = false, outline = false, } ) surface.CreateFont( "StructureText", { font = "Century", -- Use the font-name which is shown to you by your operating system Font Viewer, not the file name size = 14, weight = 800, blursize = 0, scanlines = 0, antialias = true, underline = false, italic = false, strikeout = false, symbol = false, rotary = false, shadow = false, additive = false, outline = false, } ) local function createTooltipTextFor(tbl) local string = "" for k,v in pairs(tbl) do string = string .. (k .. " x" .. v .. "\n") end return string end local function createPanel() local frame = vgui.Create( "InventoryFrame" ) return frame end local function createMenuFor(menu, tbl) print("Createing actions for:") PrintTable(tbl) for k,v in pairs(tbl) do if(isfunction(v)) then --This is a dead-end, add the menu local thisoption = menu:AddOption(k,v) else --Otherwise it should be a table, recursively call to create local submenu = menu:AddSubMenu(k) createMenuFor(submenu,v) end end end // Frame local PANEL = {} function PANEL:Init() self:SetSize( invxsize, invysize ) self:SetTitle( "Inventory" ) self:MakePopup() self:Center() self:SetKeyboardInputEnabled(true) self:ShowCloseButton(false) self.OnKeyCodePressed = function(self,key) if(key == KEY_Q)then self:Close() end end local buttonPanel = vgui.Create("DPanel", self) buttonPanel:SetSize( bPanelWidth, bPanelHeight ) buttonPanel:SetPos( 10, self:GetTall() * 0.1 ) buttonPanel.Paint = function() draw.RoundedBox(12,0,0,buttonPanel:GetWide(),buttonPanel:GetTall(),Color(0, 0, 0, 255)) end local displayPanel = vgui.Create("DPanel", self) displayPanel:SetSize( dPanelWidth, dPanelHeight ) displayPanel:SetPos( buttonPanel:GetWide() + 30, self:GetTall() * 0.1 ) if (curDisplay != nil) then dis = vgui.Create(curDisplay,displayPanel) dis:SetSize(dPanelWidth,dPanelHeight) else dis = vgui.Create(buttons[1]['txt'], displayPanel) dis:SetSize(dPanelWidth,dPanelHeight) end displayPanel.Paint = function() draw.RoundedBox( 0, 0, 0, displayPanel:GetWide(), displayPanel:GetTall(), Color( 255, 255, 255 ) ) end titlePanelWidth = 50 local titlePanel = vgui.Create("DPanel", buttonPanel) titlePanel:SetSize(buttonPanel:GetWide(),titlePanelWidth) titlePanel:SetPos( 0,0 ) titlePanel.Paint = function() draw.RoundedBox( 0, 0, 0, titlePanel:GetWide(), titlePanel:GetTall(), Color( 153, 0, 0) ) surface.SetFont( "gmNameFont" ) surface.SetTextColor( 0,0,0 ) surface.SetTextPos( (titlePanel:GetWide()/2) - ( surface.GetTextSize(gmod.GetGamemode().Name)/2 ), (titlePanel:GetTall()/2) - (select( 2, surface.GetTextSize( gmod.GetGamemode().Name ) )/2) ) surface.DrawText( gmod.GetGamemode().Name ) end for k,v in pairs(buttons) do if (v['admin'] and !LocalPlayer():IsAdmin()) then continue end local btn = vgui.Create("DButton", buttonPanel) btn:SetText("") btn:SetSize( buttonPanel:GetWide(), 35 ) btn:SetPos( 0, (k-1)*btn:GetTall() + ((k-1)*1) + (titlePanelWidth+10) ) btn.Paint = function() draw.RoundedBox( 0, 0, 0, btn:GetWide(), btn:GetTall(), Color( 0, 0, 102 ) ) surface.SetFont( "ButtonText" ) surface.SetTextColor( 255,255,255 ) surface.SetTextPos( (btn:GetWide()/2) - ( surface.GetTextSize(v['txt'])/2 ), (btn:GetTall()/2) - (select( 2, surface.GetTextSize( v['txt'] ) )/2) ) surface.DrawText( v['txt'] ) end btn.DoClick = function() displayPanel:Clear() local d = vgui.Create( v['txt'], displayPanel ) d:SetSize( dPanelWidth, dPanelHeight ) curDisplay = v['txt'] end end end function PANEL:Paint() draw.RoundedBox( 0, 0, 0, self:GetWide(), self:GetTall(), Color( 0, 0, 0, 250 ) ) end vgui.Register( "InventoryFrame", PANEL, "DFrame" ) // Inventory local PANEL = {} function PANEL:Init() local dpnl = vgui.Create( "DScrollPanel", self ) dpnl:SetSize( dPanelWidth, dPanelHeight ) dpnl:SetPos( 0, 0 ) local col = 0 local row = 0 i = 0 for k,v in SortedPairs(Resources) do if (v == 0) then continue end local slot = vgui.Create("DButton", dpnl) slot:SetSize(dPanelWidth/5, 100) slot:SetText("") slot.Paint = function() draw.RoundedBox( 0, 1, 1, slot:GetWide()-2, slot:GetTall()-2, Color( 250, 250, 250, 250 ) ) draw.RoundedBox( 8, 4, 4, slot:GetWide()-8, slot:GetTall()-8, Color( 0, 0, 0, 250 ) ) surface.SetFont( "ButtonText" ) surface.SetTextColor( 255,255,255 ) surface.SetTextPos( (slot:GetWide()/2) - ( surface.GetTextSize("x"..v)/2 ), (slot:GetTall()/2) + select( 2, surface.GetTextSize( "x"..v ) ) - 5 ) surface.DrawText( "x"..v ) end local img = vgui.Create("DImage", slot) img:SetPos(20, 10) img:SetSize(slot:GetWide()-40, slot:GetTall()-40) if(GMS.Resources[k] == nil) then --This resource is not registered! img:SetImage("vgui/avatar_default") print("Resource:" .. k .. " not registed! This might be a bug!") continue elseif(GMS.Resources[k].Icon == nil) then img:SetImage("vgui/avatar_default") print("Resource:" .. k .. " does not have an .Icon field! This might be a bug!") continue else img:SetImage(GMS.Resources[k].Icon) slot:SetTooltip(k.."\n"..GMS.Resources[k].Description) end slot.DoClick = function() local menu = vgui.Create("DMenu") createMenuFor(menu,GMS.Resources[k].Actions) menu:Open() end if (i % 5 != 0 ) then slot:SetPos(row*dPanelWidth/5, (col-1)*100 + 25) row=row+1 else row=0 col=col+1 slot:SetPos(row*dPanelWidth/5, (col-1)*100 + 25) row=row+1 end i=i+1 end end function PANEL:Paint() resAmount = 0 for k,v in pairs(Resources) do resAmount = resAmount+v end draw.RoundedBox(0,0,0,self:GetWide(), self:GetTall(), Color(48,48,48,125)) draw.RoundedBox(0,0,0,self:GetWide(),25,Color(0,0,0,250)) draw.SimpleText( "Total: " .. resAmount .. "/" .. 25 + ( GetSkill( "Survival" ) * 5 ), "ButtonText", 0, 0, Color(255,255,255) ) end vgui.Register( "Inventory", PANEL, "DPanel" ) // Structures local PANEL = {} function PANEL:Init() local dpnl = vgui.Create( "DScrollPanel", self ) dpnl:SetSize( dPanelWidth, dPanelHeight ) dpnl:SetPos( 0, 0 ) dpnl:SetVerticalScrollbarEnabled(true) local col = 0 local row = 0 i = 0 for k,v in SortedPairs(GMS.Combinations["Structures"]) do local slot = vgui.Create("DButton", dpnl) slot:SetSize(dPanelWidth/5, 100) slot:SetText("") local modelPanel = vgui.Create( "DModelPanel", slot ) modelPanel:SetFont("StructureText") modelPanel:SetText(v.Name) modelPanel:SetSize( slot:GetWide(), slot:GetTall() ) modelPanel:SetModel( v.BuildSiteModel ) modelPanel:SetCamPos( Vector( 50,50,50 ) ) modelPanel:SetLookAt( Vector( 0, 0, 20 ) ) modelPanel.DoClick = function() LocalPlayer():ConCommand("gms_MakeCombination Structures " .. k ) end if (i % 5 != 0 ) then slot:SetPos(row*dPanelWidth/5, (col-1)*100) row=row+1 else row=0 col=col+1 slot:SetPos(row*dPanelWidth/5, (col-1)*100) row=row+1 end i=i+1 end end function PANEL:Paint() draw.RoundedBox(0,0,0,self:GetWide(), self:GetTall(), Color(48,48,48,125)) end vgui.Register( "Structures", PANEL, "DPanel" ) // Combinations local PANEL = {} function PANEL:Init() local dpnl = vgui.Create( "DScrollPanel", self ) dpnl:SetSize( dPanelWidth, dPanelHeight ) dpnl:SetPos( 0, 0 ) local col = 0 local row = 0 i = 0 for k,v in SortedPairs(GMS.Combinations["Combinations"]) do local slot = vgui.Create("DButton", dpnl) slot:SetSize(dPanelWidth/5, 100) slot:SetText("") slot:SetTooltip(createTooltipTextFor(v.Req)) slot.DoClick = function() --print("I want to combine a " .. v.Name) LocalPlayer():ConCommand("gms_MakeCombination Combinations " .. v.Name) end if (i % 5 != 0 ) then slot:SetPos(row*dPanelWidth/5, (col-1)*100) row=row+1 else row=0 col=col+1 slot:SetPos(row*dPanelWidth/5, (col-1)*100) row=row+1 end slot.Paint = function() draw.RoundedBox( 0, 1, 1, slot:GetWide()-2, slot:GetTall()-2, Color( 250, 250, 250, 250 ) ) draw.RoundedBox( 8, 4, 4, slot:GetWide()-8, slot:GetTall()-8, Color( 0, 0, 0, 250 ) ) surface.SetFont( "ButtonText" ) surface.SetTextColor( 255,255,255 ) surface.SetTextPos( (slot:GetWide()/2) - ( surface.GetTextSize(k)/2 ), (slot:GetTall()/2) + (select( 2, surface.GetTextSize( k ) )-5) ) surface.DrawText( v.Name ) end local img = vgui.Create("DImage", slot) img:SetPos(20, 10) img:SetSize(slot:GetWide()-40, slot:GetTall()-40) // for some reason has stone twice? v for j,k in SortedPairs(v.Results) do if (j != "Stone") then if(GMS.Resources[j] == nil) then --This resource is not registered! img:SetImage("vgui/avatar_default") print("Resource:" .. j .. " not registed! This might be a bug!") continue elseif(GMS.Resources[j].Icon == nil) then img:SetImage("vgui/avatar_default") print("Resource:" .. j .. " does not have an .Icon field! This might be a bug!") continue else img:SetImage(GMS.Resources[j].Icon) end end end i=i+1 end end function PANEL:Paint() draw.RoundedBox(0,0,0,self:GetWide(), self:GetTall(), Color(48,48,48,125)) end vgui.Register( "Combinations", PANEL, "DPanel" ) // Equipment local PANEL = {} function PANEL:Init() end function PANEL:Paint() draw.RoundedBox(0,0,0,self:GetWide(), self:GetTall(), Color(48,48,48,125)) end vgui.Register( "Equipment", PANEL, "DPanel" ) // Props local PANEL = {} function PANEL:Init() local dpnl = vgui.Create( "DScrollPanel", self ) dpnl:SetSize( 540, 400 ) dpnl:SetPos( 0, 0 ) local layout = vgui.Create( "DListLayout", dpnl) layout:SetSize(dpnl:GetWide(), dpnl:GetTall()) local labelnum = 0 for k,v in pairs(GMS_SpawnLists) do local DCollapsible = vgui.Create( "DCollapsibleCategory" ) DCollapsible:SetLabel(k) DCollapsible:SetSize(dpnl:GetWide(),200) DCollapsible:SetPadding(5) --DCollapsible:SetPos(0,labelnum) DCollapsible:SetExpanded( 0 ) layout:Add(DCollapsible) labelnum = labelnum + 20 local propgrid = vgui.Create("DTileLayout", DCollapsible) propgrid:SetBaseSize( 64 ) -- Tile size propgrid:Dock( FILL ) propgrid:MakeDroppable( "unique_name" ) -- Allows us to rearrange children DCollapsible:SetContents(propgrid) for i,j in pairs(v) do local itm = vgui.Create("DModelPanel", propgrid) itm:SetCamPos( Vector( 50,50,50 ) ) itm:SetLookAt( Vector( 0, 0, 20 ) ) itm:SetModel(j) itm:SetSize( 64, 64 ) itm.DoClick = function() RunConsoleCommand( "gm_spawn", j, 0 ) end propgrid:Add(itm) end --layout:Add(combipanel) end end function PANEL:Paint() draw.RoundedBox(0,0,0,self:GetWide(), self:GetTall(), Color(48,48,48,125)) end vgui.Register( "Props", PANEL, "DPanel" ) // Tools local PANEL = {} function PANEL:Init() self.ActiveTool = "Weld" self.pnl = vgui.Create("DPanel", self) self.pnl:SetSize(dPanelWidth/3, dPanelHeight) self.Tools = vgui.Create( "DListLayout", self.pnl ) self.Tools:SetPos(8,8) self.Tools:SetSize(self.pnl:GetWide()-16, self:GetTall()-16) self.Encapsulate = vgui.Create("DScrollPanel",self) self.Encapsulate:SetSize((dPanelWidth*2)/3,dPanelHeight) self.Encapsulate:SetPos(dPanelWidth/3,0) self.ControlPanel = vgui.Create("DForm",self.Encapsulate) self.ControlPanel:SetSize((dPanelWidth*2)/3,dPanelHeight) self.ControlPanel:SetPos(0,0) self.PanelProxy = {} self.PanelProxy.cp = self.ControlPanel self.PanelProxy.MatSelect = function(self,cmd,matlist,bool,x,y) print("MatSelect's cmd is:") print(cmd) local grid = vgui.Create( "DGrid" ) grid:SetPos( 0, 0 ) grid:SetCols( 5 ) grid:SetColWide( 64 ) grid:SetRowHeight( 64 ) local MatSelectPanel = {} MatSelectPanel.AddMaterial = function(name, path) print("Adding material:") PrintTable(name) end if(matlist != nil) then for k,v in pairs(matlist) do local vitem = vgui.Create("DButton") vitem:SetText("") vitem:SetSize(64,64) --print("Adding item for:" .. v) vitem:SetImage(v) vitem.DoClick = function() print("Running " .. cmd .. " " .. v) RunConsoleCommand(cmd, v) end vitem.Paint = function(self,w,h) if(self:IsDown()) then surface.DrawRect( 0, 0, w, h ) end end grid:AddItem(vitem) end end self.cp:AddItem(grid) return MatSelectPanel end self.PanelProxy.ClearControls = function() self.PanelProxy.cp:Clear() end self.PanelProxy.AddItem = function(self,item) print("----------AddItem called!--------------") print("Adding:") print(item) local output = self.cp:AddItem(item) print("-----------AddItem finished!-----------") return output end self.PanelProxy.AddControl = function(self,type,table) print("Adding control...") print("Type:" .. type) if(type == "Header") then self.cp:ControlHelp(table.Description) elseif(type == "Slider") then return self.cp:NumSlider(table.Label,table.Command,table.Min,table.Max,0) elseif(type == "Checkbox") then self.cp:CheckBox(table.Label,table.Command) elseif(type == "RopeMaterial") then --TODO:Do this or something I guess elseif(type == "Numpad") then local binder = vgui.Create( "DBinder") function binder:SetSelectedNumber( num ) self.m_iSelectedNumber = num end self.cp:AddItem(binder) elseif(type == "Color") then local color = vgui.Create( "DRGBPicker" ) local color_cube = vgui.Create( "DColorCube" ) local colorvars = {} local curcolor = {} for k,v in pairs({"Red","Green","Blue"}) do colorvars[v] = table[v] end curcolor.r = GetConVar(colorvars["Red"]):GetInt() curcolor.g = GetConVar(colorvars["Green"]):GetInt() curcolor.b = GetConVar(colorvars["Blue"]):GetInt() print("Color convars are:") PrintTable(colorvars) color_cube:SetColor( curcolor ) color_cube:SetSize(200,200) function color:OnChange(tocolor) color_cube:SetColor( tocolor ) end function color_cube:OnUserChanged(tocolor) local t = self:GetRGB() GetConVar(colorvars["Red"]):SetInt(t.r) GetConVar(colorvars["Green"]):SetInt(t.g) GetConVar(colorvars["Blue"]):SetInt(t.b) end self.cp:AddItem(color,color_cube) elseif(type == "ComboBox") then local DComboBox = vgui.Create( "DComboBox" ) for k,v in pairs(table.Options) do DComboBox:AddChoice(k,v) end DComboBox.OnSelect = function( panel, index, value ) for k,v in pairs(table.Options[value]) do print("Setting " .. k .. " to " .. v) GetConVar(k):SetInt(v) end end self.cp:AddItem(DComboBox) elseif(type == "PropSelect") then local grid = vgui.Create( "DGrid" ) grid:SetSize(256,64) grid:SetPos( 0, 0 ) grid:SetCols( 3 ) grid:SetColWide( 128 ) grid:SetRowHeight(64) grid:SetPos( 10, 30 ) grid:SetCols( 5 ) grid:SetColWide( 36 ) for k,v in pairs(table.Models) do local icon = vgui.Create( "DModelPanel", Panel ) icon:SetSize( 64, 64 ) icon:SetSize( 32, 32 ) icon:SetModel( k ) icon:SetCamPos( Vector( 15,15,15 ) ) icon:SetLookAt( Vector( 0, 0, 1 ) ) icon.DoClick = function() GetConVar(table.ConVar):SetString(k) end grid:AddItem(icon) end self.cp:AddItem(grid) elseif(type == "Label") then self.cp:AddItem(vgui.Create("DLabel"):SetText(table.Text)) elseif(type == "Button") then self.cp:Button(table.Label,table.Command) else print("I wanted to add a control, but I haven't written it yet!") print("Type:" .. type) print("Table:") PrintTable(table) print("I am:") PrintTable(self) debug.Trace() end end if(self.ControlPanel.AddControl == nil) then print("Control panel's AddControl is nil!") end --self.ControlPanel:SetSize((dPanelWidth/3)*2,dPanelWidth) --self.ControlPanel:SetPos(dPanelWidth/3,0) --self.ControlPanel:Dock(FILL) --local g = controlpanel.Get("Axis") --print(g) --self.ControlPanel:AddItem(g) for k,v in pairs(spawnmenu.GetTools()[1]["Items"]) do for i,j in pairs(v) do if(istable(j)) then local isprohibitied = true for l,m in pairs(GMS.AllowedStools) do print("Checking: " .. j.ItemName) if(j.ItemName == m) then isprohibitied = false end end if(!isprohibitied) then local button = vgui.Create("DButton",self.Tools) local btable = {} for n,o in pairs(j) do btable[n] = o end print("Btable is:") PrintTable(btable) button:SetText(btable.Text) --button.Name = j.Text button.PanelCreate = j.CPanelFunction --self.Tools:Add print("adding " .. j.Text) button.DoClick = function() --print("Before calling function, PanelProxy is:") --PrintTable(self.PanelProxy) LocalPlayer():ConCommand(btable.Command) local cp = controlpanel.Get(btable.Text) if ( !cp:GetInitialized() ) then cp:FillViaTable( btable ) end self.ControlPanel:Clear() self.ControlPanel:AddItem(cp) button.PanelCreate(self.PanelProxy) end end end end end --PrintTable(spawnmenu.GetTools()[1]["Items"]) end function PANEL:EnableControlPanel( button ) if(self.LastSelected) then self.LastSelected:SetSelected(false) end button:SetSelected( true ) self.LastSelected = button print(button.Name) local cp = controlpanel.Get( button.Name ) print("got control panel for:") print(cp) --if ( !cp:GetInitialized() ) then --cp:FillViaTable( button ) --end self.ControlPanel:Clear() self.ControlPanel:AddItem( cp ) self.ControlPanel:Rebuild() --[[ if ( button.Command ) then LocalPlayer():ConCommand( button.Command ) end ]] end function PANEL:Paint() draw.RoundedBox(0,0,0,self:GetWide(), self:GetTall(), Color(48,48,48,125)) end vgui.Register( "Tools", PANEL, "DPanel" ) /* Prop Protection */ local PANEL = {} PANEL.LastThink = CurTime() PANEL.Settings = { { text = "Enable Prop Protection", elem = "DCheckBoxLabel", cmd = "spp_enabled" }, { text = "Enable use key protection", elem = "DCheckBoxLabel", cmd = "spp_use" }, { text = "Enable entity damage protection", elem = "DCheckBoxLabel", cmd = "spp_entdmg" }, { text = "", elem = "DLabel" }, { text = "Admins can touch other player props", elem = "DCheckBoxLabel", cmd = "spp_admin" }, { text = "Admins can touch world props", elem = "DCheckBoxLabel", cmd = "spp_admin_wp" }, { text = "", elem = "DLabel" }, { text = "Delete disconnected admins entities", elem = "DCheckBoxLabel", cmd = "spp_del_adminprops" }, { text = "Delete disconnected players entities", elem = "DCheckBoxLabel", cmd = "spp_del_disconnected" }, { text = "Deletion delay in seconds", elem = "DNumSlider", cmd = "spp_del_delay", min = 10, max = 600 }, } function PANEL:Init() if ( !LocalPlayer():IsAdmin() ) then self.Settings = { { text = "You are not an admin.", elem = "DLabel" } } end self.Buddies = vgui.Create( "DPanelList", self ) self.Buddies:EnableVerticalScrollbar( true ) self.Buddies:SetSpacing( 5 ) self.Buddies:SetPadding( 5 ) function self.Buddies:Paint() draw.RoundedBox( 4, 0, 0, self:GetWide(), self:GetTall(), Color( 75, 75, 75 ) ) end self.AdminSettings = vgui.Create( "DPanelList", self ) self.AdminSettings:EnableVerticalScrollbar( true ) self.AdminSettings:SetSpacing( 5 ) self.AdminSettings:SetPadding( 5 ) function self.AdminSettings:Paint() draw.RoundedBox( 4, 0, 0, self:GetWide(), self:GetTall(), Color( 75, 75, 75 ) ) end self.AdminCleanUp = vgui.Create( "DPanelList", self ) self.AdminCleanUp:EnableVerticalScrollbar( true ) self.AdminCleanUp:SetSpacing( 5 ) self.AdminCleanUp:SetPadding( 5 ) function self.AdminCleanUp:Paint() draw.RoundedBox( 4, 0, 0, self:GetWide(), self:GetTall(), Color( 75, 75, 75 ) ) end /* Admin settings */ for txt, t in pairs( self.Settings ) do local item = vgui.Create( t.elem ) item:SetText( t.text ) if ( t.elem != "DLabel" ) then item:SetConVar( t.cmd ) end if ( t.elem == "DNumSlider" ) then item:SetMin( t.min ) item:SetMax( t.max ) item:SetDecimals( 0 ) item.TextArea:SetTextColor( Color( 200, 200, 200 ) ) end self.AdminSettings:AddItem( item ) end /* Admin cleanup */ for i, p in pairs( player.GetAll() ) do local item = vgui.Create( "DButton" ) item:SetConsoleCommand( "spp_cleanup_props", p:GetNWString( "SPPSteamID" ) ) item:SetText( p:Name() ) item:SetTall( 26 ) self.AdminCleanUp:AddItem( item ) end local item = vgui.Create( "DButton" ) item:SetConsoleCommand( "spp_cleanup_props_left" ) item:SetText( "Cleanup disconnected players props" ) item:SetTall( 26 ) self.AdminCleanUp:AddItem( item ) /* Client */ for i, p in pairs( player.GetAll() ) do if ( p != LocalPlayer() ) then local item = vgui.Create( "DCheckBoxLabel" ) local BCommand = "spp_buddy_" .. p:GetNWString( "SPPSteamID" ) if ( !LocalPlayer():GetInfo( BCommand ) ) then CreateClientConVar( BCommand, 0, false, true ) end item:SetConVar( BCommand ) item:SetText( p:Name() ) item:SetTextColor( Color( 255, 255, 255, 255 ) ) self.Buddies:AddItem( item ) end end local item = vgui.Create( "DButton" ) item:SetConsoleCommand( "spp_apply_buddies" ) item:SetText( "Apply settings" ) item:SetTall( 26 ) self.Buddies:AddItem( item ) local item = vgui.Create( "DButton" ) item:SetConsoleCommand( "spp_clear_buddies" ) item:SetText( "Clear all buddies" ) item:SetTall( 26 ) self.Buddies:AddItem( item ) end function PANEL:Paint() draw.RoundedBox(0,0,0,self:GetWide(), self:GetTall(), Color(48,48,48,125)) end function PANEL:Think() if ( CurTime() >= self.LastThink + 3 )then self.LastThink = CurTime() self.AdminCleanUp:Clear( true ) self.Buddies:Clear( true ) /* Admin cleanup */ if ( LocalPlayer():IsAdmin() ) then for i, p in pairs( player.GetAll() ) do local item = vgui.Create( "DButton" ) item:SetConsoleCommand( "spp_cleanup_props", p:GetNWString( "SPPSteamID" ) ) item:SetTall( 26 ) item:SetText( p:Name() ) self.AdminCleanUp:AddItem( item ) end local item = vgui.Create( "DButton" ) item:SetConsoleCommand( "spp_cleanup_props_left" ) item:SetTall( 26 ) item:SetText( "Cleanup disconnected players props" ) self.AdminCleanUp:AddItem( item ) self.AdminSettings:SetVisible( true ) self.AdminCleanUp:SetVisible( true ) else local item = vgui.Create( "DLabel" ) item:SetText( "You are not an admin." ) self.AdminCleanUp:AddItem( item ) self.AdminSettings:SetVisible( false ) self.AdminCleanUp:SetVisible( false ) end /* Client */ for i, p in pairs( player.GetAll() ) do if ( p != LocalPlayer() ) then local item = vgui.Create( "DCheckBoxLabel" ) local BCommand = "spp_buddy_" .. p:GetNWString( "SPPSteamID" ) if ( !LocalPlayer():GetInfo( BCommand ) ) then CreateClientConVar( BCommand, 0, false, true ) end item:SetConVar( BCommand ) item:SetText( p:Name() ) self.Buddies:AddItem( item ) end end local item = vgui.Create( "DButton" ) item:SetConsoleCommand( "spp_apply_buddies" ) item:SetText( "Apply settings" ) item:SetTall( 26 ) self.Buddies:AddItem( item ) local item = vgui.Create( "DButton" ) item:SetConsoleCommand( "spp_clear_buddies" ) item:SetText( "Clear all buddies" ) item:SetTall( 26 ) self.Buddies:AddItem( item ) end end function PANEL:PerformLayout() self:StretchToParent( 0, 21, 0, 5 ) self.Buddies:SetPos( 5, 5 ) self.Buddies:SetSize( self:GetWide() * 0.45, self:GetTall() - 5 ) self.AdminSettings:SetPos( self:GetWide() * 0.45 + 10, 5 ) self.AdminSettings:SetSize( self:GetWide() - ( self:GetWide() * 0.45 ) - 14, self:GetTall() / 2 - 5 ) self.AdminCleanUp:SetPos( self:GetWide() * 0.45 + 10, self:GetTall() / 2 + 5 ) self.AdminCleanUp:SetSize( self:GetWide() - ( self:GetWide() * 0.45 ) - 14, self:GetTall() / 2 - 5 ) end vgui.Register( "Prop Protection", PANEL, "DPanel" ) /* Admin */ local PANEL = {} PANEL.SpawningCmds = { { text = "Spawn tree", cmd = "gms_admin_maketree" }, { text = "Spawn rock", cmd = "gms_admin_makerock" }, { text = "Spawn food", cmd = "gms_admin_makefood" }, { text = "Save all characters", cmd = "gms_admin_saveallcharacters" }, { text = "Plant random plant", cmd = "gms_admin_makeplant" }, { text = "Plant melons", cmd = "gms_admin_makeplant 1" }, { text = "Plant banana tree", cmd = "gms_admin_makeplant 2" }, { text = "Plant oranges", cmd = "gms_admin_makeplant 3" }, { text = "Plant berry bush", cmd = "gms_admin_makeplant 4" }, { text = "Plant grain", cmd = "gms_admin_makeplant 5" } } PANEL.Settings = { { text = "Force players to use Tribe color", elem = "DCheckBoxLabel", cmd = "gms_TeamColors" }, { text = "Allow players to damage each other with tools", elem = "DCheckBoxLabel", cmd = "gms_PVPDamage" }, { text = "Enable free build for everyone", elem = "DCheckBoxLabel", cmd = "gms_FreeBuild" }, { text = "Enable free build for super admins", elem = "DCheckBoxLabel", cmd = "gms_FreeBuildSa" }, { text = "Give all players all tools", elem = "DCheckBoxLabel", cmd = "gms_AllTools" }, //{ text = "Enable low needs alerts ( coughing, etc )", elem = "DCheckBoxLabel", cmd = "gms_alerts" }, { text = "Spread fire", elem = "DCheckBoxLabel", cmd = "gms_SpreadFire" }, { text = "Fadeout rocks, just like trees", elem = "DCheckBoxLabel", cmd = "gms_FadeRocks" }, { text = "Enable campfires", elem = "DCheckBoxLabel", cmd = "gms_campfire" }, { text = "Spawn zombies at night", elem = "DCheckBoxLabel", cmd = "gms_zombies" }, { text = "Enable day/night cycle", elem = "DCheckBoxLabel", cmd = "gms_daynight" }, //{ text = "Costs scale", elem = "DNumSlider", decimals = 1, cmd = "gms_CostsScale", min = 1, max = 4 }, { text = "Plant limit per player", elem = "DNumSlider", cmd = "gms_PlantLimit", min = 10, max = 35 }, { text = "", elem = "DLabel" }, { text = "Reproduce trees", elem = "DCheckBoxLabel", cmd = "gms_ReproduceTrees" }, { text = "Max reproduced trees", elem = "DNumSlider", cmd = "gms_MaxReproducedTrees", min = 1, max = 60 }, { text = "", elem = "DLabel" }, { text = "Autosave user profiles", elem = "DCheckBoxLabel", cmd = "gms_AutoSave" }, { text = "Autosave delay ( minutes )", elem = "DNumSlider", cmd = "gms_AutoSaveTime", min = 1, max = 30 }, } function PANEL:Init() self.MapSaving = vgui.Create( "DPanelList", self ) self.MapSaving:EnableVerticalScrollbar( true ) self.MapSaving:SetSpacing( 5 ) self.MapSaving:SetPadding( 5 ) function self.MapSaving:Paint() draw.RoundedBox( 4, 0, 0, self:GetWide(), self:GetTall(), Color( 75, 75, 75 ) ) end self.Populating = vgui.Create( "DPanelList", self ) self.Populating:EnableVerticalScrollbar( true ) self.Populating:SetSpacing( 5 ) self.Populating:SetPadding( 5 ) function self.Populating:Paint() draw.RoundedBox( 4, 0, 0, self:GetWide(), self:GetTall(), Color( 75, 75, 75 ) ) end self.AdminSettings = vgui.Create( "DPanelList", self ) self.AdminSettings:EnableVerticalScrollbar( true ) self.AdminSettings:SetSpacing( 5 ) self.AdminSettings:SetPadding( 5 ) function self.AdminSettings:Paint() draw.RoundedBox( 4, 0, 0, self:GetWide(), self:GetTall(), Color( 75, 75, 75 ) ) end self.Spawning = vgui.Create( "DPanelList", self ) self.Spawning:EnableVerticalScrollbar( true ) self.Spawning:SetSpacing( 5 ) self.Spawning:SetPadding( 5 ) function self.Spawning:Paint() draw.RoundedBox( 4, 0, 0, self:GetWide(), self:GetTall(), Color( 75, 75, 75 ) ) end for txt, t in pairs( self.Settings ) do local item = vgui.Create( t.elem ) item:SetText( t.text ) if ( t.elem == "DNumSlider" ) then item:SetMin( t.min ) item:SetMax( t.max ) item:SetDecimals( t.decimals or 0 ) item.TextArea:SetTextColor( Color( 200, 200, 200 ) ) end if ( t.elem != "DLabel" ) then item:SetConVar( t.cmd ) end self.AdminSettings:AddItem( item ) end for txt, t in pairs( self.SpawningCmds ) do local item = vgui.Create( "DButton" ) item:SetText( t.text ) item:SetTall( 26 ) item:SetConsoleCommand( t.cmd ) self.Spawning:AddItem( item ) end // POPULATE AREA local populatearea = vgui.Create( "DPanel", self ) populatearea:SetTall( 100 ) local label = vgui.Create( "DLabel", populatearea ) label:SetPos( 10, 5 ) label:SetDark( true ) label:SetText( "Amount" ) label:SizeToContents() self.PopulateAmount = vgui.Create( "DTextEntry", populatearea ) self.PopulateAmount:SetPos( 10, 20 ) self.PopulateAmount:SetTall( 24 ) self.PopulateAmount:SetValue( "10" ) populatearea.PopulateAmount = self.PopulateAmount local label = vgui.Create( "DLabel", populatearea ) label:SetDark( true ) label:SetText( "Max radius" ) label:SizeToContents() self.PopulateRadius = vgui.Create( "DTextEntry", populatearea ) self.PopulateRadius:SetValue( "1000" ) self.PopulateRadius:SetTall( 24 ) self.PopulateRadius.Label = label populatearea.PopulateRadius = self.PopulateRadius local label = vgui.Create( "DLabel", populatearea ) label:SetPos( 10, 49 ) label:SetDark( true ) label:SetText( "Type" ) label:SizeToContents() local typ = "Trees" self.PopulateType = vgui.Create( "DComboBox", populatearea ) self.PopulateType:SetTall( 24 ) self.PopulateType:SetPos( 10, 64 ) self.PopulateType:AddChoice( "Trees", "Trees" ) self.PopulateType:AddChoice( "Rocks", "Rocks" ) self.PopulateType:AddChoice( "Random plants", "Random_Plant" ) self.PopulateType:ChooseOptionID( 1 ) function self.PopulateType:OnSelect( index, value, data ) typ = data end self.PopulateArea = vgui.Create( "gms_CommandButton", populatearea ) self.PopulateArea:SetTall( 24 ) self.PopulateArea:SetText( "Populate Area" ) function self.PopulateArea:DoClick() local p = self:GetParent() RunConsoleCommand( "gms_admin_PopulateArea", typ, string.Trim( p.PopulateAmount:GetValue() ), string.Trim( p.PopulateRadius:GetValue() ) ) end self.Populating:AddItem( populatearea ) // POPULATE AREA: Antlions local populatearea = vgui.Create( "DPanel", self ) populatearea:SetTall( 54 ) local label = vgui.Create( "DLabel", populatearea ) label:SetPos( 10, 5 ) label:SetDark( true ) label:SetText( "Amount" ) label:SizeToContents() self.PopulateAmountAnt = vgui.Create( "DTextEntry", populatearea ) self.PopulateAmountAnt:SetPos( 10, 20 ) self.PopulateAmountAnt:SetTall( 24 ) self.PopulateAmountAnt:SetValue( "5" ) populatearea.PopulateAmountAnt = self.PopulateAmountAnt self.PopulateAreaAnt = vgui.Create( "gms_CommandButton", populatearea ) self.PopulateAreaAnt:SetTall( 24 ) self.PopulateAreaAnt:SetText( "Make Antlion Barrow" ) function self.PopulateAreaAnt:DoClick() RunConsoleCommand( "gms_admin_MakeAntlionBarrow", string.Trim( self:GetParent().PopulateAmountAnt:GetValue() ) ) end self.Populating:AddItem( populatearea ) // Save map local populatearea = vgui.Create( "DPanel", self ) populatearea:SetTall( 64 ) self.MapName = vgui.Create( "DTextEntry", populatearea ) self.MapName:SetPos( 5, 5 ) self.MapName:SetTall( 24 ) self.MapName:SetValue( "savename" ) populatearea.MapName = self.MapName self.SaveMap = vgui.Create( "gms_CommandButton", populatearea ) self.SaveMap:SetPos( 5, 34 ) self.SaveMap:SetTall( 24 ) self.SaveMap:SetText( "Save" ) function self.SaveMap:DoClick() RunConsoleCommand( "gms_admin_savemap", string.Trim( self:GetParent().MapName:GetValue() ) ) end self.MapSaving:AddItem( populatearea ) // Load/delete map local populatearea = vgui.Create( "DPanel", self ) populatearea:SetTall( 64 ) local map = "" self.MapNameL = vgui.Create( "DComboBox", populatearea ) self.MapNameL:SetTall( 24 ) self.MapNameL:SetPos( 5, 5 ) function self.MapNameL:OnSelect( index, value, data ) map = data end populatearea.MapNameL = self.MapNameL self.LoadMap = vgui.Create( "gms_CommandButton", populatearea ) self.LoadMap:SetPos( 5, 34 ) self.LoadMap:SetTall( 24 ) self.LoadMap:SetText( "Load" ) function self.LoadMap:DoClick() RunConsoleCommand( "gms_admin_loadmap", string.Trim( map ) ) end self.DeleteMap = vgui.Create( "gms_CommandButton", populatearea ) self.DeleteMap:SetTall( 24 ) self.DeleteMap:SetText( "Delete" ) function self.DeleteMap:DoClick() RunConsoleCommand( "gms_admin_deletemap", map ) end self.MapSaving:AddItem( populatearea ) end function PANEL:Paint() draw.RoundedBox(0,0,0,self:GetWide(), self:GetTall(), Color(48,48,48,125)) end function PANEL:PerformLayout() self:StretchToParent( 0, 21, 0, 5 ) self.MapSaving:SetPos( 5, 5 ) self.MapSaving:SetSize( self:GetWide() * 0.45, self:GetTall() / 2 - 5 ) self.Populating:SetPos( 5, self:GetTall() / 2 + 5 ) self.Populating:SetSize( self:GetWide() - ( self:GetWide() * 0.45 ) - 14, self:GetTall() / 2 - 5 ) self.AdminSettings:SetPos( self:GetWide() * 0.45 + 10, 5 ) self.AdminSettings:SetSize( self:GetWide() - ( self:GetWide() * 0.45 ) - 14, self:GetTall() / 2 - 5 ) self.Spawning:SetPos( self:GetWide() - ( self:GetWide() * 0.45 ) - 4, self:GetTall() / 2 + 5 ) self.Spawning:SetSize( self:GetWide() * 0.45, self:GetTall() / 2 - 5 ) /* POPULATION */ self.PopulateAmount:SetWide( self.Populating:GetWide() / 2 - 20 ) self.PopulateRadius:SetWide( self.Populating:GetWide() / 2 - 20 ) self.PopulateRadius.Label:SetPos( self.Populating:GetWide() / 2, 5 ) self.PopulateRadius:SetPos( self.Populating:GetWide() / 2, 20 ) self.PopulateType:SetWide( self.Populating:GetWide() / 2 - 20 ) self.PopulateArea:SetWide( self.Populating:GetWide() / 2 - 20 ) self.PopulateArea:SetPos( self.Populating:GetWide() / 2, 64 ) /* ANTLIONS */ self.PopulateAmountAnt:SetWide( self.Populating:GetWide() / 2 - 20 ) self.PopulateAreaAnt:SetWide( self.Populating:GetWide() / 2 - 20 ) self.PopulateAreaAnt:SetPos( self.Populating:GetWide() / 2, 20 ) // Save map self.MapName:SetWide( self.MapSaving:GetWide() - 20 ) self.SaveMap:SetWide( self.MapSaving:GetWide() - 20 ) // Load/delete map self.MapNameL:SetSize( self.MapSaving:GetWide() - 20, 24 ) self.LoadMap:SetWide( self.MapSaving:GetWide() / 2 - 20 ) self.DeleteMap:SetWide( self.MapSaving:GetWide() / 2 - 20 ) self.DeleteMap:SetPos( self.MapSaving:GetWide() / 2 + 5, 34 ) end vgui.Register( "Admin", PANEL, "DPanel" ) //Tribes local PANEL = {} function PANEL:Init() local dpnl = vgui.Create( "DScrollPanel", self ) dpnl:SetSize( dPanelWidth, dPanelHeight ) dpnl:SetPos( 0, 0 ) local grid = vgui.Create("DGrid",dpnl) grid:Dock(FILL) local sizelen = 135 grid:SetColWide( sizelen ) grid:SetRowHeight( sizelen ) for k,v in pairs(Tribes) do local tribeb = vgui.Create("DButton") tribeb:SetText(v.name) tribeb:SetSize(sizelen,sizelen) tribeb.DoClick = function(self) if(v.pass) then Derma_StringRequest( "Please enter password", "Please enter password for the tribe.", "", function( text ) RunConsoleCommand( "gms_join", v.name, text ) end ) else RunConsoleCommand("gms_join", v.name,"") end end tribeb.Paint = function(self,w,h) surface.SetDrawColor(255,255,255) surface.DrawRect(0,0,self:GetWide(),self:GetTall()) surface.SetDrawColor(v.color) surface.DrawRect(8,8,self:GetWide()-16,self:GetTall()-16) surface.SetDrawColor(Color(255,255,255,255)) surface.DrawRect(20,(h/2)-10,self:GetWide()-40,20) end grid:AddItem(tribeb) end local newtribe = vgui.Create("DButton") newtribe:SetText("Create Tribe") newtribe:SetSize(sizelen,sizelen) newtribe.DoClick = function() local p = vgui.Create("GMS_TribeMenu") end grid:AddItem(newtribe) end function PANEL:Paint() end vgui.Register( "Tribes", PANEL, "DPanel" ) //Bind it to open on q local invpanel = nil function GM:OnSpawnMenuOpen() if(invpanel == nil) then invpanel = createPanel() return end if(! invpanel:IsValid()) then invpanel = createPanel() return end end function GM:ReloadSpawnMenu() if(invpanel == nil) then return end if(!invpanel:IsValid()) then return end if(invpanel != nil) then invpanel:Close() invpanel = createPanel() return end end function GM:OnSpawnMenuClose() end function GM:SpawnMenuEnabled() return false end