• How to not have more than 1 of the same derma menu
    32 replies, posted
Ok, so, I made a derma menu, and when you die and your a spectator, it comes up every round, and if you stay afk, the menus keep popping up. If the above did not make sense to you, please answer this simple question: How do you not have more than 1 of the same derma frame pop up?
Set a variable in PANEL:Init and check it when you are trying to create another panel?
[QUOTE=iRzilla;26940193]Don't create it more then once.[/QUOTE] ... dude the gamemode opens it every round, im trying to figure out a way to not have it open if there already is one open [QUOTE=Feihc;26940161]Set a variable in PANEL:Init and check it when you are trying to create another panel?[/QUOTE] I was thinking about that but I felt iffy if it would work
It should work as long as its in scope of both the panel and the function you are calling it from.
pretty sure panel:IsVisible() exists, make a check before creating.
Not sure why he was rated late, that would be a lot easierthen creating a variable [lua] if PANEL:IsVisible() then return end [/lua]
[QUOTE=iRzilla;26941387]What you're saying c-unit is PANEL = vgui.Create('DFrame')?[/QUOTE] Yes :ohdear: [editline]24th December 2010[/editline] then at the end of the round when he goes to open the menu instead of running the console command to open it or however he does it, he does this [lua] if PANEL:IsVisible() then return end else ply:ConCommand("derma_menu") end [/lua]
Just wondering, is it possible to get the value of a variable from serverside? ok so...would this work? [lua] function mydermamenu() if numberofmenusopen == nil or 0 then numberofmenusopen = 0 numberofmenusopen = numberofmenusopen + 1 blah = vgui.Create( "DFrame" ) //blahblahblah blah1 = vgui.Create( "DButton", blah ) //blahblahblah blah1.DoClick = function() numberofmenusopen = numberofmenusopen - 1 blah:Close() end end end [/lua]
[QUOTE=Andriko1;26941762]Just wondering, is it possible to get the value of a variable from serverside[/QUOTE] usermessages
[QUOTE=c-unit;26941399]Yes :ohdear: [editline]24th December 2010[/editline] then at the end of the round when he goes to open the menu instead of running the console command to open it or however he does it, he does this [lua] if PANEL:IsVisible() then return end else ply:ConCommand("derma_menu") end [/lua][/QUOTE] You mean PANEL:IsActive() ??? I haven't seen 1 correct paste of code you put on facepunch...
[QUOTE=Andriko1;26942175]I haven't seen 1 correct paste of code you put on facepunch...[/QUOTE] Coming from the person who put for k, v in pairs(ply.GetAll()) and IsVisible works perfectly fine. [editline]24th December 2010[/editline] you should read up on it [b][url=http://wiki.garrysmod.com/?title=Panel.IsVisible]Panel.IsVisible [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]
player.GetAll() grr [editline]24th December 2010[/editline] It gave a nil value :( [editline]24th December 2010[/editline] I fixed it by just saying if choose == nil then [editline]24th December 2010[/editline] and assigning choose to nil when it closes
[QUOTE=iRzilla;26940193]Don't create it more then once.[/QUOTE] I don't see why this was shot down and rated dumb. He is right about only creating it once; Check if it exists, if it doesn't then create it, else show it.
[QUOTE=iRzilla;26951310]I was wondering why too, but obviously these newcomers know best. Which is why they're posting questions here.[/QUOTE] Don't worry, I rated agree ;D
by dont open it again, I thought he meant, if its open dont open the menu again, and the error wont happen. Some little kids open it twice, so I'm trying to find a way to fix it lol [editline]26th December 2010[/editline] Do Frames have the IsVisible function, or do I have to parent the frame to a panel for this to work [editline]26th December 2010[/editline] Would Frame:IsActive() return if the frame is visible?
IsVisible() returns if it's visible, IsActive returns if its open like if you have ran the console command and you can still interact with it, it will still return true even if you did SetVisible( false ) I think [lua] function menu() --make the menu in here end concommand.Add("men", menu) concommand.Add("end_of_round_menu", function( ply ) if !DFrameVarName:IsVisible() then ply:ConCommand("men") else return "" end end) [/lua] Something like that
There is no need to use a concommand.
[QUOTE=c-unit;26982892]IsVisible() returns if it's visible, IsActive returns if its open like if you have ran the console command and you can still interact with it, it will still return true even if you did SetVisible( false ) I think [lua] function menu() --make the menu in here end concommand.Add("men", menu) concommand.Add("end_of_round_menu", function( ply ) if !DFrameVarName:IsVisible() then ply:ConCommand("men") else return "" end end) [/lua] Something like that[/QUOTE] would frame:Close() make it not active? UGH, I know panels have the IsVisible() function, but gmod wiki did not say if its part of frames too
[QUOTE=Andriko1;26982257]by dont open it again, I thought he meant, if its open dont open the menu again, and the error wont happen. Some little kids open it twice, so I'm trying to find a way to fix it lol [editline]26th December 2010[/editline] Do Frames have the IsVisible function, or do I have to parent the frame to a panel for this to work [editline]26th December 2010[/editline] Would Frame:IsActive() return if the frame is visible?[/QUOTE] Just make it so that if its open and they open it again, it closes, simple.
I did not know frames were based off panels... Thank you but could of had a nicer tone :P
Using blah:IsVisible() will error out if the panel dosent exist. Im pretty sure about this but not 100% positive.
[lua] if DPanelName && DPanelName:IsVisible() then return '' end [/lua]
I got an idea. Create the derma menu then use DPanel:SetVisible(true) to show it and DPanel:SetVisible(false) to hide it.
[QUOTE=foxxeh;26991067]I got an idea. Create the derma menu then use DPanel:SetVisible(true) to show it and DPanel:SetVisible(false) to hide it.[/QUOTE] Check 50 posts up
I just checked if it's nil, it seems to be working :P
what are you talking about
Sorry, you need to Log In to post a reply to this thread.