[lua]
local killmsg = {}
killmsg.chatcolor = Color(255,255,255,255)
killmsg.namecolor = Color(255,255,0,255)
killmsg.detective = Color(0,171,255,200)
killmsg.traitor = Color(206,0,0,0)
killmsg.innocent = Color(0,183,27,129)
killmsg.damage = Color(225,0,0,129)
net.Receive("killmessages", function()
local atk = net.ReadEntity()
local role = net.ReadString()
if role == "world" then
chat.AddText(killmsg.chatcolor, "You were killed by the world.")
elseif atk:IsValid() && atk:Nick() == LocalPlayer():Nick() then
chat.AddText(killmsg.chatcolor, "You managed to kill yourself.")
elseif role == "traitor" then
chat.AddText(killmsg.chatcolor, "You were killed by ", killmsg.namecolor, atk:Nick(), killmsg.chatcolor,". Role: ", killmsg.traitor, "T")
chat.AddText(killmsg.chatcolor, "He had ", killmsg.damage, atk:Health())
chat.AddText(killmsg.chatcolor, "And was using a ", killmsg.damage, atk:GetActiveWeapon())
elseif role == "detective" then
chat.AddText(killmsg.chatcolor, "You were killed by ", killmsg.namecolor, atk:Nick(), killmsg.chatcolor,". Role: ", killmsg.detective, "Detective")
chat.AddText(killmsg.chatcolor, "He had ", killmsg.damage, atk:Health())
chat.AddText(killmsg.chatcolor, "And was using a ", killmsg.damage, atk:GetActiveWeapon())
elseif role == "innocent" then
chat.AddText(killmsg.chatcolor, "You were killed by ", killmsg.namecolor, atk:Nick(), killmsg.chatcolor, ". Role: ", killmsg.innocent, "Inno")
chat.AddText(killmsg.chatcolor, "He had ", killmsg.damage, atk:Health())
chat.AddText(killmsg.chatcolor, "And was using a ", killmsg.damage, atk:GetActiveWeapon())
else
chat.AddText(killmsg.chatcolor, "You shouldnt see this. Please contact the coder to solve the problem.")
end
end)
[/lua]
Everything else works fine except for health. No idea why it is not displaying it.
[lua]
if SERVER then
util.AddNetworkString("killmessages")
hook.Add("PlayerDeath", "KillMessage", function(vic, inf, atk)
net.Start("killmessages")
net.WriteEntity(atk)
print(atk)
if IsValid(atk) && atk:IsPlayer() then
net.WriteString(atk:GetRoleString())
else
net.WriteString("world")
end
net.Send(vic)
end)
end
[/lua]
Server side if anyone cares.
maybe try
[lua]net.WriteInt(atk:Health())[/lua]
[QUOTE=KTBM;49351617]maybe try
[lua]net.WriteInt(atk:Health())[/lua][/QUOTE]
you forgot the bit count for int.
[QUOTE=tzahush;49352046]you forgot the bit count for int.[/QUOTE]
So i Would need to add net.WriteInt(atk:Health()) to the server side lua?
[QUOTE=Ztiep;49352281]So i Would need to add net.WriteInt(atk:Health()) to the server side lua?[/QUOTE]
Yes in the server side lua
like so
[lua]net.WriteInt(atk:Health(), 16)[/lua]
[QUOTE=KTBM;49352508]Yes in the server side lua
like so
[lua]net.WriteInt(atk:Health(), 16)[/lua][/QUOTE]
Nope just tested it and now nothing will show up
show me the new code
[QUOTE=KTBM;49354412]show me the new code[/QUOTE]
[lua]
if SERVER then
util.AddNetworkString("killmessages")
hook.Add("PlayerDeath", "KillMessage", function(vic, inf, atk)
net.Start("killmessages")
net.WriteEntity(atk)
net.WriteInt(atk:Health(), 16)
print(atk)
if IsValid(atk) && atk:IsPlayer() then
net.WriteString(atk:GetRoleString())
else
net.WriteString("world")
end
net.Send(vic)
end)
end
[/lua]
and the client side code
[QUOTE=KTBM;49354604]and the client side code[/QUOTE]
client is still the same as in the first post.
You'll need to add
[lua]local hp = net.ReadInt(16)[/lua]
after
[lua]local role = net.ReadString()[/lua]
and instead of doing [lua]chat.AddText(atk:Health)[/lua]
you'll need to do
[lua]chat.Addtext(hp)[/lua]
[QUOTE=KTBM;49354660]You'll need to add
[lua]local hp = net.ReadInt(16)[/lua]
after
[lua]local role = net.ReadString()[/lua]
and instead of doing [lua]chat.AddText(atk:Health)[/lua]
you'll need to do
[lua]chat.Addtext(hp)[/lua][/QUOTE]
Nope still nothing
Alright I found your problem
chat.AddText doesn't read integers like HP
so to convert HP to a string you must do
[lua]local hp = tostring(net.ReadInt(16))[/lua]
[QUOTE=KTBM;49357784]Alright I found your problem
chat.AddText doesn't read integers like HP
so to convert HP to a string you must do
[lua]local hp = tostring(net.ReadInt(16))[/lua][/QUOTE]
So got something but it is always returning
He had 1569
Sorry, you need to Log In to post a reply to this thread.