How can I make that a Derma Menu opens once the player spawn?

How can I make that a Derma Menu opens once the player spawn?

I made a derma menu that I want to open once the player has spawned… the script is client side…

tips on how to do this?

On PlayerSpawn make the panel open

Does this work on CLIENT as well or only SERVER? Cause I tried this… got error or attempt to set GM to Nill value…

May I see your code?

The code:


if ( CLIENT ) then
local pl =LocalPlayer()
  function GM:PlayerSpawn(pl)
/* inside theres the DFrame code + DButtons */
end

Hope this helps, not near the PC right now…

Since the PlayerSpawn function is server-side and Derma is a client-side thing, you’re going to have to use net messages to communicate between client and server.

i.e



if (SERVER) then

util.AddNetworkstring("somenetwork")

   hook.Add("PlayerSpawn", "OpenDerma", function(ply)

   net.Start("somenetwork")
   net.Send(ply)
  
   end)
end

if (CLIENT) then

   net.Recieve("somenetwork", function()
 
   --Derma code here

   end)

end



This basically tells it to start the net message “somenetwork”, (which will contain the contents to the derma menu in your client side code), when that player spawns, which will ultimately open that menu.

You can read more on the net library here: http://wiki.garrysmod.com/page/Net_Library_Usage

EDIT:

The reason why your code isn’t working is because you’re using client side code in a server-side function, you can correct it as I explained above.

adding onto what he said ^

if you plan to use PANELS as the derma, make sure the 3rd arg in the vgui.Create() is not the same as the first; it will create a infinite net loop which will fuck your shit over

If you want it to appear when the player first joins, you can create a HUDPaint ( with mandatories, ie return if LocalPlayer !IsValid ), but after the LocalPlayer IsValid remove the HUDPaint hook and open the vgui window.

Super simple way to detect when a player has fully connected to the server ( don’t use this method for things that NEED to be executed by the server; there are other methods to detect PlayerFullyConnected on the server )…

Here’s an example, except it creates the HUDPaint when the PlayerInitialSpawn is called on Server through net message: https://dl.dropboxusercontent.com/u/26074909/tutoring/vgui/display_something_on_initial_spawn.lua.html – That is for something… this is vgui: https://dl.dropboxusercontent.com/u/26074909/tutoring/vgui/display_vgui_on_initial_spawn.lua.html

To make it 100% clientside, all networking could be removed, and just keep the HUDPaint hook in the main scope of the file instead of inside the net.Receive.

There are many different ways to do it depending on the goal… If only once, then several methods listed above. If every spawn, you can use networking, but you can also use game-events ( which are shared to make something 100% clientside for non-important things ): https://dl.dropboxusercontent.com/u/26074909/tutoring/_redistributable/acecooldev_base/documentation/game_events/game_event_listeners.lua.html

What exactly are you trying to do… What is the vgui for? Is it for team selection on initial join, or is it to “vote” warden in jail-break, or etc… Based on different scenarios certain things may be “better”, ie more efficient, than others.

nice post, didnt advertise your dropbox tutorials that make choppy functions, you explained it a bit better than us +1