Making derma menu popup

So I have made a Derma but i cant get it to pop up i use



function ShowMenu( ply )
	umsg.Start( "Openpls", ply )
	umsg.End()
end
hook.Add("ShowHelp", "MyHook", MyMenu)

in a server side file but because this is not a gamemode so its not in a init file im not sure how to add it to my derma code so i can open it up.

thanks in advance for the help

I’d recommend using net messages.

Here’s a tutorial in using them: https://dl.dropboxusercontent.com/u/26074909/tutoring/networking/networking_booleans.lua.html

Example using the network to send a message to a client, start a HUDPaint, and only when the client is fully in the server start the count-down before removing it: https://dl.dropboxusercontent.com/u/26074909/tutoring/vgui/display_something_on_initial_spawn.lua.html

For yours, instead of using hook.Add HUDPaint, you’d use vgui.Create for your panel on the receiving end. Instead of PlayerInitialSpawn triggering the net.Send on the SERVER side, you’d use your ShowHelp hook.

Hi im still really new to gmod lua so im kind of confused what you are talking about, so if you can explain to me in a way a noob can understand that would be nice

Net messages work the same way umsgs used to.
Umsgs aren’t used anylonger, here’s how to use net messages: http://wiki.garrysmod.com/page/Net_Library_Usage

ok but how would i use this to send my code to the client file so i can open up my derma menu

Sure. The first link does several things. in if SERVER then, it defines the message name that will be sent back and forth…

Console command is added, dev_testbit. It works on both client and server ( this file is meant to be shared meaning in lua/autorun/ instead of client which is lua/autorun/client/ or server which is lua/autorun/server ).

If you type dev_testbit in console on the server, it sends it to all players ( broadcast sends to all; net.Send( player.GetAll( ) ) does the same thing ).

If you type dev_testbin in console on the client, it sends to the server.

net.Receive will print the same thing regardless of whether it is on the SERVER or CLIENT ( receiving end )

First, it turns the bit ( 1 / 8 of one character - either a 1 or 0 = 0000000[1] or 0000000[0] ), tobool converts it to a true or false. If this is not done, both will always be true in terms of a boolean expression ( if x then ) because the value is set.

What you’re looking to do, is on the ShowHelp hook ( which remains the same in your code, just replace umsg lines with net.Start( “message_name” ); net.Start( ply ); ) and make sure the message_name is initialized like in the boolean code.

your net.Receive will only be on the CLIENT; and you’ll do something like


local _panel = vgui.Create( "DFrame" );
_panel:SetSize( 400, 400 );
_panel:Center( );

The second example basically puts it all together to make something appear for 5 seconds, then disappear.

thanks for teaching me that but what i actualy want to do is make it so my derma menu can pop up

Like, slide in?
Or… Panel:MakePopup() ?

this is not the problem my panel will popup except im trying to make it so i click f4 or f1 or those type of things it will open up and this is not for a gamemode, using tuts it all says to put it in an init file which i dont have, i just want to make it so ican open it up thats all not some hard thing really.

I have lost interest in this topic.

Your words are very misleading and each of your post totally changes my view of what you want done.

Good luck.

[lua]
if ( SERVER ) then
// Sure. The first link does several things. in if SERVER then, it defines the message name that will be sent back and forth…
// and make sure the message_name is initialized like in the boolean code.
util.AddNetworkString( “NetMessageName” );

// What you're looking to do, is on the ShowHelp hook 
hook.Add( "ShowHelp", "NetMessageName:ShowHelp", function( _p )
	// ( which remains the same in your code, just replace umsg lines with net.Start( "message_name" ); net.Start( ply ); )
	net.Start( "NetMessageName" );
	net.Send( _p );
end );

else
//your net.Receive will only be on the CLIENT; and you’ll do something like:
net.Receive( “NetMessageName”, function( len )
local _panel = vgui.Create( “DFrame” );
_panel:SetSize( 400, 400 );
_panel:Center( );
_panel:MakePopup( );

end );

end[/lua]