• TTT Kill Revealer
    8 replies, posted
Hey guys :) 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! :)
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 : [url]www.wiki.garrysmod.com[/url] PIL : [url]www.lua.org/pil/[/url] Player death hook : [url]http://wiki.garrysmod.com/page/GM/PlayerDeath[/url] Chat print function : [url]http://wiki.garrysmod.com/page/chat/AddText[/url] 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 :) btw.. If anyone has any pre made ones to save him some time please post ! :)
[QUOTE=adnan;40768025]Ok thanks bro, i will ask my awesome dev to try it out :) btw.. If anyone has any pre made ones to save him some time please post ! :)[/QUOTE] Hardly awesome if he can't code a simple thing such as printing a message on a hook.
[QUOTE=tyguy;40768321]Hardly awesome if he can't code a simple thing such as printing a message on a hook.[/QUOTE] Well SORRY if it's the first time that i use that types of things?
[QUOTE=McPherson;40768484]Well SORRY if it's the first time that i use that types of things?[/QUOTE] That's why there is a wiki.
[QUOTE=McPherson;40768484]Well SORRY if it's the first time that i use that types of things?[/QUOTE] 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: [url]http://facepunch.com/showthread.php?t=1269677&p=40632441&viewfull=1#post40632441[/url] [code] 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) [/code] ^ The above would print "You were killed by Pandaman09 who is a Detective."(In blue)
Sorry, you need to Log In to post a reply to this thread.