• Chat Tag doesn't work
    7 replies, posted
Okay this is the code: [lua]local function AddToChat(msg) local col1 = Color(msg:ReadShort(), msg:ReadShort(), msg:ReadShort()) local name = msg:ReadString() local ply = msg:ReadEntity() local col2 = Color(msg:ReadShort(), msg:ReadShort(), msg:ReadShort()) local text = msg:ReadString() if text and text ~= "" then if ply and ply:IsValid() and ply:IsPlayer() and ply:IsAdmin() then chat.AddText(col1, name, Color(0, 155, 0, 255), " (ADMIN) ", col2, ": "..text) else chat.AddText(col1, name, col2, ": "..text) end if ply and ply:IsValid() then hook.Call("OnPlayerChat", GM, ply, text, false, ply:Alive()) end else chat.AddText(col1, name) hook.Call("ChatText", GM, "0", name, "", "none") end chat.PlaySound() end usermessage.Hook("DarkRP_Chat", AddToChat)[/lua] The problem is that it replace the player's name with (ADMIN) instead of adding the tag next to the name. What exactly is the problem since I am too dumb enough to not see?
[lua]local function AddToChat(msg) local col1 = Color(msg:ReadShort(), msg:ReadShort(), msg:ReadShort()) local name = msg:ReadString() local ply = msg:ReadEntity() local col2 = Color(msg:ReadShort(), msg:ReadShort(), msg:ReadShort()) local text = msg:ReadString() if text and text ~= "" then if ply and ply:IsValid() and ply:IsPlayer() and ply:IsAdmin() then chat.AddText(col1, name, Color(0, 155, 0, 255), " (ADMIN) " .. ply:Nick() .., col2, ": "..text) else chat.AddText(col1, name, col2, ": "..text) end if ply and ply:IsValid() then hook.Call("OnPlayerChat", GM, ply, text, false, ply:Alive()) end else chat.AddText(col1, name) hook.Call("ChatText", GM, "0", name, "", "none") end chat.PlaySound() end usermessage.Hook("DarkRP_Chat", AddToChat)[/lua] Try this I guess, might not work though.
Doesn't work and I also want the admin tag to be after the player name.
Bump.
Anyone?
[QUOTE=Mr Ibizza;42348135]Anyone?[/QUOTE] If you want I can help you threw steam. Steam: [url]http://steamcommunity.com/id/forsakenspade14[/url]
[QUOTE=kArp19;42412457]If you want I can help you threw steam. Steam: [url]http://steamcommunity.com/id/forsakenspade14[/url][/QUOTE] Why don't you just help them here instead?
[QUOTE][CODE] if text and text ~= "" then if ply and ply:IsValid() and ply:IsPlayer() and ply:IsAdmin() then chat.AddText(col1, name, Color(0, 155, 0, 255), " (ADMIN) ", col2, ": "..text) else chat.AddText(col1, name, col2, ": "..text) end[/CODE][/QUOTE] Try changing this to: [CODE] if text and text ~= "" then if ply and ply:IsValid() and ply:IsPlayer() and ply:IsAdmin() then chat.AddText(col1, name, ply:GetName(), Color(0, 155, 0, 255), " (ADMIN) ", col2, ": "..text) else chat.AddText(col1, name, col2, ": "..text) end[/CODE]
Sorry, you need to Log In to post a reply to this thread.