MisterQuestions Posted December 8, 2014 Share Posted December 8, 2014 Is there anyway to disable team chat for certain teams? Link to comment
MTA Team botder Posted December 9, 2014 MTA Team Share 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 ) Link to comment
MisterQuestions Posted December 9, 2014 Author Share Posted December 9, 2014 i will check it thanks Link to comment
MisterQuestions Posted December 10, 2014 Author Share 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 ) Link to comment
Banex Posted December 10, 2014 Share 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) Link to comment
.:HyPeX:. Posted December 10, 2014 Share 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 ) Link to comment
DiSaMe Posted December 10, 2014 Share 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. Link to comment
.:HyPeX:. Posted December 10, 2014 Share 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. Link to comment
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