Jump to content

Disable team chat?


Recommended Posts

  • MTA Team
  
blocked = { 
    ["FiveForty"] = true, 
    ["Querty"] = true 
} 
  
addEventHandler("onPlayerChat", root, 
    function (_, type) 
        if (type == 2) then -- team message 
            local team = getPlayerTeam(source) 
            if (team and blocked[ getTeamName(team) ]) then 
                return cancelEvent() 
            end 
        end 
    end 
) 
  

Link to comment

Hmm, got a question, if i create a table of teams without permission to teamchat, its okay like this?

disabled = {'Team1', 'Team2'}    
  
addEventHandler("onPlayerChat", root, 
    function (_, type) 
        if (type == 2) then -- team message 
            local team = getTeamFromName(disabled) 
            if (team) then 
                return cancelEvent() 
            end 
        end 
    end 
) 

Link to comment
disabled = {'Team1', 'Team2'}    
  
addEventHandler("onPlayerChat", root, 
function (_, type) 
    if (type == 2) then 
        for k,v in pairs(disabled) do 
            local team = getTeamFromName(v) 
            if (team) then 
                return cancelEvent() 
            end 
        end 
    end 
end) 

Link to comment

Thats not gonna work, lol. You're cancelling every team!

  
disabled = {'Team1', 'Team2'}   
  
addEventHandler("onPlayerChat", root, 
function (_, type) 
    if (type == 2) then 
        for k,v in pairs(disabled) do 
            local team = getTeamFromName(v) 
            if ( team) and (team==getPlayerTeam(source) ) then 
                return cancelEvent() 
            end 
        end 
    end 
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...