Derma Menu when Player dies - whats wrong?

So; Im scripting some things for my future DarkRP server (Yeah, DarkRP - so what? >:P).

I’m trying to make a Derma menu open, when the player is killed, asking wether or not he accepts the terms and rules of New Life Rule. But whenever I add the code, it makes the Gamemode unloadable, for some reason. Here’s the code:

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

function acceptance()

frame = vgui.Create (“DFrame”)
frame:SetPos (ScrW() / 2, ScrH() / 2)
frame:SetSize (300, 120)
frame:SetTitle (“New Life Rule”)
frame:SetText (“You died. You only remember your friends, home and job. Do not revenge your death by killing the guy who killed you.”)
frame:SetVisible (true)
frame:SetDraggable (false)
frame:ShowCloseButton (false)
frame:MakePopup()

accept = vgui.Create ("DButton", frame )
accept:SetPos (100, 40)
accept:SetSize (50, 50)
accept:SetText ("Accept!")
accept.DoClick = function()frame:Close() 
	ply:Spawn()		
	end
end

decline = vgui.Create ("DButton", frame )
decline:SetPos (200, 80)
decline:SetSize (50, 50)
decline:SetText ("Decline!")
decline.DoClick = function()frame:Close()
	RunConsoleCommand ("disconnect")
		end
	end

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

This code is supposed to be in cl_init.lua, right?

I dont know if this is right, but if you spot the error/mistake - please write back to me with the correct code/the spotted error.

[Please dont make this to a “LAWLZ i H8S DrakRP, becuase is soks” - I dont care what you think about it]

  • Thank you in advance :: Busymonkey

PlayerDeath is a serverside hook. You will need to use it like this:

init.lua
[lua]
function playerDies( victim, weapon, killer )

victim:ConCommand("OMGIDED")

end

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

cl_init.lua
[lua]
function PlayerDies()
frame = vgui.Create (“DFrame”)
frame:SetPos (ScrW() / 2, ScrH() / 2)
frame:SetSize (300, 120)
frame:SetTitle (“New Life Rule”)
frame:SetText (“You died. You only remember your friends, home and job. Do not revenge your death by killing the guy who killed you.”)
frame:SetVisible (true)
frame:SetDraggable (false)
frame:ShowCloseButton (false)
frame:MakePopup()

accept = vgui.Create ("DButton", frame )  
accept:SetPos (100, 40)  
accept:SetSize (50, 50)  
accept:SetText ("Accept!")  
accept.DoClick = function()
    frame:Close()      
end 
  
decline = vgui.Create ("DButton", frame )  
decline:SetPos (200, 80)  
decline:SetSize (50, 50)  
decline:SetText ("Decline!")  
decline.DoClick = function()frame:Close()  
    RunConsoleCommand ("disconnect")  
end

end

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

Thanks a bunch. I would never have figured that out by myself! :slight_smile:

  • Case closed :smiley:

EDIT

It didnt work :o

I copy-pasted the thing for init.lua and launched Garrys mod - I died and it gave me a console error: " Unknown Command “OMGIDIED” ".
Then I realized that I forgot copy-pasting the thing for cl_init.lua, so I did - and I got the same result when I tried - It crashes the Gamemode.

So, thread is still open for solutions :o

EDIT

This is the error Im getting:

[lua]
DarkRP/gamemode/cl_init.lua:1066: ‘end’ expected (to close ‘function’ at line 1038) near ‘<eof>’



********** COULDN’T LOAD GAMEMODE!! **********



There was a problem opening the gamemode file ‘DarkRP/gamemode/cl_init.lua’

Registering gamemode ‘DarkRP’ derived from ‘base’
Couldn’t include file ‘shared.lua’ (File not found)[/lua]

and I’m getting spammed with this:

[lua]Warning: Unhandled usermessage ‘FRecieveGlobalInt’
Warning: Unhandled usermessage ‘FRecieveGlobalInt’
Warning: Unhandled usermessage ‘FRecieveGlobalInt’
Warning: Unhandled usermessage ‘FRecieveGlobalInt’
Warning: Unhandled usermessage ‘FRecieveGlobalInt’
Warning: Unhandled usermessage ‘FRecieveGlobalInt’
Warning: Unhandled usermessage ‘FRecieveGlobalInt’
Warning: Unhandled usermessage ‘DarkRP_Chat’[/lua]

Put an extra ‘end’ before [lua]concommand.Add(“OMGIDED”, PlayerDies)[/lua]

Yeah, was in a rush. Updated my post.