Hi there! I have a problem. I made the mean time the admin chat. But this command works for all players and what they write in the chat is also probably to all players.
Code:
Server Side:
util.AddNetworkString("ReceiveAdminMsg")
hook.Add( "PlayerSay", "AdminChat", function( ply, text, team )
if ( string.sub( string.lower( text ), 1, 4 ) == "!adm" ) or ( string.sub( string.lower( text ), 1, 4 ) == "/adm" ) then
local text = string.sub( text, 5 )
local send = {}
if ply:CheckGroup("superadmin") or ply:CheckGroup("HeadAdmin") or ply:CheckGroup("GameMaster") or ply:CheckGroup("Administrator") or ply:CheckGroup("Moderator") or ply:CheckGroup("BigBro") or ply:CheckGroup("Superadmin_D") then table.insert(send, ply) end
for _, v in ipairs(player.GetAll()) do
if v:CheckGroup("superadmin") or v:CheckGroup("HeadAdmin") or v:CheckGroup("GameMaster") or v:CheckGroup("Administrator") or v:CheckGroup("Moderator") or v:CheckGroup("BigBro") or v:CheckGroup("Superadmin_D") then
table.insert(send, v)
end
end
net.Start("ReceiveAdminMsg")
net.WriteEntity(ply)
net.WriteString(text)
net.Send(ply)
end
end )
Client Side:
net.Receive("ReceiveAdminMsg", function( len )
local pply = net.ReadEntity()
local ptext = net.ReadString()
local pnick = pply:IsPlayer() and pply:Nick() or "Console"
local ply = LocalPlayer()
if not ply:CheckGroup("superadmin") or ply:CheckGroup("HeadAdmin") or ply:CheckGroup("GameMaster") or ply:CheckGroup("Administrator") or ply:CheckGroup("Moderator") or ply:CheckGroup("BigBro") or ply:CheckGroup("Superadmin_D") then return end
chat.AddText( Color(255, 0, 0), "[Админ Чат] ", Color(49, 49, 49), pnick..": ", Color(255, 255, 255), ptext )
end)
You need to prevent the command text from appearing, in the PlayerSay hook. Add a return "" at the end, in the if block.
hook.Add( "PlayerSay", "AdminChat", function( ply, text, team )
if ( string.sub( string.lower( text ), 1, 4 ) == "!adm" ) or ( string.sub( string.lower( text ), 1, 4 ) == "/adm" ) then
-- etc.
return ""
end
end )
Sorry, you need to Log In to post a reply to this thread.