MisterQuestions Posted December 8, 2014 Posted December 8, 2014 Is there anyway to disable team chat for certain teams?
MTA Team botder Posted December 9, 2014 MTA Team Posted December 9, 2014 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 )
MisterQuestions Posted December 10, 2014 Author Posted December 10, 2014 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 )
Banex Posted December 10, 2014 Posted December 10, 2014 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)
.:HyPeX:. Posted December 10, 2014 Posted December 10, 2014 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 )
DiSaMe Posted December 10, 2014 Posted December 10, 2014 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.
.:HyPeX:. Posted December 10, 2014 Posted December 10, 2014 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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now