[QUOTE=Fantym420;28626001]for the color edit the color values they go red, green, blue change the amounts to get different colors, 0 is black and 255 full color. As far as adding more you could just copy the if statement and change the group and the text it's adding.[/QUOTE]
Alright so it uses RGB colors, Ok im gonna take a look in it, and hey, thank you very much man for helping me out :D Much appreciated :D
Edit:
Only 1 question, This codes are in the same LUA file, I dont have to change the function/hook or have I?
[lua]
hook.Add("OnPlayerChat","SuperAdminTag",function(ply, txt, team, dead)
local chat2 = {}
if ply:IsUserGroup("owner") then
table.insert(chat2, Color(87,83,87))
table.insert(chat2,"[Owner] ")
end
table.insert(chat2,Color(87,83,87))
table.insert(chat2,ply:Nick()..": ")
table.insert(chat2,Color(225,225,225))
table.insert(chat2,txt)
print("Chat function is being called, something else is wrong.")
chat.AddText(unpack(chat2))
return true
end)
hook.Add("OnPlayerChat","SuperAdminTag",function(ply, txt, team, dead)
local chat2 = {}
if ply:IsUserGroup("superadmin") then
table.insert(chat2, Color(234,27,6))
table.insert(chat2,"[SuperAdmin] ")
end
table.insert(chat2,Color(234,27,6))
table.insert(chat2,ply:Nick()..": ")
table.insert(chat2,Color(225,225,225))
table.insert(chat2,txt)
print("Chat function is being called, something else is wrong.")
chat.AddText(unpack(chat2))
return true
end)
[/lua]
Edit: Changed it, hope this works:
[lua]
hook.Add("OnPlayerChat","SuperAdminTag",function(ply, txt, team, dead)
local chat2 = {}
if ply:IsUserGroup("owner") then
table.insert(chat2, Color(87,83,87))
table.insert(chat2,"[Owner] ")
end
table.insert(chat2,Color(87,83,87))
table.insert(chat2,ply:Nick()..": ")
table.insert(chat2,Color(225,225,225))
table.insert(chat2,txt)
print("Chat function is being called, something else is wrong.")
chat.AddText(unpack(chat2))
if ply:IsUserGroup("superadmin") then
table.insert(chat2, Color(234,27,6))
table.insert(chat2,"[SuperAdmin] ")
end
table.insert(chat2,Color(234,27,6))
table.insert(chat2,ply:Nick()..": ")
table.insert(chat2,Color(225,225,225))
table.insert(chat2,txt)
print("Chat function is being called, something else is wrong.")
chat.AddText(unpack(chat2))
return true
end)
[/lua]
Edit: The output is dubble, I see my own name grey and red with the [SuperAdmin] Tag for it, maybe i have to recall everytime the function? Like i had in my first edit?
[editline]16th March 2011[/editline]
The dubble code dont work either
Just trying a different way of doing that myself, and also. Wouldn't it be wise to have a [lua]table.Empty(chat2)[/lua] at the end?
[editline]16th March 2011[/editline]
Ok here ya go, this works.
[lua]
hook.Add("OnPlayerChat","SuperAdminTag",function(ply, txt, team, dead)--Hook to catch the Input
local chat2 = {} //Make a table for the String
if ply:IsUserGroup("superadmin") then --If Superadmin
table.insert(chat2, Color(255,0,0))--Colour of the Tag
table.insert(chat2,"[SA] ")--Tag String
end--end the if
if ply:IsUserGroup("admin") then--If admin
table.insert(chat2, Color(0,255,0))--Colour of the Tag
table.insert(chat2,"[A] ")--Tag String
end--end the if
table.insert(chat2,Color(255,225,255))--Colour of the ":"
table.insert(chat2,ply:Nick()..": ")--add ": " to our string
table.insert(chat2,Color(225,225,225))--Colour of the actual Message
table.insert(chat2,txt)--Insert the message that was typed into our string
print("Chat function is being called, something else is wrong.")--Debugging
chat.AddText(unpack(chat2))--Addtext to the chatbox using the unpack function on the chat2 table
table.Empty(chat2)--Empty the table (Good Practice)
return true--Return true for Lulz. Not really. It stops there being a double message.
end)
[/lua]
-- EDIT
Commented the code. Hugs?
-- RE-EDIT
[lua] doesn't support // waaaah.
[QUOTE=noforgivin;28632904]Just trying a different way of doing that myself, and also. Wouldn't it be wise to have a [lua]table.Empty(chat2)[/lua] at the end?
[editline]16th March 2011[/editline]
Ok here ya go, this works.
[lua]
hook.Add("OnPlayerChat","SuperAdminTag",function(ply, txt, team, dead)--Hook to catch the Input
local chat2 = {} //Make a table for the String
if ply:IsUserGroup("superadmin") then --If Superadmin
table.insert(chat2, Color(255,0,0))--Colour of the Tag
table.insert(chat2,"[SA] ")--Tag String
end--end the if
if ply:IsUserGroup("admin") then--If admin
table.insert(chat2, Color(0,255,0))--Colour of the Tag
table.insert(chat2,"[A] ")--Tag String
end--end the if
table.insert(chat2,Color(255,225,255))--Colour of the ":"
table.insert(chat2,ply:Nick()..": ")--add ": " to our string
table.insert(chat2,Color(225,225,225))--Colour of the actual Message
table.insert(chat2,txt)--Insert the message that was typed into our string
print("Chat function is being called, something else is wrong.")--Debugging
chat.AddText(unpack(chat2))--Addtext to the chatbox using the unpack function on the chat2 table
table.Empty(chat2)--Empty the table (Good Practice)
return true--Return true for Lulz. Not really. It stops there being a double message.
end)
[/lua]
-- EDIT
Commented the code. Hugs?
-- RE-EDIT
[lua] doesn't support // waaaah.[/QUOTE]
Yes but how do you make, The Tag and the name after it the same color?
Edit: Code dont work the error: [gamemodes/terrortown/gamemode/cl_init:416] ")" expected (to close to "(" at line 392) near "end"
Line 392: [lua]hook.Add("OnPlayerChat","SuperAdminTag",function(ply, txt, team, dead)[/lua]
Line 416: [lua]end)[/lua]
[lua]
hook.Add("OnPlayerChat","SuperAdminTag",function(ply, txt, team, dead)--Hook to catch the Input
local chat2 = {} //Make a table for the String
if ply:IsUserGroup("superadmin") then --If Superadmin
table.insert(chat2, Color(255,0,0))--Colour of the Tag
table.insert(chat2,"[SA] ")--Tag String
end--end the if
if ply:IsUserGroup("admin") then--If admin
table.insert(chat2, Color(0,255,0))--Colour of the Tag
table.insert(chat2,"[A] ")--Tag String
end--end the if
if ply:IsUserGroup("superadmin") then
table.insert(chat2,Color(255,0,0))--Colour of the ":"
table.insert(chat2,ply:Nick()..": ")--add ": " to our string
end
if ply:IsUserGroup("admin") then
table.insert(chat2,Color(0,255,0))--Colour of the ":"
table.insert(chat2,ply:Nick()..": ")--add ": " to our string
end
table.insert(chat2,Color(225,225,225))--Colour of the actual Message
table.insert(chat2,txt)--Insert the message that was typed into our string
print("Chat function is being called, something else is wrong.")--Debugging
chat.AddText(unpack(chat2))--Addtext to the chatbox using the unpack function on the chat2 table
table.Empty(chat2)--Empty the table (Good Practice)
return true--Return true for Lulz. Not really. It stops there being a double message.
end)
[/lua]
Like that, think next time.
[QUOTE=noforgivin;28633649][lua]
hook.Add("OnPlayerChat","SuperAdminTag",function(ply, txt, team, dead)--Hook to catch the Input
local chat2 = {} //Make a table for the String
if ply:IsUserGroup("superadmin") then --If Superadmin
table.insert(chat2, Color(255,0,0))--Colour of the Tag
table.insert(chat2,"[SA] ")--Tag String
end--end the if
if ply:IsUserGroup("admin") then--If admin
table.insert(chat2, Color(0,255,0))--Colour of the Tag
table.insert(chat2,"[A] ")--Tag String
end--end the if
if ply:IsUserGroup("superadmin") then
table.insert(chat2,Color(255,0,0))--Colour of the ":"
table.insert(chat2,ply:Nick()..": ")--add ": " to our string
end
if ply:IsUserGroup("admin") then
table.insert(chat2,Color(0,255,0))--Colour of the ":"
table.insert(chat2,ply:Nick()..": ")--add ": " to our string
end
table.insert(chat2,Color(225,225,225))--Colour of the actual Message
table.insert(chat2,txt)--Insert the message that was typed into our string
print("Chat function is being called, something else is wrong.")--Debugging
chat.AddText(unpack(chat2))--Addtext to the chatbox using the unpack function on the chat2 table
table.Empty(chat2)--Empty the table (Good Practice)
return true--Return true for Lulz. Not really. It stops there being a double message.
end)
[/lua]
Like that, think next time.[/QUOTE]
Yeah this works perfect for people who are in a group, but people who are not in a group, their name dont show up, only white letters when they write something?
Add a section for usergroup user
[QUOTE=noforgivin;28633989]Add a section for usergroup user[/QUOTE]
Yeah works now, thank you very much :D
No problem, i have it on my server, It sets colors of teams if your TEAM_DEATH or TEAM_RUN lol
[QUOTE=noforgivin;28634329]No problem, i have it on my server, It sets colors of teams if your TEAM_DEATH or TEAM_RUN lol[/QUOTE]
Ah ok, yeah but with radio commands it dont work, but thats not really important so ill let that out :D
Thanks again :)
radio commands?
[QUOTE=noforgivin;28634417]radio commands?[/QUOTE]
Yeah with TTT you can put a key what binds "suitzoom" and when u press that key u get a little menu where are shortcuts with "im with [name]" or "[name] is a traitor!" thats still default color, but not really important :D
Yeah, you could probably edit it.
[QUOTE=noforgivin;28634676]Yeah, you could probably edit it.[/QUOTE]
Well I have no idea how, but nevermind it, its not that important :D
Well you could find the Part of the gamemode which sends those text messages, then add on a tag to them.
[QUOTE=noforgivin;28634877]Well you could find the Part of the gamemode which sends those text messages, then add on a tag to them.[/QUOTE]
Thats this
[lua]
--- Radio
RADIO = {}
RADIO.Show = false
RADIO.StoredTarget = {nick="", t=0}
RADIO.LastRadio = {msg="", t=0}
-- [key] -> command
RADIO.Commands = {
{cmd="yes", text="quick_yes", format=false},
{cmd="no", text="quick_no", format=false},
{cmd="help", text="quick_help", format=false},
{cmd="imwith", text="quick_imwith", format=true},
{cmd="see", text="quick_see", format=true},
{cmd="suspect", text="quick_suspect", format=true},
{cmd="traitor", text="quick_traitor", format=true},
{cmd="innocent", text="quick_inno", format=true},
{cmd="check", text="quick_check", format=false}
};
[/lua]
And then a few lines under it the code comes:
[lua]
-- Detectives have a blue name, in both chat and radio messages
local function AddDetectiveText(ply, text)
chat.AddText(Color(50, 200, 255),
ply:Nick(),
Color(255,255,255),
": " .. text)
end
[/lua]
So yeah its strange why it dint work in the first place
Meh, idk, Make a backup, mess around.
[QUOTE=noforgivin;28635154]Meh, idk, Make a backup, mess around.[/QUOTE]
Hmm I might do that but i have no clue where to start, i think ill keep it this way, most of the times people dont use the radio commands anyways, but its still strange that the detective code works, while i have it different now, but yeah, Never mind that :D
Radio commands in TTT are sent via a usermessage so they can be translated if the server is using a different language.
He made a hook for them:
[quote][b]TTTPlayerRadioCommand (ply, cmd_name, cmd_target)[/b]
[i]Server[/i]
Called when a player tries to use a quickchat/radio command. If this hook returns true, the command will not be sent, ie. it will get blocked. You can use this for anti-spam measures or to replace or modify a message. The "ply" parameter is of course the player using the command, "cmd_name" is the identifier of the command (such as "quick_yes" for the "Yes." command), and "cmd_target" is the target part of the command (an entity index if it's a player or identified corpse, an identifier like "quick_nobody" if not).[/quote]
Not quite sure how you would modify the output using this, but you can mess around.
Oh yeah 1 last question about the colored chat names, when players are dead they go to spectate mode, but when your dead it doesnt show *DEAD*[tag][name]: [txt] like it did before i had this, any solutions for this? Thanks :D
[lua]
local grouptags = {}
grouptags['superadmin'] = {"[SA]",Color(75,225,75),Color(175,225,175)}
grouptags['admin'] = {"[Admin]",Color(225,75,75),Color(225,175,175)}
hook.Add("OnPlayerChat","SuperAdminTag",function(ply, txt, team, dead)
local chat2 = {}
local f = false
local col2 = nil
for a,b in pairs(grouptags) do
if ply:IsUserGroup(a) then
f = true
col2 = b[3] or Color(225,225,225)
table.insert(chat2,b[2])
table.insert(chat2,b[1].." ")
end
end
if !f then
table.insert(chat2,Color(200,200,200))
table.insert(chat2,"[User] ")
end
if !dead then
table.insert(chat2,col2)
table.insert(chat2,ply:Nick()..": ")
table.insert(chat2,Color(225,225,225))
table.insert(chat2,txt)
else
table.insert(chat2,Color(50,200,200))
table.insert(chat2,"[Dead] "..ply:Nick()..": ")
table.insert(chat2,Color(90,50,50))
table.insert(chat2,txt)
end
chat.AddText(unpack(chat2))
return true
end)
[/lua]
To add a grouptag use the following format..
[code]
grouptags[usergroup] = {tag,tagcolor,namecolor}
[/code]
An example..
[code]
grouptags['superadmin'] = {"[SA]",Color(75,225,75),Color(175,225,175)}
[/code]
Alright but this line,
[lua]
if !f then
table.insert(chat2,Color(200,200,200))
table.insert(chat2,"[User] ")
end
[/lua]
Is that for people who are Not in a group? Or do I have to add in usergroups still "user" ?
You can overwrite the default usergroup, so you can still add the tag user with a different.
Thats just to catch any people without tags.
Looks.. interresting :D
Goodluck with the TTT Server :)
[QUOTE=zzaacckk;28649865]You can overwrite the default usergroup, so you can still add the tag user with a different.
Thats just to catch any people without tags.[/QUOTE]
Yes this is perfect :D
Thank you so much man, really appreciated for helping me out ^^
[QUOTE=Fantym420;28625041]
[lua]
hook.Add("OnPlayerChat","SuperAdminTag",function(ply, txt, team, dead)
local chat2 = {}
if ply:IsUserGroup("superadmin") then
table.insert(chat2, Color(75,225,75))
table.insert(chat2,"[SA] ")
end
[/QUOTE]
Is it possible to change the tag's from [SA] To a Silk Icons?
chat.AddText only supports string. If I am able to see the source of the chat then I would be able to use silk icons instead.
[editline]17th March 2011[/editline]
Because chat.AddText is handled via RunString any code produced to do this would be very unstable.
Sorry, you need to Log In to post a reply to this thread.