blinkerchris Posted March 23, 2014 Share Posted March 23, 2014 Hello, I'm making a local mute script and I need some help. This is what I have so far. local chat = true function chatDis(thePlayer) outputChatBox("#E3E8B7The chat has been disabled by "..getPlayerName(thePlayer)..".",root,255, 255, 255, true) chat = false end addCommandHandler("chatoff", chatDis) function chatEn(thePlayer) outputChatBox("#E3E8B7The chat has been enabled by "..getPlayerName(thePlayer)..".",root,255, 255, 255, true) chat = true end addCommandHandler("chaton",chatEn) function onChat() if (chat == false) then cancelEvent() end end addEventHandler("onPlayerChat", root, onChat) Everything works fine with the lua above. But the thing I want is the teamchat should work all the time, when /chatoff then only local chat should be disabled. Not teamsay. and when /chaton, everything should work as normal. Only admins should be able to /chaton /chatoff Regards, chris. Thanks Link to comment
Anubhav Posted March 23, 2014 Share Posted March 23, 2014 isObjectInAclGroup for it. You forget some parameters for onPlayerChat. You can use the type of team message and then not cancel it. Link to comment
blinkerchris Posted March 23, 2014 Author Share Posted March 23, 2014 isObjectInACL for it. You forget some parameters for onPlayerChat. You can use the type of team message and then not cancel it. I have no idea how to do that. Could you help? Thanks Link to comment
Anubhav Posted March 23, 2014 Share Posted March 23, 2014 local chat = true function chatDis(thePlayer) local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then outputChatBox("#E3E8B7The chat has been disabled by "..getPlayerName(thePlayer)..".",root,255, 255, 255, true) chat = false end end addCommandHandler("chatoff", chatDis) function chatEn(thePlayer) local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then outputChatBox("#E3E8B7The chat has been enabled by "..getPlayerName(thePlayer)..".",root,255, 255, 255, true) chat = true end end addCommandHandler("chaton",chatEn) function onChat(message,messageType) if messageType == 0 or messageType == 2 then if (chat == false) then cancelEvent() end end end addEventHandler("onPlayerChat", root, onChat) Link to comment
blinkerchris Posted March 23, 2014 Author Share Posted March 23, 2014 local chat = true function chatDis(thePlayer) local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then outputChatBox("#E3E8B7The chat has been disabled by "..getPlayerName(thePlayer)..".",root,255, 255, 255, true) chat = false end end addCommandHandler("chatoff", chatDis) function chatEn(thePlayer) local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then outputChatBox("#E3E8B7The chat has been enabled by "..getPlayerName(thePlayer)..".",root,255, 255, 255, true) chat = true end end addCommandHandler("chaton",chatEn) function onChat(message,messageType) if messageType == 0 or messageType == 2 then if (chat == false) then cancelEvent() end end end addEventHandler("onPlayerChat", root, onChat) I tested it now, and the admin part works fine. but when I do /chatoff I can't use teamsay. that's my clue that I want to work =/ but the mainchat should still be disabled when /chatoff, only teamsay should work then. Thanks Link to comment
Anubhav Posted March 23, 2014 Share Posted March 23, 2014 local chat = true function chatDis(thePlayer) local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then outputChatBox("#E3E8B7The chat has been disabled by "..getPlayerName(thePlayer)..".",root,255, 255, 255, true) chat = false end end addCommandHandler("chatoff", chatDis) function chatEn(thePlayer) local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then outputChatBox("#E3E8B7The chat has been enabled by "..getPlayerName(thePlayer)..".",root,255, 255, 255, true) chat = true end end addCommandHandler("chaton",chatEn) function onChat(message,messageType) if messageType == 0 or messageType == 2 and chat == false then cancelEvent() end end end addEventHandler("onPlayerChat", root, onChat) Link to comment
blinkerchris Posted March 23, 2014 Author Share Posted March 23, 2014 local chat = true function chatDis(thePlayer) local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then outputChatBox("#E3E8B7The chat has been disabled by "..getPlayerName(thePlayer)..".",root,255, 255, 255, true) chat = false end end addCommandHandler("chatoff", chatDis) function chatEn(thePlayer) local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then outputChatBox("#E3E8B7The chat has been enabled by "..getPlayerName(thePlayer)..".",root,255, 255, 255, true) chat = true end end addCommandHandler("chaton",chatEn) function onChat(message,messageType) if messageType == 0 or messageType == 2 and chat == false then cancelEvent() end end end addEventHandler("onPlayerChat", root, onChat) Tested it. Now the chat works no matter what. When I /chatoff both chats still works =/ only teamchat should work when /chatoff, normal chat shouldn't. when /chaton both chats should work. Thanks chris. Link to comment
blinkerchris Posted March 23, 2014 Author Share Posted March 23, 2014 There is no errors in the debugscript or console. Link to comment
Anubhav Posted March 23, 2014 Share Posted March 23, 2014 I will post it tomorrow. I am going to sleep atm. Link to comment
WhoAmI Posted March 23, 2014 Share Posted March 23, 2014 Check this out local chat = true function chatDis(thePlayer) local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then outputChatBox("#E3E8B7The chat has been disabled by "..getPlayerName(thePlayer)..".",root,255, 255, 255, true) chat = false end end addCommandHandler("chatoff", chatDis) function chatEn(thePlayer) local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then outputChatBox("#E3E8B7The chat has been enabled by "..getPlayerName(thePlayer)..".",root,255, 255, 255, true) chat = true end end addCommandHandler("chaton", chatEn) function onChat ( _, messageType ) if ( messageType == 0 or messageType == 2 ) then if ( not chat ) then cancelEvent ( ) end end end addEventHandler ( "onPlayerChat", root, onChat ) Link to comment
Vision Posted March 23, 2014 Share Posted March 23, 2014 He wants to disable only the main chat local chat = true function chatDis(thePlayer) local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then outputChatBox("#E3E8B7The chat has been disabled by "..getPlayerName(thePlayer)..".",root,255, 255, 255, true) chat = false end end addCommandHandler("chatoff", chatDis) function chatEn(thePlayer) local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then outputChatBox("#E3E8B7The chat has been enabled by "..getPlayerName(thePlayer)..".",root,255, 255, 255, true) chat = true end end addCommandHandler("chaton", chatEn) function onChat ( _, messageType ) if ( messageType == 0 and not chat ) then cancelEvent ( ) end end addEventHandler ( "onPlayerChat", root, onChat ) Try this. Link to comment
Arnold-1 Posted March 23, 2014 Share Posted March 23, 2014 ahh guys, no error in the script, the only problem is that he made it in line 24: if messageType == 0 or messageType == 2 and chat == false then if the message type = 2 then it's team chat! he want team chat to work so it must be: if messageType == 0 and chat == false then EDIT: seems like me and Castro were posting in the same time Link to comment
NeO_DUFFMAN Posted March 23, 2014 Share Posted March 23, 2014 local chat = true function chatDis(thePlayer) if not chat then outputChatBox("#E3E8B7Chat is already disabled",thePlayer,255,255,255,true) return end local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then outputChatBox("#E3E8B7The chat has been disabled by "..getPlayerName(thePlayer)..".",root,255, 255, 255, true) chat = false end end addCommandHandler("chatoff", chatDis) function chatEn(thePlayer) if chat then outputChatBox("#E3E8B7Chat is already enabled",thePlayer,255,255,255,true) return end local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then outputChatBox("#E3E8B7The chat has been enabled by "..getPlayerName(thePlayer)..".",root,255, 255, 255, true) chat = true end end addCommandHandler("chaton",chatEn) addEventHandler("onPlayerChat",root, function (message,messageType) if messageType == 0 or messageType == 1 and not chat then cancelEvent() end end) Ohh boy...guess it would be nice to know if someone else is already posting in a particular topic Link to comment
blinkerchris Posted March 23, 2014 Author Share Posted March 23, 2014 local chat = true function chatDis(thePlayer) if not chat then outputChatBox("#E3E8B7Chat is already disabled",thePlayer,255,255,255,true) return end local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then outputChatBox("#E3E8B7The chat has been disabled by "..getPlayerName(thePlayer)..".",root,255, 255, 255, true) chat = false end end addCommandHandler("chatoff", chatDis) function chatEn(thePlayer) if chat then outputChatBox("#E3E8B7Chat is already enabled",thePlayer,255,255,255,true) return end local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then outputChatBox("#E3E8B7The chat has been enabled by "..getPlayerName(thePlayer)..".",root,255, 255, 255, true) chat = true end end addCommandHandler("chaton",chatEn) addEventHandler("onPlayerChat",root, function (message,messageType) if messageType == 0 or messageType == 1 and not chat then cancelEvent() end end) Ohh boy...guess it would be nice to know if someone else is already posting in a particular topic I'm using this one now, but it's not working 100% The problem is now that when I /chaton everything should work as normal, both chats should work. when /chatoff then ONLY mainchat should be disabled, teamchat should work. and mainchat doesn't work weither its on or not. Thanks chris Link to comment
Vision Posted March 23, 2014 Share Posted March 23, 2014 Did you try the code that I posted? 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