How to not have more than 1 of the same derma menu

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?

Don’t create it more then once.

… 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

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]

What you’re saying c-unit is PANEL = vgui.Create(‘DFrame’)?

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]

usermessages

You mean PANEL:IsActive() ???
I haven’t seen 1 correct paste of code you put on facepunch…

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 **[Panel.IsVisible

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=Panel.IsVisible)**

player.GetAll() grr

[editline]24th December 2010[/editline]

It gave a nil value :frowning:

[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

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.

I was wondering why too, but obviously these newcomers know best. Which is why they’re posting questions here.

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.