• How to add concommand.Add properly to the script?
    3 replies, posted
I have been using this: [url]http://www.garrysmod.org/downloads/?a=view&id=88809[/url] I edited a bit of the code to make it work for me, gave edited version to a friend, he couldn't find the open button, I said I'd add a concommand. It doesn't work :L At the moment, the con.command is calling InfoMenu, which is the main function, which should work. Yet when I type "musicp" (the concommand added) into console, it says Unknown Command (even though the command appears in the suggestion box.) If anyone knows how to, I would like the concommand to do this: "Mainmenu:SetVisible(true)" This is the current code [lua]function InfoMenu() Csave=file.Read("guilsstuff/Barcolors.txt") First=file.Read("guilsstuff/firsttime.txt") include( "autorun/client/ProgressBar2.lua" ) local Mainmenu = vgui.Create("DFrame") Mainmenu:SetPos( 25,25 ) Mainmenu:SetSize( 650, 500 ) Mainmenu:SetTitle('Guils Super Menu V 1.2 "beta"') Mainmenu:SetDraggable( true ) Mainmenu:ShowCloseButton( true ) Mainmenu:SetSizable( false ) Mainmenu:SetDeleteOnClose( false ) Mainmenu:SetBackgroundBlur( false ) Mainmenu:SetVisible(false) Mainmenu:MakePopup() Open=vgui.Create("DButton") Open:SetPos(120,744) Open:SetSize(50,20) Open:SetText("Open") Open.DoClick = function() Mainmenu:SetVisible(true) end local TabS = vgui.Create("DPropertySheet",Mainmenu) TabS:SetPos (20,20) TabS:SetSize(620,470) local Tab1 = vgui.Create( "DPanel",Mainmenu) Tab1:SetPos( 5, 15 ) Tab1:SizeToContents() local Tab2 = vgui.Create( "DPanel",Mainmenu ) Tab2:SetPos( 5, 15 ) Tab2:SizeToContents() local Tab3 = vgui.Create( "DPanel",Mainmenu ) Tab3:SetPos( 5, 15 ) Tab3:SizeToContents() local Internet = vgui.Create( "DPanel",Mainmenu ) Internet:SetPos( 5, 15 ) Internet:SizeToContents() local DLV = vgui.Create("DListView") DLV:SetParent(Tab1) DLV:SetPos(0, 0) DLV:SetSize(600, 400) DLV:SetMultiSelect(false) DLV:AddColumn("Name") DLV:AddColumn("Rank") DLV:AddColumn("Hp") DLV:AddColumn("armor") DLV:AddColumn("Admin?") DLV:AddColumn("ping") DLV:AddColumn("Kills") DLV:AddColumn("Deaths") DLV:AddColumn("Rp money") DLV:AddColumn("Team #") Pcount=0 Refresh = vgui.Create("DButton",Tab1) Refresh:SetSize(50,25) Refresh:SetPos(30,400) Refresh:SetText("Refresh list") Refresh.DoClick = function() DLV:Clear() for k,v in pairs(player.GetAll()) do DLV:AddLine(v:Nick(),team.GetName( v:Team() ),v:Health(),v:Armor(),v:IsAdmin(),v:Ping(),v:Frags(),v:Deaths(),("$" .. v:GetNWInt("money")),v:Team()) end end function DLV:Think() Pcount=Pcount if table.Count(player.GetAll())!=Pcount then Pcount=table.Count(player.GetAll()) DLV:Clear() for k,v in pairs(player.GetAll()) do DLV:AddLine(v:Nick(),team.GetName( v:Team() ),v:Health(),v:Armor(),v:IsAdmin(),v:Ping(),v:Frags(),v:Deaths(),("$" .. v:GetNetworkedInt("money")),v:Team()) end end end Psred=string.Explode(" ",Csave)[2] Psgreen=string.Explode(" ",Csave)[3] Psblue=string.Explode(" ",Csave)[4] Psalpha=string.Explode(" ",Csave)[5] Urlp = vgui.Create("HTML") Urlp:SetPos(9999,9999) Urlp:SetSize(ScrW() - 100000, ScrH() - 100000) Maxtime=0 local Pbox = vgui.Create("DPanel") Pbox:SetPos(360,5) Pbox:SetSize(300,30) Pbox:SetAlpha(Psalpha) local Progress = vgui.Create("DProgressBar",Pbox) Progress:SetSize(300,30) Progress:SetMax(Maxtime) Progress:SetMin(0) Progress:SetAlpha(Psalpha) Progress:SetColor(Color(Psred,Psgreen,Psblue,255)) Time=0 Progress:SetValue(0) local Songplaying = vgui.Create("DLabel",Progress) Songplaying:SetPos(20,0) Songplaying:SetTextColor(Color(0,0,255,255)) Songplaying:SetText("No Song Playing") Songplaying:SetSize(150,30) local Timeshow = vgui.Create("DLabel",Progress) Timeshow:SetPos(160,0) Timeshow:SetTextColor(Color(255,255,0,255)) Timeshow:SetText("0:00") Timeshow:SetSize(150,30) local slash = vgui.Create("DLabel",Progress) slash:SetPos(190,0) slash:SetTextColor(Color(255,255,0,255)) slash:SetText("/") slash:SetSize(150,30) local Timetotal = vgui.Create("DLabel",Progress) Timetotal:SetPos(200,0) Timetotal:SetTextColor(Color(255,255,0,255)) Timetotal:SetText("0:00") Timetotal:SetSize(150,30) local Guilplayer = vgui.Create("DLabel",Progress) Guilplayer:SetPos(20,-50) Guilplayer:SetTextColor(Color(255,0,0,255)) Guilplayer:SetText("Music Player") Guilplayer:SetSize(150,30) Starts=0 Startm=0 --STEAM_0:1:22731794 :P just a reminder local Songlist = vgui.Create("DListView") Songlist:SetParent( Tab2 ) Songlist:SetSize(600,340) Songlist:SetPos(0,1) Songlist:SetMultiSelect(false) Songlist:AddColumn("Song") Songlist:AddColumn("Time") Songlist:AddColumn("online/offline") Songlist:AddLine("NEDM",os.date("%M",320)..":"..os.date("%S",320),"Online") Songlist:AddLine("Like A Boss",os.date("%M",121)..":"..os.date("%S",121),"Online") Songlist:AddLine("Blue",os.date("%M",224)..":"..os.date("%S",224),"Online") Songlist:AddLine("You Are A Pirate",os.date("%M",114)..":"..os.date("%S",114),"Online") Songlist:AddLine("Jizz In My Pants",os.date("%M",154)..":"..os.date("%S",154),"Online") Songlist:AddLine("Beer",os.date("%M",141)..":"..os.date("%S",141),"Online") Songlist:AddLine("Techno Dream",os.date("%M",294)..":"..os.date("%S",294),"Online") Songlist:AddLine("Dota",os.date("%M",187)..":"..os.date("%S",187),"Online") Songlist:AddLine("I Can Break These Cuffs",os.date("%M",91)..":"..os.date("%S",91),"Online") Songlist:AddLine("Dont Stop The Rock",os.date("%M",332)..":"..os.date("%S",332),"Online") Songlist:AddLine("I'm A Korean",os.date("%M",278)..":"..os.date("%S",278),"Online") Songlist:AddLine("Ravebreak","00:27","Offline") Songlist:AddLine("Slap Chop",os.date("%M",198)..":"..os.date("%S",198),"Online") Songlist:AddLine("Discovery Channel",os.date("%M",262)..":"..os.date("%S",262),"Online") Songlist:AddLine("Still Alive Raddox Remix",os.date("%M",275)..":"..os.date("%S",275),"Online") Songlist:AddLine("Scatman",os.date("%M",203)..":"..os.date("%S",203),"Online") Songlist:AddLine("Scatman's World",os.date("%M",226)..":"..os.date("%S",226),"Online") Songlist:AddLine("Ghostbusters",os.date("%M",242)..":"..os.date("%S",242),"Online") Songlist:AddLine("Safety Dance",os.date("%M",165)..":"..os.date("%S",165),"Online") Songlist:AddLine("The Device Has Been Modified v2",os.date("%M",204)..":"..os.date("%S",204),"Online") Songlist:AddLine("Dick In A Box",os.date("%M",166)..":"..os.date("%S",166),"Online") Songlist:AddLine("Amazing Horse",os.date("%M",196)..":"..os.date("%S",196),"Online") Songlist:AddLine("Haax Remix",os.date("%M",56)..":"..os.date("%S",56),"Online") Songlist:AddLine("This Is Haax",os.date("%M",59)..":"..os.date("%S",59),"Online") Songlist:AddLine("Mortal KomHax",os.date("%M",77)..":"..os.date("%S",77),"Online") Songlist:AddLine("I Got A Feeling",os.date("%M",246)..":"..os.date("%S",246),"Online") Songlist:AddLine("Dance Fucker Dance",os.date("%M",179)..":"..os.date("%S",179),"Online") Textdown1=0 Textdown2=0 Scroll=0 local Songbutton = vgui.Create("DButton") Songbutton:SetParent( Tab2 ) Songbutton:SetToolTip("Play the selected song") Songbutton:SetPos( 30,350 ) Songbutton:SetSize( 80,50 ) Songbutton:SetText( "Play song" ) Songbutton.DoClick = function ( ) Picked=Songlist:GetSelected()[1]:GetValue(1) if Picked=="NEDM" then Url="http://www.youtube.com/watch?v=nVBalxt3NEU" Maxtime=320 elseif Picked=="Like A Boss" then Url="http://www.youtube.com/watch?v=NisCkxU544c" Maxtime=121 elseif Picked=="Blue" then Url="http://www.youtube.com/watch?v=Y4QGPWLY-EM" Maxtime=224 elseif Picked=="You Are A Pirate" then Url="http://www.youtube.com/watch?v=MalBJuI9O5k" Maxtime=114 elseif Picked=="Jizz In My Pants" then Url="http://www.youtube.com/watch?v=4pXfHLUlZf4" Maxtime=154 elseif Picked=="Beer" then Url="http://www.youtube.com/watch?v=iEmbOqBte1g" Maxtime=141 elseif Picked=="Techno Dream" then Url="http://www.youtube.com/watch?v=ouBJTv_OqJA" Maxtime=294 elseif Picked=="Dota" then Url="http://www.youtube.com/watch?v=qXKd7uuehlw" Maxtime=187 elseif Picked=="I Can Break These Cuffs" then Url="http://www.youtube.com/watch?v=JQTXawaAKNA" Maxtime=91 elseif Picked=="Dont Stop The Rock" then Url="h
On line 520 change Infomenu to InfoMenu . I don't know if you knew this or not, but Lua is case sensitive.
Why would you call your derma menu with a think hook? you should use a hook called less often, or just a concommand
[QUOTE=Sparky-Z;29561073]On line 520 change Infomenu to InfoMenu . I don't know if you knew this or not, but Lua is case sensitive.[/QUOTE] Just realized that :L [QUOTE=c-unitV2;29561166]Why would you call your derma menu with a think hook? you should use a hook called less often, or just a concommand[/QUOTE] Not my code. EDIT: Works like a charm now, thanks!
Sorry, you need to Log In to post a reply to this thread.