• I WANT THAT MY DERMA PANEL OPEN AFTER A DEATH
    12 replies, posted
So i create i Derma panel and i need help because i don'T know how to make that when the player respawn after a death the panel open can you help me pls
You can add a PlayerDeath hook and use the Net library to network it from server to client. You can also use gameevent.Listen with the event entity_killed. Then check if LocalPlayer() has the same index as the entity that died. I cannot recommend a solution over the other because I have no idea how GameEvents work internally. Good luck!
Can you give me an example because im a beginner in lua code
Here's a fantastic resource to get you started: Garry's Mod Here's another, from the same place: Beginner Tutorial Intro And another, also from the same place: Category No one usually cares to write someone else's code for them, unless you're paying them or you show us you've at least attempted yourself and need help getting it to work.
This would use the PlayerDeath hook with a net library if SERVER then util.AddNetworkString("opendermaondeath") util.AddNetworkString("respawn_ondeath") hook.Add("PlayerDeath", "Open Derma", function( vic, inf, attack ) net.Start("opendermaondeath") net.Send(vic) end) net.Receive("respawn_ondeath", function(len, ply) ply:Respawn() end) else net.Receive("opendermaondeath", function(len) DermaFunction() end) end I am bored and its only a few lines. This uses networking, which will throw you off if you are a new programmer. Place this in lua/autorun and replace the DermaFunction() with the function to open your derma menu. In your respawn derma button (DoClick) you run the code net.Start("respawn_ondeath") net.SendToServer()
if SERVER then util.AddNetworkString("opendermaondeath") util.AddNetworkString("respawn_ondeath") hook.Add("PlayerDeath", "Open Derma", function( vic, inf, attack ) net.Start("opendermaondeath") net.Send(vic) end) local panneau = vgui.Create("DFrame") panneau:SetTitle("                                                             Avez vous ete freekill ?") panneau:SetSize(500,150) panneau:Center() panneau:SetVisible(true) panneau:MakePopup() panneau:ShowCloseButton(false) panneau.Paint = function(s, w, h) -- C'est le contour de la boite qui est noir draw.RoundedBox(5,0,0,w , h,Color(0,0,0)) -- C'est le fond de la boite qui est gris draw.RoundedBox(5,2,2,w-4 , h-4,Color(50,50,50)) end function boutonouiappuyer() RunConsoleCommand("say", "@ J'ai besoin d'aide, j'ai été freekill") end function boutonnonappuyer() panneau:Close() end local boutonoui = vgui.Create("DButton" , panneau) -- Le 50 est sa place a l'horizontal et 40 est sa place a la verticale boutonoui:SetPos(50,40) -- Le 150 c'est sa grosseur a l'horizontal et 70 sa grosseur a la verticale boutonoui:SetSize(150,70) boutonoui:SetText("OUI") boutonoui.DoClick = boutonouiappuyer local boutonnon = vgui.Create("DButton" , panneau) -- Le 300 est sa place a l'horizontal et 40 est sa place a la verticale boutonnon:SetPos(300,40) -- Le 150 c'est sa grosseur a l'horizontal et 70 sa grosseur a la verticale boutonnon:SetSize(150,70) boutonnon:SetText("NON") boutonnon.DoClick = boutonnonappuyer net.Receive("respawn_ondeath", function(len, ply) ply:Respawn() end) else net.Receive("opendermaondeath", function(len) DermaFunction() end) end I made this but it still not working
Derma is in the client realm. You need to move your code to else part of the script. You also are missing the parentheses in the ends of your function calls.
Can you be more claer like what go in what im lost XD
You see where you are creating your DFrames and such? Its in the wrong place. Menus (dermas) are only available to the client. The server has no idea what to do with your derma code. You need to move your menu code to the else part of the if statement. You also need to toggle the menu to be visible instead of creating a new menu every time someone dies. The net receive on the client side of the if statement is the key. You need to toggle the visibility of your derma panel inside of there.
if SERVER then util.AddNetworkString("opendermaondeath") util.AddNetworkString("respawn_ondeath") hook.Add("PlayerDeath", "Open Derma", function( vic, inf, attack ) net.Start("opendermaondeath") net.Send(vic) end)     net.Receive("respawn_ondeath", function(len, ply) ply:Respawn()    end)     else net.Receive("opendermaondeath", function(len) DermaFunction() end)     end) local panneau = vgui.Create("DFrame") panneau:SetTitle("                                                             Avez vous ete freekill ?") panneau:SetSize(500,150) panneau:Center() panneau:SetVisible(true) panneau:MakePopup() panneau:ShowCloseButton(false) panneau.Paint = function(s, w, h) -- C'est le contour de la boite qui est noir draw.RoundedBox(5,0,0,w , h,Color(0,0,0)) -- C'est le fond de la boite qui est gris draw.RoundedBox(5,2,2,w-4 , h-4,Color(50,50,50)) end) function boutonouiappuyer() RunConsoleCommand("say", "@ J'ai besoin d'aide, j'ai été freekill") end) function boutonnonappuyer() panneau:Close() end) local boutonoui = vgui.Create("DButton" , panneau) -- Le 50 est sa place a l'horizontal et 40 est sa place a la verticale boutonoui:SetPos(50,40) -- Le 150 c'est sa grosseur a l'horizontal et 70 sa grosseur a la verticale boutonoui:SetSize(150,70) boutonoui:SetText("OUI") boutonoui.DoClick = boutonouiappuyer local boutonnon = vgui.Create("DButton" , panneau) -- Le 300 est sa place a l'horizontal et 40 est sa place a la verticale boutonnon:SetPos(300,40) -- Le 150 c'est sa grosseur a l'horizontal et 70 sa grosseur a la verticale boutonnon:SetSize(150,70) boutonnon:SetText("NON") boutonnon.DoClick = boutonnonappuyer Like this is it ok
DermaFunction() I put this function here so you would put your derma in that
Please note that I have no idea if this works or not as I am not currently able to test this. --your other server code above else local panneau local function createMenu() panneau = panneau or vgui.Create("DFrame") panneau:SetTitle("Avez vous ete freekill ?") panneau:SetSize(500,150) panneau:Center() panneau:SetVisible(false) panneau:MakePopup() panneau:ShowCloseButton(false) panneau.Paint = function(s, w, h) -- C'est le contour de la boite qui est noir draw.RoundedBox(5,0,0,w , h,Color(0,0,0)) -- C'est le fond de la boite qui est gris draw.RoundedBox(5,2,2,w-4 , h-4,Color(50,50,50)) end local boutonoui = vgui.Create("DButton" , panneau) -- Le 50 est sa place a l'horizontal et 40 est sa place a la verticale boutonoui:SetPos(50,40) -- Le 150 c'est sa grosseur a l'horizontal et 70 sa grosseur a la verticale boutonoui:SetSize(150,70) boutonoui:SetText("OUI") boutonoui.DoClick = function() RunConsoleCommand("say", "@ J'ai besoin d'aide, j'ai été freekill") end local boutonnon = vgui.Create("DButton" , panneau) -- Le 300 est sa place a l'horizontal et 40 est sa place a la verticale boutonnon:SetPos(300,40) -- Le 150 c'est sa grosseur a l'horizontal et 70 sa grosseur a la verticale boutonnon:SetSize(150,70) boutonnon:SetText("NON") boutonnon.DoClick = function() panneau:SetVisible(false) end end net.Receive("opendermaondeath", function(len) if (!panneau) then createMenu() end panneau:SetVisible(true) end) end
If i put this in freekill_call/lua/autorun/cl_fkc.lua is it ok
Sorry, you need to Log In to post a reply to this thread.