I am a pretty good LUA scripter, but, as everyone, I have ran into a problem. I have a chat tag script(This was made by someone else, but edited by me), but it seems to have a problem. The problem is that spectators/dead players can talk and everyone(INCLUDING LIVING PLAYERS) can see there chat. I cannot find a problem but here is the code:
[CODE] if (SERVER) then
AddCSLuaFile( "chattags.lua" )
local Tag = ""
local R = 0
local G = 0
local B = 0
function CustomChat_ChatMessage( name, String, bool, R, G, B) -- ChatMessage(rgb, name, rgb2, String)
umsg.Start( "CustomChat_ChatMsg" )
umsg.String(name)
umsg.String(String)
umsg.String(bool)
umsg.Long(R)
umsg.Long(G)
umsg.Long(B)
umsg.End()
end
concommand.Add( "chat_alert", function( ply, cmd, args )
if args[1] then // We're seeing if there are any arguments, arguments are stored on a table, so you will have to use args[index].
if ply:IsAdmin() then
CustomChat_ChatMessage( "ALERT", ": "..string.gsub(args[1], "_", " "), "" , 255, 0, 0)
else
ply:PrintMessage(HUD_PRINTCONSOLE,"You are not Admin")
Msg("--Player "..ply:Nick().." is not admin and tryed to use alert chat.\n")
end
end
end )
function CustomChat_Checker( ply, text, teamonly )
--/*
if ply:IsUserGroup("moderator") then
Tag = "(Moderator)\t"
R = 255
G = 165
B = 0
elseif ply:IsUserGroup("donator") then
Tag = "(Donator)\t"
R = 0
G = 255
B = 255
elseif ply:IsUserGroup("owner") then
Tag = "(Owner)\t"
R = 255
G = 0
B = 0
elseif ply:IsSuperAdmin() then
Tag = "(Super Admin)\t"
R = 255
G = 0
B = 0
elseif ply:IsAdmin() then
Tag = "(Admin)\t"
R = 50
G = 205
B = 50
elseif ply:IsUserGroup("co-owner") then
Tag = "(Co-Owner)\t"
R = 20
G = 100
B = 150
else
Tag = ""
R = 30
G = 144
B = 255
end
--*/
/*
if ply:IsSuperAdmin() then
Tag = "(Admin)\t"
R = 50
G = 205
B = 50
elseif ply:IsAdmin() then
Tag = "(Mod)\t"
R = 255
G = 165
B = 0
elseif ply:IsUserGroup("vip") then
Tag = "(VIP)\t"
R = 0
G = 0
end
*/
CustomChat_ChatMessage(ply:Nick(), ": "..text, Tag, R, G, B)
return ""
end
hook.Add("PlayerSay", "WordCheck", CustomChat_Checker)
------------------------------------------
else --- client code
------------------------------------------
usermessage.Hook("CustomChat_ChatMsg", function( um, ply )
local name = um:ReadString()
local String = um:ReadString()
local Tag = um:ReadString()
local R = um:ReadLong()
local G = um:ReadLong()
local B = um:ReadLong()
chat.AddText(Color(R, G, B, 255), Tag..name, Color(255, 255, 255, 255), String)
end)
end-- final end
-- Admin > flamedog: words
-- SAdmin > flamedog: words
-- Concole > words[/CODE]
The directory of this code is:
[CODE][Server]/orangebox/garrysmod/lua/autorun/chattags.lua[/CODE]
-----------------------------------------------
P.S. I also have a DeathRun server, but the Co-Owner's tag is "Super Admin" for some reason, NOTE: THIS DOES NOT HAPPEN ON TTT!
Did you try it without the "/t".
Like this: Tag = "[Moderator]"
If you're a "pretty good Lua* scripter" you should be able to solve your problem.
You don't seem to understand the flow of your own code.
1. <players say something> CustomChat_Checker gets called
2. <text gets tag and color> CustomChat_Checker finds the right tags/color
3. <you send a usermessage> CustomChat_ChatMessage send a Usermessage
In case you haven't realized it yet, the reason you see death people chat is because you send a usermesasge in CustomChat_ChatMessage to all clients on the server.
You don't anywhere in your code have any kind of restriction on who you send the data too.
[url]http://wiki.garrysmod.com/page/umsg/Start[/url]
What you probably want to do is create a table with players who are death, and only send the chat message to the table when a death person talks.
PS. The 100% right way to apply these colors/tags on the client and not on the server, doing so reduces network traffic.
[editline]19th March 2013[/editline]
PS.PS. [img]http://cold.netburst.co.uk/file/2013-03-19_10-01-03.png[/img]
You managed to miss it.
[QUOTE=OldFusion;39967600]You don't seem to understand the flow of your own code.
1. <players say something> CustomChat_Checker gets called
2. <text gets tag and color> CustomChat_Checker finds the right tags/color
3. <you send a usermessage> CustomChat_ChatMessage send a Usermessage
In case you haven't realized it yet, the reason you see death people chat is because you send a usermesasge in CustomChat_ChatMessage to all clients on the server.
You don't anywhere in your code have any kind of restriction on who you send the data too.
[url]http://wiki.garrysmod.com/page/umsg/Start[/url]
What you probably want to do is create a table with players who are death, and only send the chat message to the table when a death person talks.
PS. The 100% right way to apply these colors/tags on the client and not on the server, doing so reduces network traffic.
[editline]19th March 2013[/editline]
PS.PS. [img]http://cold.netburst.co.uk/file/2013-03-19_10-01-03.png[/img]
You managed to miss it.[/QUOTE]
Thanks a lot! I am still learning to script though! (BTW, I knew it was that, I was thinking about fixing that after I posted it, but, just to make sure, I didn't
[editline]19th March 2013[/editline]
[QUOTE=ms333;39967117]If you're a "pretty good Lua* scripter" you should be able to solve your problem.[/QUOTE]
-.-, wow, you must be some kind of dumb... I said "Pretty Good" NOT implying that I am a "Master"! And also, EVERYONE, and I mean EVERYONE, EVEN Garry, faces some problems you can't fix on your own!
[QUOTE=SkibbyDuu;39973723]
-.-, wow, you must be some kind of dumb... I said "Pretty Good" NOT implying that I am a "Master"! And also, EVERYONE, and I mean EVERYONE, EVEN Garry, faces some problems you can't fix on your own![/QUOTE]
If you're a pretty good lua scripter you can make your own chat tags script...
[QUOTE=ms333;39973797]If you're a pretty good lua scripter you can make your own chat tags script...[/QUOTE]
I have... I didn't like it...
[editline]19th March 2013[/editline]
[QUOTE=OldFusion;39967600]You don't seem to understand the flow of your own code.
1. <players say something> CustomChat_Checker gets called
2. <text gets tag and color> CustomChat_Checker finds the right tags/color
3. <you send a usermessage> CustomChat_ChatMessage send a Usermessage
In case you haven't realized it yet, the reason you see death people chat is because you send a usermesasge in CustomChat_ChatMessage to all clients on the server.
You don't anywhere in your code have any kind of restriction on who you send the data too.
[URL]http://wiki.garrysmod.com/page/umsg/Start[/URL]
What you probably want to do is create a table with players who are death, and only send the chat message to the table when a death person talks.
PS. The 100% right way to apply these colors/tags on the client and not on the server, doing so reduces network traffic.
[editline]19th March 2013[/editline]
PS.PS. [IMG]http://cold.netburst.co.uk/file/2013-03-19_10-01-03.png[/IMG]
You managed to miss it.[/QUOTE]
So are you saying that the "table of players" is passed "nil"?
Sorry, you need to Log In to post a reply to this thread.