Jump to content

isPlayerMuted


Coffey

Recommended Posts

Hey! I have a chat script, I want to make it so if a player is muted, then he cant use it... I've tried adding if not isPlayerMuted (thePlayer) stuff, but it doesnt work...

Code:

local isChatDisabled = {} 
  
function globalMessage(thePlayer, cmd, ...) 
    local message = table.concat ( { ... }, " " ); 
    local name = getPlayerName(thePlayer); 
    for _,v in ipairs(getElementsByType("player")) do 
    if not isChatDisabled[v] then 
              outputChatBox("#FF0000[GLOBAL]#00FF00"..name..": #FFFFFF"..message,v, 255, 255, 255, true) 
         end 
    end 
end 
addCommandHandler("global",  globalMessage); 
  
addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), 
 function() 
  for index,player in pairs(getElementsByType("player")) do 
        bindKey(player,"b", "down", "chatbox", "global"); 
  end 
end 
) 
  
addEventHandler("onPlayerJoin",root, 
function () 
   bindKey(source,"b", "down", "chatbox", "global"); 
end 
); 
  
addCommandHandler("gcoff", 
function(p) 
     isChatDisabled[p] = true; 
end ); 
  
addCommandHandler("gcon",  
function(p) 
    isChatDisabled[p] = false; 
end ); 

Link to comment
local isChatDisabled = {} 
  
function globalMessage(thePlayer, cmd, ...) 
    local message = table.concat ( { ... }, " " ); 
    local name = getPlayerName(thePlayer); 
    for _,v in ipairs(getElementsByType("player")) do 
    if ( not isChatDisabled[v] and not isPlayerMuted ( thePlayer ) ) then 
              outputChatBox("#FF0000[GLOBAL]#00FF00"..name..": #FFFFFF"..message,v, 255, 255, 255, true) 
         end 
    end 
end 
addCommandHandler("global",  globalMessage); 
  
addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), 
 function() 
  for index,player in pairs(getElementsByType("player")) do 
        bindKey(player,"b", "down", "chatbox", "global"); 
  end 
end 
) 
  
addEventHandler("onPlayerJoin",root, 
function () 
   bindKey(source,"b", "down", "chatbox", "global"); 
end 
); 
  
addCommandHandler("gcoff", 
function(p) 
     isChatDisabled[p] = true; 
end ); 
  
addCommandHandler("gcon", 
function(p) 
    isChatDisabled[p] = false; 
end ); 

Link to comment

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...