• If ply is ghost
    3 replies, posted
I have a killer notifier setup on my server that I got from workshop, I also have TTT spectator deathmatch on the server. I was fiddling around with the code to try to make it so that if the player is in spectator deathmatch it does not say who you were killed by. Whatever I try I just get errors. Could someone help me out a bit and get me pointed in the right direction. The code for the killer notifier is below, Thanks in advanced. [code] // ____________ ________ ____________ __ // __ ___/_ /______ __________ __/_________ ___ ___/_ // / // _____ \_ __/ __ `/_ ___/_ /_ _ __ \_ |/_/ __ \_ // /_ // ____/ // /_ / /_/ /_ / _ __/ / /_/ /_> < / /_/ //__ __/ // /____/ \__/ \__,_/ /_/ /_/ \____//_/|_| \____/ /_/ // AddCSLuaFile() function timer.Simple(1, function() -- Required to let the gamemode initialize properly if gmod.GetGamemode().Name == "Trouble in Terrorist Town" if SERVER then util.AddNetworkString("tttDeathNotify") hook.Add("PlayerDeath", "TTT_PlayerDeath_SayRole", function(victim, weapon, killer) if killer:IsPlayer() and killer != victim then net.Start("tttDeathNotify") net.WriteInt(1, 4) net.WriteString(killer:GetRoleString()) net.WriteEntity(killer) net.Send(victim) elseif killer:IsPlayer() and killer == victim then net.Start("tttDeathNotify") net.WriteInt(2, 4) net.Send(victim) else net.Start("tttDeathNotify") net.WriteInt(3, 4) net.Send(victim) end end) else local roleColors = { ["traitor"] = Color(200, 25, 25), ["detective"] = Color(25, 25, 200), ["innocent"] = Color(25, 200, 25), ["noround"] = Color(100, 100, 100) } local default = Color(255, 255, 255, 255) net.Receive("tttDeathNotify", function() local killerType = net.ReadInt(4) local role = net.ReadString() local killer = net.ReadEntity() if killerType == 1 then local color = roleColors[role] or roleColors["noround"] local a = "a" if role == "innocent" then a = "an" end chat.AddText(default, "You were killed by ", color, killer:Name(), default, " he was "..a.." ", color, role, default, ".") elseif killerType == 2 then chat.AddText(default, "You were killed by someone called yourself...") elseif killerType == 3 then chat.AddText(default, "You were killed by the world.") end end) end end end)[/code]
I think that there is a network bool for the ghosted players. You can check if the player is in specdm. edit Yeah, the nwbool is SpecDM_Enabled. You can add a check in the first hook.
Player:IsGhost() ?
Could use IsGhost. I don't remember if that was declared locally or not. If not, you can use !victim:GetNWBool("SpecDM_Enabled", false) OP. Maybe should also check killer. Not sure how that will turn out if someone jumped off a building and killed themselves.
Sorry, you need to Log In to post a reply to this thread.