Ulysses

General => Off-Topic => Topic started by: MrSpencer on September 02, 2013, 03:27:07 AM

Title: TTT Kill Revealer
Post by: MrSpencer 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
Title: Re: TTT Kill Revealer
Post by: aaron on September 02, 2013, 09:37:22 AM
A simple google search found one.

http://forums.ulyssesmod.net/index.php?topic=6059.0
Title: Re: TTT Kill Revealer
Post by: JamminR 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.
Title: Re: TTT Kill Revealer
Post by: LuaTenshi 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
Title: Re: TTT Kill Revealer
Post by: iSnipeu 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
Title: Re: TTT Kill Revealer
Post by: MrSpencer 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?
Title: Re: TTT Kill Revealer
Post by: JamminR 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.
Title: Re: TTT Kill Revealer
Post by: MrSpencer on September 05, 2013, 12:11:47 AM
Well It didn't work. Bad luck i guess
Title: Re: TTT Kill Revealer
Post by: sabo 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.
Title: Re: TTT Kill Revealer
Post by: MrSpencer 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

Title: Re: TTT Kill Revealer
Post by: iSnipeu 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)
Title: Re: TTT Kill Revealer
Post by: sabo 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.