Derma questions: Close when you click a button & Open on startup?

Greetings!

I’d like to know if it’s possible to close a DFrame whenever you click a button. If so, how?

Also, how can I exec a concommand on player startup? ( In my case, my “open team selection derma”, Team_menu )

Cheers!

**[DFrame.Close

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

On the page above there is an example for what you want too do.

You shouldn’t need to force a player to run a concommand to open a menu unless he is telling the server that he is opening up the menu, instead just run the function that makes & opens the menu in a hook.

Thanks! Now, I also want to change the player speeds. I am using :

But it doesnt seem to work. Speeds are still high for that specific team. Any tips?

Btw, close only works on Dframes, solution:

[lua]
function PANEL:Close(bRemove)
if ( bRemove == nil ) then
bRemove = true;
end

if ( bRemove == true ) then
	
	-- I'm just putting this here because when i removed it without making it invisible, it was doing a weird glitching thing, but that could be something with my custom panels.
	self:SetVisible(false);
	self:Remove();
else
	self:SetVisible(false);
end

end
[/lua]

apply them in PlayerSpawn, they work I’m using them currently.

There is no harm in doing it, though.

the DFrame close thing works! Cheers!

Um, I still want to run a concommand as soon as a player spawns. HOW DO.

And uh, I’m still having problems with the speed. You see, I want to make it so that one team is faster than the other one. So doing that in playerspawn wouldnt really help. :\

Uh…Yeah it would?

Bad example but:
[lua]function GM:PlayerSpawn( ply )
if ply:Team() == 1 then
ply:SetRunSpeed(100)
ply:SetWalkSpeed(100)
elseif ply:Team() == 2 then
ply:SetRunSpeed(500)
ply:SetWalkSpeed(500)
end
end[/lua]

thats the catch. i tried using that, but it didnt work. run is still 500, walk is still 250. Any ideas guys? :\

It does work. I’m doing it right now. That means somehow whatever gamemode you’re using is setting there speeds again after they are initially set.

snip