Hello, i'am edit addon chat tag for evolve admin mod.
You can download this addon and test it.
[URL="http://www.gamefront.com/files/22717277/AdminTag.rar"]Download for Evolve mod[/URL]
[URL="http://www.gamefront.com/files/22718317/AdminTag+for+ulx.rar"]Download For Ulx[/URL]
Not recommended for TTT servers
Tanks for sharing your work!
Do you know if this will work for TTT and ULX?
Yes =)
Open gamemodes/terrortown/gamemsg.lua and past this code from the my addon file
To gamemsg.lua
[CODE]local ranks = {
["owner"] = Color(255,0,0),
["superadmin"] = Color(100,250,105),
["respected"] = Color(127,255,212),
["donator"] = Color(127,219,255),
["admin"] = Color(255,194,127),
["guest"] = Color(238,221,130)
}
if (SERVER) then
AddCSLuaFile("chat.lua")
function CustomChat_ChatMessage(ply, msg, rank, r, g, b)
umsg.Start("CustomChat_ChatMsg")
umsg.Entity(ply)
umsg.String(msg)
umsg.String(rank)
umsg.Short(r)
umsg.Short(g)
umsg.Short(b)
umsg.End()
end
function CustomChat_Checker(ply, text, teamonly)
local group = ply:EV_GetRank()
local color = ranks[group]
local txtcheck = string.sub(text,1,1)
if txtcheck == "/" then
return text
else
return "", CustomChat_ChatMessage(ply, text, "["..string.upper(string.sub(group,1,1))..string.sub(group,2).."]", color.r, color.g, color.b)
end
end
hook.Add("PlayerSay", "WordCheck", CustomChat_Checker)
else
usermessage.Hook("CustomChat_ChatMsg", function(um)
local ply = um:ReadEntity()
local msg = um:ReadString()
local rank = um:ReadString()
local r = um:ReadShort()
local g = um:ReadShort()
local b = um:ReadShort()
chat.AddText(Color(r, g, b), rank, team.GetColor(ply:Team()), " "..ply:Nick(), Color(255,255,255), ": "..msg)
end)
end[/CODE]
For ulx ttt
[CODE]local ranks = {
["owner"] = Color(255,0,0),
["superadmin"] = Color(100,250,105),
["respected"] = Color(127,255,212),
["donator"] = Color(127,219,255),
["admin"] = Color(255,194,127),
["guest"] = Color(238,221,130)
}
if (SERVER) then
AddCSLuaFile("chat.lua")
function CustomChat_ChatMessage(ply, msg, rank, r, g, b)
umsg.Start("CustomChat_ChatMsg")
umsg.Entity(ply)
umsg.String(msg)
umsg.String(rank)
umsg.Short(r)
umsg.Short(g)
umsg.Short(b)
umsg.End()
end
function CustomChat_Checker(ply, text, teamonly)
local group = ply:GetUserGroup()
local color = ranks[group]
local txtcheck = string.sub(text,1,1)
if txtcheck == "/" then
return text
else
return "", CustomChat_ChatMessage(ply, text, "["..string.upper(string.sub(group,1,1))..string.sub(group,2).."]", color.r, color.g, color.b)
end
end
hook.Add("PlayerSay", "WordCheck", CustomChat_Checker)
else
usermessage.Hook("CustomChat_ChatMsg", function(um)
local ply = um:ReadEntity()
local msg = um:ReadString()
local rank = um:ReadString()
local r = um:ReadShort()
local g = um:ReadShort()
local b = um:ReadShort()
chat.AddText(Color(r, g, b), rank, team.GetColor(ply:Team()), " "..ply:Nick(), Color(255,255,255), ": "..msg)
end)
end[/CODE]
Have fun =)
Wow. You really are helpfull!
I will test this as Soon as i get home :)
I had something similar, but that made people able to alltalk when dead.
Will report back In an hour or so!
I'am can realise tab admin color if need.
And Alltalk is don't work after you dead
Example - Owner - Red name on TTT tab
Im not sure what you mean. If you are talking about a rank row that sais "Admin" in color, I already have that.
Or are you talking about making the names of admins in color. (The names in on the left side of the scoreboard)?
If so im really interested :)
EDIT:
So this is what i did i took this part:
[lua]
local ranks = {
["superadmin"] = Color(220,20,60),
["admin"] = Color(255,20,60),
["moderator"] = Color(238,0,238),
["regular"] = Color(255,255,255),
["friend"] = Color(150,255,150),
}
if (SERVER) then
function CustomChat_ChatMessage(ply, msg, rank, r, g, b)
umsg.Start("CustomChat_ChatMsg")
umsg.Entity(ply)
umsg.String(msg)
umsg.String(rank)
umsg.Short(r)
umsg.Short(g)
umsg.Short(b)
umsg.End()
end
function CustomChat_Checker(ply, text, teamonly)
local group = ply:GetUserGroup()
local color = ranks[group]
local txtcheck = string.sub(text,1,1)
if txtcheck == "/" then
return text
else
return "", CustomChat_ChatMessage(ply, text, "["..string.upper(string.sub(group,1,1))..string.sub(group,2).."]", color.r, color.g, color.b)
end
end
hook.Add("PlayerSay", "WordCheck", CustomChat_Checker)
else
usermessage.Hook("CustomChat_ChatMsg", function(um)
local ply = um:ReadEntity()
local msg = um:ReadString()
local rank = um:ReadString()
local r = um:ReadShort()
local g = um:ReadShort()
local b = um:ReadShort()
chat.AddText(Color(r, g, b), rank, team.GetColor(ply:Team()), " "..ply:Nick(), Color(255,255,255), ": "..msg)
end)
end
[/lua]
and put it at the bottom of gamemsg.lua wich was in the terrortown/gamemessage folder.
But now there is no text displaying at all!
I do get an error in console:
[code]
Warning: Unhandled usermessage 'CustomChat_ChatMsg'
[/code]
Any ideas why this is happening?
(I have the feeling im beeing a complete retard again :S) (Am i suppose to add this to lua/autorun as well?)
EDIT2:
So i added this to lua/autorun instead. And now it working at least. But i saw now that this is the excact code that someone posted some days ago, so maybe they just pasted your work. Either way i think this makes all reanked people able to alltalk when dead :/
[QUOTE=zapha;38737040]Im not sure what you mean. If you are talking about a rank row that sais "Admin" in color, I already have that.
Or are you talking about making the names of admins in color. (The names in on the left side of the scoreboard)?
If so im really interested :)
EDIT:
So this is what i did i took this part:
[lua]
local ranks = {
["superadmin"] = Color(220,20,60),
["admin"] = Color(255,20,60),
["moderator"] = Color(238,0,238),
["regular"] = Color(255,255,255),
["friend"] = Color(150,255,150),
}
if (SERVER) then
function CustomChat_ChatMessage(ply, msg, rank, r, g, b)
umsg.Start("CustomChat_ChatMsg")
umsg.Entity(ply)
umsg.String(msg)
umsg.String(rank)
umsg.Short(r)
umsg.Short(g)
umsg.Short(b)
umsg.End()
end
function CustomChat_Checker(ply, text, teamonly)
local group = ply:GetUserGroup()
local color = ranks[group]
local txtcheck = string.sub(text,1,1)
if txtcheck == "/" then
return text
else
return "", CustomChat_ChatMessage(ply, text, "["..string.upper(string.sub(group,1,1))..string.sub(group,2).."]", color.r, color.g, color.b)
end
end
hook.Add("PlayerSay", "WordCheck", CustomChat_Checker)
else
usermessage.Hook("CustomChat_ChatMsg", function(um)
local ply = um:ReadEntity()
local msg = um:ReadString()
local rank = um:ReadString()
local r = um:ReadShort()
local g = um:ReadShort()
local b = um:ReadShort()
chat.AddText(Color(r, g, b), rank, team.GetColor(ply:Team()), " "..ply:Nick(), Color(255,255,255), ": "..msg)
end)
end
[/lua]
and put it at the bottom of gamemsg.lua wich was in the terrortown/gamemessage folder.
But now there is no text displaying at all!
I do get an error in console:
[code]
Warning: Unhandled usermessage 'CustomChat_ChatMsg'
[/code]
Any ideas why this is happening?
(I have the feeling im beeing a complete retard again :S) (Am i suppose to add this to lua/autorun as well?)[/QUOTE]
It's because it's terrible.
ply.GetUserGroup is shared and he sends it from the server, same goes for ply.EV_GetRank.
Before someone complains because I don't help:
[code]
if ( SERVER ) then
-- Before someone complains: Garry changed it so that if it's called without an arg it adds the current file
AddCSLuaFile( )
return
end
-- For evolve change all GetUserGroup to EV_GetRank
-- Adding more Tags is as simple as TagColor["example"] = Color( 0, 0, 0 )
-- The numbers mean r g b, red green blue.
-- All TagColor's have to be under the local TagColor = {}
local TagColor = {}
TagColor["superadmin"] = Color( 0, 0, 255 )
TagColor["admin"] = Color( 255, 0, 0 )
TagColor["donator"] = Color( 0, 255, 0 )
local function OnPlayerChat( ply, strText, bTeamOnly, bPlayerIsDead )
local tab = {}
if ( bPlayerIsDead ) then
table.insert( tab, Color( 255, 30, 40 ) )
table.insert( tab, "|DEAD| " )
end
if ( bTeamOnly ) then
table.insert( tab, Color( 30, 160, 40 ) )
table.insert( tab, "|TEAM|" )
end
if ( IsValid( ply ) ) then
if ( ply.GetUserGroup ) then
if ( ply:GetUserGroup() != "user" ) then
table.insert( tab, TagColor[ ply:GetUserGroup() ] or Color(0, 50, 255 ) )
table.insert( tab, "( " .. ply:GetUserGroup() .. " )" )
end
end
table.insert( tab, ply:GetName() )
else
table.insert( tab, "Console" )
end
table.insert( tab, Color( 255, 255, 255 ) )
table.insert( tab, ": "..strText )
chat.AddText( unpack(tab) )
return true
end
hook.Add("OnPlayerChat", "Tags.OnPlayerChat", OnPlayerChat)
[/code]
Edit: Just saw your edit, mine won't do that his does that because it overwrites the hole PlayerChat function and that breaks stuff.
Need add addon lua file in lua/autorun/ and write code in gamemsg.lua
[QUOTE=Combinerus;38737689]Need add addon lua file in lua/autorun/ and write code in gamemsg.lua[/QUOTE]
What ?
No, it doesn't need a "addon lua file" and no don't write it in gamemsg that means game message.
Just make a file in lua/autorun and call it whatever you want.
[QUOTE=Leystryku;38737909]What ?
No, it doesn't need a "addon lua file" and no don't write it in gamemsg that means game message.
Just make a file in lua/autorun and call it whatever you want.[/QUOTE]
Ill try your code out then and report back :)
[editline]7th December 2012[/editline]
Tanks a lot, the code is working swell :)
but i have one question for you. Is there any way to make the (admin) colored and the nickname plain white? kind of reversed of what it is now?
this maybe?
[lua]
table.insert( tab, "[" .. ply:GetUserGroup() .. "]" )
table.insert( tab, TagColor[ ply:GetUserGroup() ] or Color(0, 50, 255 ) )
[/lua]
I do not know about you, but I have everything working fine, I will put my build and not going to edit it. For me, it is better
Thanks for help
Sorry for the ignorant question, but where do I place this folder if I am running ULX? I tried putting it in the addons folder, to no avail. Please help.
create a new lua file (whatever name) and place it in lua/autorun :)
[QUOTE=Samg381;38741715]Sorry for the ignorant question, but where do I place this folder if I am running ULX? I tried putting it in the addons folder, to no avail. Please help.[/QUOTE]
Also put, addon lua folder in server/garrysmod/lua/autorun/
It works, great! Only problem: OOC Chat in Darkrp servers overrides this. The command is /ooc.
Sorry, you need to Log In to post a reply to this thread.