Jump to content

Disable team chat?


Recommended Posts

  • MTA Team
Posted
  
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 
) 
  

Posted

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 
) 

"El conocimiento jamás debe detenerse, por que es lo único que nos salvará cuando no nos quede más".

Att: -|TG|-Mister[Q]<.

Posted
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) 

jIcd9sc.png

Not worry about the future. Very soon it will come.

Posted

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 
) 
  

My ingame nick is ~HyPeX~

BF3 Gamemode Progress: ~30% - Currently working on AI & MapManager

gKhdyRJ.png

Posted

But it's more efficient to use the team as table key like Necktrox did rather than loop through the table and check the player's team against every value.

-

Posted
But it's more efficient to use the team as table key like Necktrox did rather than loop through the table and check the player's team against every value.

Yeah true, i just copied down the code abdove me.

My ingame nick is ~HyPeX~

BF3 Gamemode Progress: ~30% - Currently working on AI & MapManager

gKhdyRJ.png

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...