• Testing if player was killed by the server?
    2 replies, posted
Hey everyone. I have a function that is hooked with the "GM:PlayerDeath" In the function, I want something to happen dependent on who killed the player. But I don't want that something to happen, if the player was killed by the server (ply:Kill()) How can I test for that? Any help is appreciated :D - Fillipuster
[lua] hook.Add("DoPlayerDeath", "SomePlayerDeathThing", function(ply, killer, dmginfo) if !IsValid(killer) or !killer:IsPlayer() or !IsValid(ply) or !ply:IsPlayer() then return end for k,v in pairs(player.GetAll()) do if (ply == killer) then PrintMessage( HUD_PRINTCONSOLE, "[INFO] ".. ply:Nick() .." (".. ply:SteamID() ..") suicided!") else PrintMessage( HUD_PRINTCONSOLE, "[INFO] ".. killer:Nick() .." (".. killer:SteamID() ..") killed ".. ply:Nick() .." (".. ply:SteamID() ..") !") end end end) [/lua] Something I quickly threw together. Bassicly, it prints in the console who was killed by who, and if the player is the killer, it would say he suicided.
[QUOTE=Lolm4te;45599285][lua] hook.Add("DoPlayerDeath", "SomePlayerDeathThing", function(ply, killer, dmginfo) if !IsValid(killer) or !killer:IsPlayer() or !IsValid(ply) or !ply:IsPlayer() then return end for k,v in pairs(player.GetAll()) do if (ply == killer) then PrintMessage( HUD_PRINTCONSOLE, "[INFO] ".. ply:Nick() .." (".. ply:SteamID() ..") suicided!") else PrintMessage( HUD_PRINTCONSOLE, "[INFO] ".. killer:Nick() .." (".. killer:SteamID() ..") killed ".. ply:Nick() .." (".. ply:SteamID() ..") !") end end end) [/lua] Something I quickly threw together. Bassicly, it prints in the console who was killed by who, and if the player is the killer, it would say he suicided.[/QUOTE] if ply == killer returns true if the player suicides. But if the player is killed by the server (ply:Kill()) will it then also count as suicide?
Sorry, you need to Log In to post a reply to this thread.