Ulysses
General => Off-Topic => Topic started 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
-
A simple google search found one.
http://forums.ulyssesmod.net/index.php?topic=6059.0
-
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.
-
Bender also has his own website, http://www.bendersvilla.net/
And can be found on Steam here. http://steamcommunity.com/profiles/76561198023178705
-
Untested, but this should work.
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
-
Untested, but this should work.
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?
-
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.
-
Well It didn't work. Bad luck i guess
-
Hey, this is what I use, I thought I could share it with you :)
Put this into lua/autorun/server/killmsg.lua
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
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.
-
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
-
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)
-
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.