Sign in to follow this  
blinkerchris

Localmute

Recommended Posts

Hello, I'm making a local mute script and I need some help. This is what I have so far.

local chat = true 
  
function chatDis(thePlayer) 
    outputChatBox("#E3E8B7The chat has been disabled by "..getPlayerName(thePlayer)..".",root,255, 255, 255, true) 
    chat = false 
end 
addCommandHandler("chatoff", chatDis) 
  
function chatEn(thePlayer) 
    outputChatBox("#E3E8B7The chat has been enabled by "..getPlayerName(thePlayer)..".",root,255, 255, 255, true) 
    chat = true 
end 
addCommandHandler("chaton",chatEn) 
  
function onChat() 
    if (chat == false) then 
    cancelEvent() 
end 
end 
addEventHandler("onPlayerChat", root, onChat) 

Everything works fine with the lua above.

But the thing I want is the teamchat should work all the time, when /chatoff then only local chat should be disabled. Not teamsay.

and when /chaton, everything should work as normal.

Only admins should be able to /chaton /chatoff

Regards,

chris.

Thanks :D

Share this post


Link to post

isObjectInAclGroup for it. You forget some parameters for onPlayerChat. You can use the type of team message and then not cancel it.

Share this post


Link to post
isObjectInACL for it. You forget some parameters for onPlayerChat. You can use the type of team message and then not cancel it.

I have no idea how to do that.

Could you help?

Thanks

Share this post


Link to post
  
local chat = true 
  
function chatDis(thePlayer) 
   local accName = getAccountName ( getPlayerAccount ( thePlayer ) )  
   if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then 
    outputChatBox("#E3E8B7The 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("#E3E8B7The chat has been enabled by "..getPlayerName(thePlayer)..".",root,255, 255, 255, true) 
    chat = true 
end 
end 
addCommandHandler("chaton",chatEn) 
  
function onChat(message,messageType) 
    if messageType == 0 or messageType == 2 then 
    if (chat == false) then 
    cancelEvent() 
   end 
end 
end 
addEventHandler("onPlayerChat", root, onChat) 
  

Share this post


Link to post
  
local chat = true 
  
function chatDis(thePlayer) 
   local accName = getAccountName ( getPlayerAccount ( thePlayer ) )  
   if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then 
    outputChatBox("#E3E8B7The 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("#E3E8B7The chat has been enabled by "..getPlayerName(thePlayer)..".",root,255, 255, 255, true) 
    chat = true 
end 
end 
addCommandHandler("chaton",chatEn) 
  
function onChat(message,messageType) 
    if messageType == 0 or messageType == 2 then 
    if (chat == false) then 
    cancelEvent() 
   end 
end 
end 
addEventHandler("onPlayerChat", root, onChat) 
  

I tested it now, and the admin part works fine. but when I do /chatoff I can't use teamsay. that's my clue that I want to work =/ but the mainchat should still be disabled when /chatoff, only teamsay should work then.

Thanks

Share this post


Link to post
  
  
local chat = true 
  
function chatDis(thePlayer) 
   local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) 
   if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then 
    outputChatBox("#E3E8B7The 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("#E3E8B7The chat has been enabled by "..getPlayerName(thePlayer)..".",root,255, 255, 255, true) 
    chat = true 
end 
end 
addCommandHandler("chaton",chatEn) 
  
function onChat(message,messageType) 
    if messageType == 0 or messageType == 2 and chat == false then 
    cancelEvent() 
   end 
end 
end 
addEventHandler("onPlayerChat", root, onChat) 
  
  

Share this post


Link to post
  
  
local chat = true 
  
function chatDis(thePlayer) 
   local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) 
   if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then 
    outputChatBox("#E3E8B7The 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("#E3E8B7The chat has been enabled by "..getPlayerName(thePlayer)..".",root,255, 255, 255, true) 
    chat = true 
end 
end 
addCommandHandler("chaton",chatEn) 
  
function onChat(message,messageType) 
    if messageType == 0 or messageType == 2 and chat == false then 
    cancelEvent() 
   end 
end 
end 
addEventHandler("onPlayerChat", root, onChat) 
  
  

Tested it.

Now the chat works no matter what. When I /chatoff both chats still works =/

only teamchat should work when /chatoff, normal chat shouldn't.

when /chaton both chats should work.

Thanks

chris.

Share this post


Link to post

Check this out

local chat = true 
  
function chatDis(thePlayer) 
   local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) 
   if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then 
    outputChatBox("#E3E8B7The 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("#E3E8B7The 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 or messageType == 2 ) then 
        if ( not chat ) then 
            cancelEvent ( ) 
        end 
    end 
end 
addEventHandler ( "onPlayerChat", root, onChat ) 

Share this post


Link to post

He wants to disable only the main chat

local chat = true 
  
function chatDis(thePlayer) 
   local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) 
   if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then 
    outputChatBox("#E3E8B7The 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("#E3E8B7The 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 ) 

Try this.

Share this post


Link to post

ahh guys, no error in the script, the only problem is that he made it in line 24:

  
  if messageType == 0 or messageType == 2 and chat == false then 
  

if the message type = 2 then it's team chat! he want team chat to work so it must be:

  
  if messageType == 0 and chat == false then 
  

EDIT: seems like me and Castro were posting in the same time

Share this post


Link to post
  
local chat = true 
  
function chatDis(thePlayer) 
   if not chat then outputChatBox("#E3E8B7Chat is already disabled",thePlayer,255,255,255,true) return end 
    
   local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) 
   if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then 
    outputChatBox("#E3E8B7The chat has been disabled by "..getPlayerName(thePlayer)..".",root,255, 255, 255, true) 
    chat = false 
   end     
end 
addCommandHandler("chatoff", chatDis) 
  
function chatEn(thePlayer) 
    if chat then outputChatBox("#E3E8B7Chat is already enabled",thePlayer,255,255,255,true) return end 
    
    local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) 
    if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then 
      outputChatBox("#E3E8B7The chat has been enabled by "..getPlayerName(thePlayer)..".",root,255, 255, 255, true) 
      chat = true 
    end 
end 
addCommandHandler("chaton",chatEn) 
  
addEventHandler("onPlayerChat",root, 
function (message,messageType) 
if messageType == 0 or messageType == 1 and not chat then 
    cancelEvent() 
   end 
end) 

Ohh boy...guess it would be nice to know if someone else is already posting in a particular topic xD

Share this post


Link to post
  
local chat = true 
  
function chatDis(thePlayer) 
   if not chat then outputChatBox("#E3E8B7Chat is already disabled",thePlayer,255,255,255,true) return end 
    
   local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) 
   if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then 
    outputChatBox("#E3E8B7The chat has been disabled by "..getPlayerName(thePlayer)..".",root,255, 255, 255, true) 
    chat = false 
   end     
end 
addCommandHandler("chatoff", chatDis) 
  
function chatEn(thePlayer) 
    if chat then outputChatBox("#E3E8B7Chat is already enabled",thePlayer,255,255,255,true) return end 
    
    local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) 
    if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then 
      outputChatBox("#E3E8B7The chat has been enabled by "..getPlayerName(thePlayer)..".",root,255, 255, 255, true) 
      chat = true 
    end 
end 
addCommandHandler("chaton",chatEn) 
  
addEventHandler("onPlayerChat",root, 
function (message,messageType) 
if messageType == 0 or messageType == 1 and not chat then 
    cancelEvent() 
   end 
end) 

Ohh boy...guess it would be nice to know if someone else is already posting in a particular topic xD

I'm using this one now, but it's not working 100%

The problem is now that when I /chaton everything should work as normal, both chats should work. when /chatoff then ONLY mainchat should be disabled, teamchat should work.

and mainchat doesn't work weither its on or not.

Thanks

chris

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.