Loading a vgui when player spawn

So hello guys, i’m currently working on a gamemode, my first actualy.
But at the moment, i’m stuck, so my question would be:

How could i make the client load a VGUI panel to select weapon, but only when the player spawn, also, 1 different vgui per team, and there’s 2 team.

Thanks ^^

Edit: Also by the same way, could anyone help me integretating a Hud in the said gamemod too? I’ve tried different thing but it just don’t work.

Edit3: As you know i’m currently working on gamemode projet, i just went through the Early beta phase, the gm work fine itself, but i found many bug, if someone could kindly help this novice in lua it would be grealy apreciated, Send me a PM on here if you feel you can help me ^^; I’m working alone to do the mod, and as i’m starting in Lua i need someone to teach me, help me and else…

You can use these handy things called usermessages to signal when a client should do something and gamemode hooks to run functions on events like when a player spawns. For example,

[lua]function OpenMenu(pl)
umsg.Start(“OpenMenu”,pl)
umsg.End()
end
hook.Add(“PlayerSpawn”,“OpenMenu”,OpenMenu)[/lua]

And then on the client,

[lua]function Menu()
// Menu stuff here
end
usermessage.Hook(“OpenMenu”,Menu)[/lua]

For the HUD just use the client gamemode hooks, namely HUDShouldDraw and HUDPaint, along with the surface and draw libraries. It’s all on the wiki.

Thanks guy (You both made me learn alot of new things), though, i didn’t get my HUD hide thing to work
Also, i seem to have a problem with playermodel, it say an error about the base gamemode or something.

Edit:
Also, if i want the buttons to give a certain swep when pressed, is there a better way then let say,

At the moment i have things like


 Init.lua
function smg1( ply ) 

        ply:Give( "airsoft_smg1" )
 end
 concommand.Add( "smg1", smg1 )


 Cl_Init.lua
weaponc = vgui.Create( "DButton", frame )
weaponc:SetPos( 65, 20 );
weaponc:SetSize( 50, 50 )
weaponc:SetText( "SMG1" )
weaponc.DoClick = function()
    RunConsoleCommand( "smg1" )
frame:Close()
end

Edit2: Finaly fixed the Derma menu. And hud

Edit3: As you know i’m currently working on gamemode projet, i just went through the Early beta phase, the gm work fine itself, but i found many bug, if someone could kindly help this novice in lua it would be grealy apreciated, Send me a PM on here if you feel you can help me ^^; I’m working alone to do the mod, and as i’m starting in Lua i need someone to teach me, help me and else…