TTT Kill Revealer

Hey guys :slight_smile:

I was just looking for a Kill Revealer that works something like this!

Like the one that does the following:

When you die by an innocent it will say:

You were killed by playername(GREEN).

When you die by a traitor it will say:

You were killed by playername(RED).

When you die by a detective it will say:

You were killed by playername(BLUE).

Thanks guys, helpful answers are highly appreciated! :slight_smile:

These are perfect scripts for you to do yourself, because it’s not big enough to fail due to bad code.

Here are some resources to get you started :

Wiki : www.wiki.garrysmod.com
PIL : www.lua.org/pil/

Player death hook : http://wiki.garrysmod.com/page/GM/PlayerDeath
Chat print function : http://wiki.garrysmod.com/page/chat/AddText

You can get a player’s role with :

[lua]
ply:GetRole()
[/lua]

For example, to check if they’re a traitor :

[lua]
if ( ply:GetRole() == ROLE_TRAITOR ) then … end
[/lua]

Ok thanks bro, i will ask my awesome dev to try it out :slight_smile:

btw…

If anyone has any pre made ones to save him some time please post ! :slight_smile:

Hardly awesome if he can’t code a simple thing such as printing a message on a hook.

Well SORRY if it’s the first time that i use that types of things?

That’s why there is a wiki.

I assume you never made a Hello World script?

[lua]
if SERVER then
util.AddNetworkString(“TTTChatText”)
local grey = Color(150,150,150)
local dark grey = Color(200,200,200)
local white = Color(255,255,255) – undescriptive variable and function names
local red = Color(255,0,0) – make reading the code a pain in the ass
local green = Color(0,255,0) – please name your variables and functions
local blue = Color(0,0,255) – properly
local black = Color(0,0,0)

--- Obv not my code really because I didn't feel like rewriting what I wanted before.
-- add/remove weapons in the table as you wish, because you might not have some that are in the table therefore they won't spawn. EG MP5/ETC


-- gay

-- WHO KILLED WHO 
function TraitorKiller( v,w,k)
    local colour = ""
    local message = "You were killed by"
    local name = ""
    
    if k == v then
            message = "You killed yourself"
            white = Color(255,255,0)
        else
            if k:IsPlayer() then
                name = " "..k:Nick()
                
                if k:IsRole(ROLE_TRAITOR) then 
                    colour = Color(255,0,0)
                elseif k:IsRole(ROLE_INNOCENT) then 
                    colour = Color(0,255,0)
                elseif k:IsRole(ROLE_DETECTIVE) then 
                    colour = Color(0,0,255)
                end
            else
                name = " the world"
                white = Color(255,255,0)
            end
    end
    net.Start("TTTChatText")
        net.WriteTable({grey,"[",Color(0,0,255),"wD TTT Killer",grey,"]",Color(255,255,255),": ",white,message,colour,name,white,"!"})
    net.Send(v)
end
hook.Add("PlayerDeath", "TraitorKiller", TraitorKiller)
-- uguu

end
if CLIENT then
net.Receive(“TTTChatText”,function()
local tbl = net.ReadTable()
if tbl != nil then
chat.AddText(unpack(tbl))
else
print(“Empty table received! --debug”)
end
end)
end

/*

this is compatible with hatschat chatbox fyi

*/[/lua]

Or something more simply like this:
http://forum.facepunch.com/showthread.php?t=1269677&p=40632441&viewfull=1#post40632441



function TTTDeath(ply, attacker, dmginfo)
	local role_color = {
	   [ROLE_TRAITOR]   = Color(255,0,0,255),
	   [ROLE_INNOCENT]  = Color(0,255,0,255),
	   [ROLE_DETECTIVE] = Color(0,0,255,255)
	}
    if IsValid(attacker) and attacker:IsPlayer() then
        ply:ChatPrint(role_color[attacker:GetRole()],"You were killed by "..attacker:Nick().." who is a"..attacker:GetRoleString()..".")
    end
end
hook.Add("DoPlayerDeath", "TTTDeaths", TTTDeath)


^ The above would print
“You were killed by Pandaman09 who is a Detective.”(In blue)