Author Topic: TTT Kill Revealer  (Read 11045 times)

0 Members and 1 Guest are viewing this topic.

Offline MrSpencer

  • Newbie
  • *
  • Posts: 6
  • Karma: 0
TTT Kill Revealer
« on: September 02, 2013, 03:27:07 AM »
I seen another Post on this but the download link doesnt work anymore. I need one really badly, that says You where killed by <name> He was Innocent or Traitor Or Detective Someone please help

Offline aaron

  • Newbie
  • *
  • Posts: 14
  • Karma: 1
Re: TTT Kill Revealer
« Reply #1 on: September 02, 2013, 09:37:22 AM »

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: TTT Kill Revealer
« Reply #2 on: September 02, 2013, 12:18:59 PM »
Aaron, that link 404'ed.
Thanks for directing him to google though!

MrSpencer, bender's pretty active around these forums.
If you can't find anything working using the search, perhaps reply to that post or another involving any TTT item you're looking for.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline LuaTenshi

  • Hero Member
  • *****
  • Posts: 545
  • Karma: 47
  • Just your ordinary moon angel!
    • Mirai.Red
Re: TTT Kill Revealer
« Reply #3 on: September 02, 2013, 12:39:34 PM »
Bender also has his own website, http://www.bendersvilla.net/

And can be found on Steam here. http://steamcommunity.com/profiles/76561198023178705
I cry every time I see that I am not a respected member of this community.

Offline iSnipeu

  • Jr. Member
  • **
  • Posts: 83
  • Karma: 12
Re: TTT Kill Revealer
« Reply #4 on: September 03, 2013, 02:00:21 AM »
Untested, but this should work.

Code: [Select]
if SERVER then
util.AddNetworkString("WhoKilled")
hook.Add("PlayerDeath", "WhoKilled", function( victim, weapon, killer )
net.Start("WhoKilled")
net.WriteString( (killer:IsPlayer() and killer:Nick() or "the world") )
net.WriteInt( (killer:IsPlayer() and killer:GetRole() or -1), 8 )
net.Send( victim )
end)
else
net.Receive("WhoKilled", function()
local killer = net.ReadString()
local killer_role = net.ReadInt(8)

local str = "You were killed by "..killer.."!"
if killer_role == ROLE_INNOCENT then
chat.AddText( Color(0,255,0), str )
elseif killer_role == ROLE_TRAITOR then
chat.AddText( Color(255,0,0), str )
elseif killer_role == ROLE_DETECTIVE then
chat.AddText( Color(0,0,255), str )
else
chat.AddText( Color(255,255,0), str )
end
end)
end
« Last Edit: September 05, 2013, 06:07:00 PM by iSnipeu »

Offline MrSpencer

  • Newbie
  • *
  • Posts: 6
  • Karma: 0
Re: TTT Kill Revealer
« Reply #5 on: September 03, 2013, 03:02:32 AM »
Untested, but this should work.

Code: [Select]
if SERVER then
util.AddNetworkString("WhoKilled")
hook.Add("PlayerDeath", "WhoKilled", function( victim, weapon, killer )
net.Start("WhoKilled")
net.WriteString( (killer:IsPlayer() and killer:Nick() or "the world") )
net.WriteInt( (killer:IsPlayer() and killer:GetRole() or -1) )
net.Send( victim )
end)
else
net.Receive("WhoKilled", function()
local killer = net.ReadString()
local killer_role = net.ReadInt()

local str = "You were killed by "..killer.."!"
if killer_role == ROLE_INNOCENT then
chat.AddText( Color(0,255,0), str )
elseif killer_role == ROLE_TRAITOR then
chat.AddText( Color(255,0,0), str )
elseif killer_role == ROLE_DETECTIVE then
chat.AddText( Color(0,0,255), str )
else
chat.AddText( Color(255,255,0), str )
end
end)
end

Where should i place this?

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: TTT Kill Revealer
« Reply #6 on: September 03, 2013, 02:22:35 PM »
Where should i place this?
Opinion;
As a server admin, even one who will never learn how to code in a game's way of interaction with the game, the admin should learn the basics of where/what/how the server does things on the back end.
I will tell the answer to your question, in great hopes you'll remember it, experiment with answers like it in the future, and, I pray, teach your fellow server want-to-be-better hosts where pieces of code, for, at least in this respect, Gmod, go.

Fact:
Shut down server.
You copy the code.
Open up notepad.
Paste the code.
Save it to <your Gmod server path>\lua\autorun\anyfilename_perhaps_tttkillreveal.lua

You'll need to figure out how to save in .lua and not .txt on your own.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline MrSpencer

  • Newbie
  • *
  • Posts: 6
  • Karma: 0
Re: TTT Kill Revealer
« Reply #7 on: September 05, 2013, 12:11:47 AM »
Well It didn't work. Bad luck i guess

Offline sabo

  • Full Member
  • ***
  • Posts: 136
  • Karma: 2
  • Hello :)
    • The Elite Gaming
Re: TTT Kill Revealer
« Reply #8 on: September 05, 2013, 07:20:52 AM »
Hey, this is what I use, I thought I could share it with you :)

Put this into lua/autorun/server/killmsg.lua

Code: [Select]
AddCSLuaFile("autorun/client/cl_killmsg.lua")
print("Kill message script loaded!, continuing happily!")

function PrintKillMsgOnDeath(victim, wep, attacker)
if GetRoundState() == ROUND_ACTIVE then
if (attacker:IsPlayer()) and (attacker ~= victim) and attacker:IsTraitor() then
umsg.Start("KillMsg", victim)
umsg.String(attacker:Nick())
umsg.Char(2)
umsg.End()
end
if (attacker:IsPlayer()) and (attacker ~= victim) and attacker:IsDetective() then
umsg.Start("KillMsg", victim)
umsg.String(attacker:Nick())
umsg.Char(3)
umsg.End()
end
if (attacker:IsPlayer()) and (attacker ~= victim) and !attacker:IsDetective() and !attacker:IsTraitor() then
umsg.Start("KillMsg", victim)
umsg.String(attacker:Nick())
umsg.Char(1)
umsg.End()
end
end
end

hook.Add("PlayerDeath", "ChatKillMsg", PrintKillMsgOnDeath)

And put this into lua/autorun/client/cl_killmsg.lua

Code: [Select]
print("Kill message script loaded!")
local teamslist = {" innocent.", " traitor.", " detective."}
local teamscolors = {Color(0, 200, 0, 255), Color(180, 50, 40, 255), Color(50, 60, 180, 255)}

function PrintKillMsg(um)
local nick = um:ReadString()
local team = um:ReadChar()
chat.AddText(Color(255, 255, 255), "You were killed by ", teamscolors[team], nick, Color(255, 255, 255), ", he was a", teamscolors[team], teamslist[team])
end

usermessage.Hook("KillMsg", PrintKillMsg)

Hope this helps ;)

Good luck.

Offline MrSpencer

  • Newbie
  • *
  • Posts: 6
  • Karma: 0
Re: TTT Kill Revealer
« Reply #9 on: September 05, 2013, 03:42:42 PM »
My players are getting a client error: I looked through the file and didn't see and ) out of place?

[Sir Noname|37|STEAM_0:1:63862704] Lua Error:

[ERROR] lua/autorun/client/cl_killmsg.lua:3: ')' expected near '3'
1. unknown - lua/autorun/client/cl_killmsg.lua:0


Offline iSnipeu

  • Jr. Member
  • **
  • Posts: 83
  • Karma: 12
Re: TTT Kill Revealer
« Reply #10 on: September 05, 2013, 06:04:23 PM »
Well It didn't work. Bad luck i guess

What error did you get?

EDIT: Oh I forgot to include the bit count, try it again now (put into lua/autorun)
« Last Edit: September 05, 2013, 06:08:00 PM by iSnipeu »

Offline sabo

  • Full Member
  • ***
  • Posts: 136
  • Karma: 2
  • Hello :)
    • The Elite Gaming
Re: TTT Kill Revealer
« Reply #11 on: September 07, 2013, 04:31:36 PM »
My players are getting a client error: I looked through the file and didn't see and ) out of place?

[Sir Noname|37|STEAM_0:1:63862704] Lua Error:

[ERROR] lua/autorun/client/cl_killmsg.lua:3: ')' expected near '3'
1. unknown - lua/autorun/client/cl_killmsg.lua:0

You should consider setting up your server again.

Looks like an addon you have added is conflicting it because I am using the exact code I gave you on my server and I never had that problem.