On Dead Popup

i tryed to make a menu Pop up on Death
but every time i Dies Nothing happens
Please help me
[lua]
function playerDies( victim, weapon, killer )

function testframe()
local frame1 = vgui.Create(“DFrame”)

frame1:SetPos(100,100)
frame1:SetSize(200,200)
frame1:SetTitle(“Test”)
frame1:MakePopup()

end

end

hook.Add( “PlayerDeath”, “playerDeathTest”, playerDies )
[/lua]

I’ve never worked with vgui before, so this may be imperfect, but this worked for me-

[LUA]
function playerDies( victim, weapon, killer )
umsg.Start(“call_vgui”, victim)
umsg.End()
end

function showDeathPopup()
if CLIENT then
local frame1 = vgui.Create(“DFrame”)

	frame1:SetPos(100,100)  
	frame1:SetSize(200,200)  
	frame1:SetTitle("Test")  
	frame1:SetVisible( true )
	frame1:SetDraggable( false ) //Can the player drag the frame /True/False
	frame1:ShowCloseButton( true ) //Show the X (Close button) /True/False
	frame1:MakePopup()  
end	  

end

hook.Add( “PlayerDeath”, “playerDeathTest”, playerDies )
usermessage.Hook( “call_vgui”, showDeathPopup ) [/LUA]

This can be copypasta’d right into a shared file. There is likely a much better way to organize it between client & server, but I don’t have time right now.

I have just what you’re looking for, let me find it…

Edit:

cl_init.lua:

[lua]function PlayerDies()
frame = vgui.Create (“DFrame”)
frame:SetPos (250, ScrH() / 2)
frame:SetSize (400, 90)
frame:SetTitle (“New Life Rule”)
frame:SizeToContents()
frame:SetVisible (true)
frame:SetDraggable (false)
frame:ShowCloseButton (false)
frame:MakePopup()

label = vgui.Create ("DLabel") 
label:SetParent (frame)
label:SetText ("You died. You only remember your friends, home and job. 

Do not revenge your death by killing the guy who killed you.")
label:SetPos (50, 20)
label:SizeToContents()

accept = vgui.Create ("DButton", frame )  
accept:SetPos (100, 30)  
accept:SetSize (50, 30)  
accept:SetText ("Accept!")  
accept.DoClick = function()
    frame:Close()      
end 
  
decline = vgui.Create ("DButton", frame )  
decline:SetPos (200, 30)  
decline:SetSize (50, 30)  
decline:SetText ("Decline!")  
decline.DoClick = function()  
    error ('You have to Accept the New Life Rule!')  
end

end

concommand.Add(“OMGIDED”, PlayerDies)[/lua]

init.lua:

[lua]function PlayerDies( victim, weapon, killer )

victim:ConCommand("OMGIDED")

end

hook.Add( “PlayerDeath”, “playerDeathTest”, PlayerDies )
[/lua]

It seems odd, but from what I’ve read, nested functions are possible in LUA.

I’ve seen people do it to make use of local variables in a function. I think it’s sloppy, but that’s my personal feeling.

I would just wrap the part I want to keep local in a do end block instead of put it in another function.