Author Topic: I need help with the UPS Menu Add-on that I am working on. Please and Thank You.  (Read 2565 times)

0 Members and 1 Guest are viewing this topic.

Offline LuaTenshi

  • Hero Member
  • *****
  • Posts: 545
  • Karma: 47
  • Just your ordinary moon angel!
    • Mirai.Red
I have decided to make an ad-don for UPS, that allows you to target specific entity types and or models.

I am going to make additional commands that work as chat commands along with this add-on.

My first version works, but I am having trouble with this one.

Code: [Select]
module( "UPS", package.seeall )

function upsMenuOpen()

local DermaPanel = vgui.Create( "DFrame" )
DermaPanel:SetPos( 50,50 )
DermaPanel:SetSize( 250, 300 )
DermaPanel:SetTitle( "UPS Menu" )
DermaPanel:SetVisible( true )
DermaPanel:SetDraggable( true )
DermaPanel:ShowCloseButton( true )
DermaPanel:MakePopup()

-- panel:AddControl( "Label", { Text = "" } ) -- Spacing
local myLabelOne = vgui.Create("DLabel", DermaPanel)
myLabelOne:SetColor(Color(0,0,0,0)) // Color
myLabelOne:SetFont("default")
myLabelOne:SetText("Spacing") // Text
myLabelOne:SizeToContents() // make the control the same size as the text.

-- panel:AddControl( "Label", { Text = "Time until props are put up for grabs after player leaves:" } )
local myLabelTwo = vgui.Create("DLabel", DermaPanel)
myLabelTwo:SetColor(Color(255,255,255,255)) // Color
myLabelTwo:SetFont("default")
myLabelTwo:SetText("Time until props are put up for grabs after player leaves:") // Text
myLabelTwo:SizeToContents() // make the control the same size as the text.

-- panel:AddControl( "Slider",  {
-- Label = "Set to -1 to disable",
-- Type = "Integer",
-- Min = -1,
-- Max = 1200,
-- Command = "ups_cl_cleartime",
-- } )

local NumSliderOne = vgui.Create( "DNumSlider", DermaPanel )
NumSliderOne:SizeToContents()
NumSliderOne:SetText( "Set to -1 to disable" )
NumSliderOne:SetMin( -1 ) -- Minimum number of the slider
NumSliderOne:SetMax( 1200 ) -- Maximum number of the slider
NumSliderOne:SetDecimals( 0 ) -- Sets a decimal. Zero means it's a whole number
NumSliderOne:SetConVar( "ups_cl_cleartime" ) -- Set the convar

-- panel:AddControl( "Label", { Text = "" } ) -- Spacing
local myLabelThree = vgui.Create("DLabel", DermaPanel)
myLabelThree:SetColor(Color(0,0,0,0)) // Color
myLabelThree:SetFont("default")
myLabelThree:SetText("Spacing") // Text
myLabelThree:SizeToContents() // make the control the same size as the text.

-- panel:AddControl( "Label", { Text = "Time until deletion after player leaves:" } )

local myLabelFour = vgui.Create("DLabel", DermaPanel)
myLabelFour:SetColor(Color(255,255,255,255)) // Color
myLabelFour:SetFont("default")
myLabelFour:SetText("Time until deletion after player leaves:") // Text
myLabelFour:SizeToContents() // make the control the same size as the text.

-- panel:AddControl( "Slider",  {
-- Label = "Set to -1 to disable",
-- Type = "Integer",
-- Min = -1,
-- Max = 1200,
-- Command = "ups_cl_deletetime",
-- } )

local NumSliderTwo = vgui.Create( "DNumSlider", DermaPanel )
NumSliderTwo:SizeToContents()
NumSliderTwo:SetText( "Set to -1 to disable" )
NumSliderTwo:SetMin( -1 ) -- Minimum number of the slider
NumSliderTwo:SetMax( 1200 ) -- Maximum number of the slider
NumSliderTwo:SetDecimals( 0 ) -- Sets a decimal. Zero means it's a whole number
NumSliderTwo:SetConVar( "ups_cl_deletetime" ) -- Set the convar

-- panel:AddControl( "Checkbox", { Label = "Delete admin props on leave", Command = "ups_cl_deleteadmin" } )
local CheckBoxOne = vgui.Create( "DCheckBoxLabel", DermaPanel )
    CheckBoxOne:SetText( "Delete admin props on leave" )
    CheckBoxOne:SetConVar( "ups_cl_deleteadmin" )
    CheckBoxOne:GetValue()
    CheckBoxOne:SizeToContents()

-- panel:AddControl( "Checkbox", { Label = "Admins affected by restrictions", Command = "ups_cl_affectadmins" } )
local CheckBoxTwo = vgui.Create( "DCheckBoxLabel", DermaPanel )
    CheckBoxTwo:SetText( "Admins affected by restrictions" )
    CheckBoxTwo:SetConVar( "ups_cl_affectadmins" )
    CheckBoxTwo:GetValue()
    CheckBoxTwo:SizeToContents()

-- panel:AddControl( "Checkbox", { Label = "Enable world protection", Command = "ups_cl_worldprotection" } )
local CheckBoxTwo = vgui.Create( "DCheckBoxLabel", DermaPanel )
    CheckBoxTwo:SetText( "Enable world protection" )
    CheckBoxTwo:SetConVar( "ups_cl_worldprotection" )
    CheckBoxTwo:GetValue()
    CheckBoxTwo:SizeToContents()

-- panel:AddControl( "Label", { Text = "" } ) -- Spacing
local myLabelFive = vgui.Create("DLabel", DermaPanel)
myLabelFive:SetColor(Color(0,0,0,0)) // Color
myLabelFive:SetFont("default")
myLabelFive:SetText("Spacing") // Text
myLabelFive:SizeToContents() // make the control the same size as the text.

-- panel:AddControl( "Label", { Text = "There are " .. tostring( table.getn( ents.GetAll() ) ) .. " entities found on the map!" } ) -- Shows how many entities are found on the map
local myLabelSix = vgui.Create("DLabel", DermaPanel)
myLabelSix:SetColor(Color(255,255,255,255)) // Color
myLabelSix:SetFont("default")
myLabelSix:SetText("There are " .. tostring( table.getn( ents.GetAll() ) ) .. " entities found on the map!") // Text
myLabelSix:SizeToContents() // make the control the same size as the text.

local UpsMenuCC = vgui.Create("DCollapsibleCategory", DermaPanel)
UpsMenuCC:SetPos( 25,50 )
UpsMenuCC:SetSize( 200, 50 ) -- Keep the second number at 50
UpsMenuCC:SetExpanded(  ) -- Expanded when popped up
UpsMenuCC:SetLabel( "Cleanup Controlls" )
 
CategoryList = vgui.Create( "DPanelList" )
CategoryList:SetAutoSize( true )
CategoryList:SetSpacing( 5 )
CategoryList:EnableHorizontal( false )
CategoryList:EnableVerticalScrollbar( true )
 
UpsMenuCC:SetContents( CategoryList ) -- Add our list above us as the contents of the collapsible category

-- panel:AddControl( "TextBox", { Label = "Cleanup", Command = "ups_clnstr_string", WaitForEnter = false } )
local textbox = vgui.Create("TextEntry")
textbox:SetConVar( "ups_clnstr_string" )
textbox:SetValue( "*" )
textbox:SizeToContents()
CategoryList:AddItem( textbox ) -- Add the above item to our list

-- panel:AddControl( "Button", { Text = "Cleanup!", Command = "ups_clnstr" } )
local button = vgui.Create( "DButton" )
button:SizeToContents()
button:SetText( "Cleanup!" )
button:SetConsoleCommand("ups_clnstr")
CategoryList:AddItem( button ) -- Add the above item to our list

local ClassCleanupMenu = vgui.Create("DCollapsibleCategory")
ClassCleanupMenu:SetPos( 25,50 )
ClassCleanupMenu:SetSize( 200, 50 ) -- Keep the second number at 50
ClassCleanupMenu:SetExpanded( 0 ) -- Expanded when popped up
ClassCleanupMenu:SetLabel( "Cleanup all props of a selected class:" )
 
ClassCleanupList = vgui.Create( "DPanelList" )
ClassCleanupList:SetAutoSize( true )
ClassCleanupList:SetSpacing( 5 )
ClassCleanupList:EnableHorizontal( false )
ClassCleanupList:EnableVerticalScrollbar( true )
 
ClassCleanupMenu:SetContents( ClassCleanupList ) -- Add our list above us as the contents of the collapsible category

local entClassTable = {}

for _, ent in pairs( ents.GetAll() ) do
if( ent:IsValid() ) then
if( ent:IsWorld() ) then

table.insert( entClassTable, ent:GetClass() )

if table.HasValue( entClassTable, ent:GetClass() ) then
local clnbutton = vgui.Create( "DButton" )
clnbutton:SizeToContents()
clnbutton:SetText( ent:GetClass() )
clnbutton:SetConsoleCommand("ups_clnstr_string" .. ent:GetClass() .. ";ups_clnstr")
end

ClassCleanupList:AddItem( clnbutton ) -- Add lines
end
end
end

CategoryList:AddItem( ClassCleanupList ) -- Add the above item to our list

local PlayerCleanupMenu = vgui.Create("DCollapsibleCategory")
PlayerCleanupMenu:SetPos( 25,50 )
PlayerCleanupMenu:SetSize( 200, 50 ) -- Keep the second number at 50
PlayerCleanupMenu:SetExpanded( 0 ) -- Expanded when popped up
PlayerCleanupMenu:SetLabel( "Delete all of a player's props:" )
 
PlayerCleanupList = vgui.Create( "DPanelList" )
PlayerCleanupList:SetAutoSize( true )
PlayerCleanupList:SetSpacing( 5 )
PlayerCleanupList:EnableHorizontal( false )
PlayerCleanupList:EnableVerticalScrollbar( true )
 
PlayerCleanupMenu:SetContents( PlayerCleanupList ) -- Add our list above us as the contents of the collapsible category

for uid, nick in pairs( playerTable ) do
local plybutton = vgui.Create( "DButton" )
plybutton:SizeToContents()
plybutton:SetText( nick )
plybutton:SetConsoleCommand("ups_remove " .. uid)
end

PlayerCleanupList:AddItem( PlayerCleanupList ) -- Add the above item to our list

local button = vgui.Create( "DButton", DermaPanel )
button:SizeToContents()
button:SetText( "Console Commands" )
button.DoClick = function()
Msg("---\n")
        Msg("You can also use the following console commands!\n")
Msg("---\n")
Msg("ups_cl_cleartime # [Time until props are put up for grabs after player leaves]\n")
Msg("---\n")
Msg("ups_cl_deletetime # [Time until deletion after player leaves]\n")
Msg("---\n")
Msg("ups_cl_deleteadmin # [Delete admin props on leave]\n")
Msg("---\n")
Msg("ups_cl_affectadmins # [Admins affected by restrictions]\n")
Msg("---\n")
Msg("ups_cl_worldprotection # [Enable world protection]\n")
Msg("---\n")
Msg("ups_clnstr_string (model or class) [Set the model or class to be cleaned up]\n")
Msg("---\n")
Msg("ups_clnstr [Cleanup the entities selected by ups_clnstr_string]\n")
Msg("---\n")
    end

end

concommand.Add( "ups_menu", upsMenuOpen )

I do not get any errors. And yes I made a GUI for UPS Menu. :)
« Last Edit: October 14, 2011, 03:17:55 PM by HeLLFox_15 »
I cry every time I see that I am not a respected member of this community.

Offline krooks

  • Sr. Member
  • ****
  • Posts: 382
  • Karma: 32
  • I don't like video games.
    • Diamond Krooks
Re: UPS Menu Add-on! (not a release.)
« Reply #1 on: September 22, 2011, 01:58:58 PM »
Sounds useful! Hopefully you're able to get it to work  :D (I can't be of any help, at all.) haha
My TTT server. Join the fun!

Offline LuaTenshi

  • Hero Member
  • *****
  • Posts: 545
  • Karma: 47
  • Just your ordinary moon angel!
    • Mirai.Red
I have edited my first post with my new problem, every thing else seems to be working fine.

I do not get any errors, that is the strange thing.

The commented lines of code are the old code.

(I accidentally removed the older comment so I just re-pasted it.)

Does any one have the slightest idea on how to fix this, because its bothering me that I can not get it 2 work.

Please Note: The commented lines of code are the original code, I modified it to change it into a GUI, but I cant seem to get it to work...
« Last Edit: October 15, 2011, 11:44:12 AM by HeLLFox_15 »
I cry every time I see that I am not a respected member of this community.