Nahar Posted May 25, 2015 Share Posted May 25, 2015 function chatDis(command) cancelEvent() outputChatBox("THE CHAT IS DISABLED",source,255,0,0) if hasObjectPermissionTo ( command, "function.banPlayer" ) then addEventHandler("onPlayerChat",getRootElement(),chatDis) end end function chatEN(command) if hasObjectPermissionTo ( command, "function.banPlayer" ) then outputChatBox("THE CHAT IS NOW ENABLED ",getRootElement(),255,0,0) removeEventHandler("onPlayerChat",getRootElement(),chatDis) end end addCommandHandler("cd",chatDis) addCommandHandler("ce",chatEN) How i can add there that it work only for the team spectators? i mean when i write ./ce no one can write in the chat even admins. how i can add like admins can talk and others cant. Link to comment
ALw7sH Posted May 25, 2015 Share Posted May 25, 2015 function disableChat() if getTeamName(getPlayerTeam(source)) == "Spectators" then cancelEvent() outputChatBox("THE CHAT IS DISABLED",source,255,0,0) end end function toggleChat(player,cmd) if hasObjectPermissionTo ( player, "function.banPlayer" ) then if cmd == "cd" then addEventHandler("onPlayerChat",getRootElement(),disableChat) outputChatBox("THE CHAT IS NOW ENABLED ",getRootElement(),255,0,0) elseif cmd == "ce" then removeEventHandler("onPlayerChat",getRootElement(),disableChat) end end end addCommandHandler("cd",toggleChat) addCommandHandler("ce",toggleChat) Link to comment
ALw7sH Posted May 25, 2015 Share Posted May 25, 2015 What's doesn't works? use /debugscript 3 to see if there's any errors Link to comment
tosfera Posted May 25, 2015 Share Posted May 25, 2015 simple way to enable/disable the chat; local isDisabled = false; addEventHandler ( "onPlayerChat", root, function ( message, messageType ) if ( messageType == 0 ) then if ( isDisabled ) then if ( not hasObjectPermissionTo ( source, "function.banPlayer" ) ) then cancelEvent(); outputChatBox ( "The chat is currently disabled", source ); end elseif ( getPlayerTeam ( source ) and getTeamName ( getPlayerTeam ( source ) ) == "Spectators" ) then cancelEvent(); outputChatBox ( "You're not allowed to talk", source ); end end end ); addCommandHandler ( "cd", function ( thePlayer, cmd ) if ( hasObjectPermissionTo ( thePlayer, "function.banPlayer" ) ) then isDisabled = not isDisabled; outputChatBox ( "The chat has been ".. ( isDisabled and "disabled" or "enabled" ) .." by ".. getPlayerName ( thePlayer ) ); end end ); 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