Using both server and client side help

So I plan on making a something, along the lines of if a player dies then a menu will show up upon death.
So this involves server side(player stuff) and client side(Derma)
So my question is how can I get this to function properly as one. ( point me in the direction in order to do this)

Hiya, My name is Seagull and I will be your guide today.

First is going on the Serverside. We are going to call a hook, better known as ‘PlayerDeath’
[lua]
hook.Add( “PlayerDeath”, “OpenDeath”, function( ply ) – ply is our Player variable
umsg.Start( “OpenMenu”, ply ) – prepares the Usermessage for client
umsg.End() – Sends to Client
end )
[/lua]

After doing this we move onto the clientside function. Around your Derma menu, add this in:
[lua]
usermessage.Hook( “OpenMenu”, MyMenu )
[/lua]
Where MyMenu is the name of your derma function

Hope this helped :slight_smile:
Any questions, reply back here or PM me on Facepunch.

Thank you! this definitely clears some things up. I’ll be sure to test it out and reply back.

EDIT: I just get “Warning: Unhandled usermessage ‘OpenMenu’”

You shouldn’t be using user messages anymore in GMod 13 (imo).
Use the new net library.



--Server
util.AddNetworkString("OpenMenu")
hook.Add("PlayerDeath", "OpenDeath", function(ply)
 net.Start("OpenMenu")
 net.Send(ply)
end)




--Client
net.Receive("OpenMenu", function()
 --Do Derma Stuff
end)


I tried that with no luck. Then I did something like this, with no luck.
Doesn’t run, no errors. nada.
I’m probably messing something up stupidly.



--client
local function playerdeathmenu()
local DermaPanel = vgui.Create( "DFrame" )
DermaPanel:SetPos( 50,50 )
DermaPanel:SetSize( 1000, 900 )
DermaPanel:SetTitle( "Testing Derma Stuff" ) 
DermaPanel:SetVisible( true )
DermaPanel:SetDraggable( true )
DermaPanel:ShowCloseButton( true )
DermaPanel:MakePopup()
DermaPanel:Center()
DermaPanel:SetBackgroundBlur( true )
end
net.Receive("OpenMenu", playerdeathmenu)




--server
function playerdeath(victim, weapon, killer)
util.AddNetworkString("OpenMenu")
net.Start("OpenMenu")
net.Send(ply)
end
hook.Add("PlayerDeath", "Playerdeathmenu", playerdeath)


Put util.AddNetworkString(“OpenMenu”) outside of any functions, loops or IFs. Put it in the beginning of the file.

Alright, did that, but I still receive the same results.

Try this:

[LUA]
–client
net.Receive(“OpenMenu”, function()
local DermaPanel = vgui.Create( “DFrame” )
DermaPanel:SetPos( 50,50 )
DermaPanel:SetSize( 1000, 900 )
DermaPanel:SetTitle( “Testing Derma Stuff” )
DermaPanel:SetVisible( true )
DermaPanel:SetDraggable( true )
DermaPanel:ShowCloseButton( true )
DermaPanel:MakePopup()
DermaPanel:Center()
DermaPanel:SetBackgroundBlur( true )
end)

–server
function playerdeath(victim, weapon, killer)
util.AddNetworkString(“OpenMenu”)
net.Start(“OpenMenu”)
net.Send(ply)
end
hook.Add(“PlayerDeath”, “Playerdeathmenu”, playerdeath)[/LUA]

util.AddNetworkString(“OpenMenu”)

Have to be outside any function.

[lua]util.AddNetworkString(“OpenMenu”)

// Server function
//On player death, it will send a message to ply (the player who died) to do client-side stuff
function playerdeath(victim, weapon, killer)
net.Start(“OpenMenu”)
net.Send(victim)
end
hook.Add(“PlayerDeath”, “Playerdeathmenu”, playerdeath)

// Client Function
// Once it receives the OpenMenu message which the server sent, it will run below function, aka the derma menu.
// I’m not 100% if this alone works (not sure if victim is pointing towards said person.) but w/e, you get the jist

if CLIENT then
net.Receive(“OpenMenu”, function()
local DermaPanel = vgui.Create( “DFrame” )
DermaPanel:SetPos( 50,50 )
DermaPanel:SetSize( 1000, 900 )
DermaPanel:SetTitle( “Testing Derma Stuff” )
DermaPanel:SetVisible( true )
DermaPanel:SetDraggable( true )
DermaPanel:ShowCloseButton( true )
DermaPanel:MakePopup()
DermaPanel:Center()
DermaPanel:SetBackgroundBlur( true )
end)
end[/lua]

Should work, ask me if you have any questions

Hmmm… Still getting the same results. I’ve tried killing myself through props,players,suicide and so fourth as well.
I am getting absolutely no errors. I’ve tried multiple ways too, with no luck.
The closet thing I got to a response from the console was MrGregsWorld idea, which still didn’t work(Error).

Added a small bit, this should most definitely work now and you should see “A player died” in console to confirm it’s hooking correctly.

You are running the script as shared right ( or 1 client 1 server). You could try to print a debug message so you know the function is actually being called.

Edit: damn, I was ninja’d

Well, I’m utterly confused, but it works!
Why I’m confused:
The server side works fine, while the client side didn’t respond to anything.
I moved the client side to another file with my hud(which is also client sided) and it works perfectly fine.
I’ve checked a couple things to see why it would happen, and well none of it comes to sense why it shouldn’t.

Anyway, thanks guys.

Sounds like the file you had it in before wasn’t being included.

That was my first guess, so I doubled checked that and it was included most definitely.
Ill look more into it tomorrow on my own.
Once again thanks for the help everyone.