Try this
local chat = true
function chatDis(thePlayer)
local accName = getAccountName ( getPlayerAccount ( thePlayer ) )
if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then
outputChatBox("#ff0000Main chat has been disabled by "..getPlayerName(thePlayer)..".",root,255, 255, 255, true)
chat = false
end
end
addCommandHandler("chatoff", chatDis)
function chatEn(thePlayer)
local accName = getAccountName ( getPlayerAccount ( thePlayer ) )
if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then
outputChatBox("#ff0000Main chat has been enabled by "..getPlayerName(thePlayer)..".",root,255, 255, 255, true)
chat = true
end
end
addCommandHandler("chaton", chatEn)
function onChat ( _, messageType )
if ( messageType == 0 and not chat ) then
cancelEvent ( )
end
end
addEventHandler ( "onPlayerChat", root, onChat )