AstroBurn Posted April 3, 2013 Share Posted April 3, 2013 (edited) Hello, i wanted to prevent scripts or map to spam the chatbox with messages, so i removed the right with the acl "function.outputChatBox" access="false"> it's working well for the non-admin scripts, but I just can't do the same for the maps, i tried by removing the right to all the acls, but the in-map scritps can still use outputChatBox. Someone could help me please? Edited April 5, 2013 by Guest Link to comment
Ludo Posted April 3, 2013 Share Posted April 3, 2013 Not tested: function preventSpam(message, element) if not (getElementType(element) == "player") then cancelEvent() end end addEventHandler("onChatMessage", getRootElement(), preventSpam) Link to comment
ZL|LuCaS Posted April 3, 2013 Share Posted April 3, 2013 Not tested: function preventSpam(message, element) if not (getElementType(element) == "player") then cancelEvent() end end addEventHandler("onChatMessage", getRootElement(), preventSpam) makes no sense. Link to comment
Ludo Posted April 3, 2013 Share Posted April 3, 2013 Not tested: function preventSpam(message, element) if not (getElementType(element) == "player") then cancelEvent() end end addEventHandler("onChatMessage", getRootElement(), preventSpam) makes no sense. Why? Link to comment
iPrestege Posted April 3, 2013 Share Posted April 3, 2013 onPlayerChat cancelEvent ?? What about this? And you can't cancel that event "onChatMessage" Link to comment
Ludo Posted April 3, 2013 Share Posted April 3, 2013 onPlayerChatcancelEvent ?? What about this? And you can't cancel that event "onChatMessage" That won't work, as the wiki says "This event is triggered when a player chats inside the chat box." So it won't work for resources' messages Link to comment
AstroBurn Posted April 3, 2013 Author Share Posted April 3, 2013 Thx for the help, it actually works if i use the client event: function preventSpam() if not (getElementType(source) == "player") then cancelEvent() end end addEventHandler("onClientChatMessage", getRootElement(), preventSpam) But it cancel all the chatbox msg, probably because the event doesn't return the element's name i don' tknow how to fix that Link to comment
Ludo Posted April 3, 2013 Share Posted April 3, 2013 But it cancel all the chatbox msg, probably because the event doesn't return the element's name i don' tknow how to fix that That's because the source of that event is the root element, so you aren't gonna get the resource that outputs the message. Link to comment
AstroBurn Posted April 3, 2013 Author Share Posted April 3, 2013 Well thanks, but it's not helping me in any ways, when i try with the server , onChatMessage, i can't cancel this event, and it doesn't output Clients messages if anyone have an idea to help me Link to comment
xXMADEXx Posted April 3, 2013 Share Posted April 3, 2013 You can try this, but its just something, not tested... addEventHandler("onChatMessage",root, function () if (getElementType(source) ~= "player") then cancelEvent() end end ) Link to comment
AstroBurn Posted April 4, 2013 Author Share Posted April 4, 2013 You can try this, but its just something, not tested... addEventHandler("onChatMessage",root, function () if (getElementType(source) ~= "player") then cancelEvent() end end ) i tried this, and it does nothing, it looks like we can't cancel this event + i tested it and if im not wrong it doesn't detect client outputChatBox Link to comment
Booo Posted April 4, 2013 Share Posted April 4, 2013 client [lua]function preventSpam() cancelEvent() outputChatBox("Chat Block",source) end addEventHandler("onClientChatMessage", getRootElement(), preventSpam) [/lua] or Server function blockChatMessage(a) if a ~= 911 then cancelEvent() cancelEvent() end end addEventHandler( "onPlayerChat", getRootElement(), blockChatMessage ) Link to comment
Castillo Posted April 4, 2013 Share Posted April 4, 2013 So, if the message is not 911 it cancels the event? that doesn't make any sense. Link to comment
xXMADEXx Posted April 4, 2013 Share Posted April 4, 2013 You can try this, but its just something, not tested... addEventHandler("onChatMessage",root, function () if (getElementType(source) ~= "player") then cancelEvent() end end ) i tried this, and it does nothing, it looks like we can't cancel this event + i tested it and if im not wrong it doesn't detect client outputChatBox type /debugscript 3 then restart the resource that this code is in, and tell me the error message you got. Link to comment
ZL|LuCaS Posted April 5, 2013 Share Posted April 5, 2013 You can try this, but its just something, not tested... addEventHandler("onChatMessage",root, function () if (getElementType(source) ~= "player") then cancelEvent() end end ) i tried this, and it does nothing, it looks like we can't cancel this event + i tested it and if im not wrong it doesn't detect client outputChatBox type /debugscript 3 then restart the resource that this code is in, and tell me the error message you got. by Mr.Pres[T]ege on Wed Apr 03, 2013 2:26 pm--[[ onPlayerChat ]]-- cancelEvent ?? What about this? And you can't cancel that event "onChatMessage" Link to comment
AstroBurn Posted April 5, 2013 Author Share Posted April 5, 2013 You can try this, but its just something, not tested... addEventHandler("onChatMessage",root, function () if (getElementType(source) ~= "player") then cancelEvent() end end ) i tried this, and it does nothing, it looks like we can't cancel this event + i tested it and if im not wrong it doesn't detect client outputChatBox type /debugscript 3 then restart the resource that this code is in, and tell me the error message you got. I am not getting any error message, it's simply like i can't cancel this event by Mr.Pres[T]ege on Wed Apr 03, 2013 2:26 pm--[[ onPlayerChat ]]-- cancelEvent ?? What about this? And you can't cancel that event "onChatMessage" I actually want to cancel scripts messages, not players ones Link to comment
Moderators IIYAMA Posted April 5, 2013 Moderators Share Posted April 5, 2013 (edited) [Removed] Edited April 5, 2013 by Guest Link to comment
Renkon Posted April 5, 2013 Share Posted April 5, 2013 Using ACL is the only wait sir. And you can manually modify the resources if you don't wanna show the message Link to comment
Cadu12 Posted April 5, 2013 Share Posted April 5, 2013 Please, next time read the wiki. Parametersstring theMessage, resource / element theElement theMessage: The text that was output to the chatbox theElement: Player element if chatbox output was done via say, teamsay or me. Resource if it was done via outputChatBox. function onChatMessage ( _, theElement ) if ( getElementType ( theElement ) ~= "player" ) then cancelEvent ( ) end end addEventHandler ( "onChatMessage", root, onChatMessage ) Link to comment
AstroBurn Posted April 5, 2013 Author Share Posted April 5, 2013 Please, next time read the wiki.Parametersstring theMessage, resource / element theElement theMessage: The text that was output to the chatbox theElement: Player element if chatbox output was done via say, teamsay or me. Resource if it was done via outputChatBox. function onChatMessage ( _, theElement ) if ( getElementType ( theElement ) ~= "player" ) then cancelEvent ( ) end end addEventHandler ( "onChatMessage", root, onChatMessage ) I actually got it, thanks for the help but it's still that "onChatMessage" is done in server, and it does not cancel the client outputchatbox, or maybe because of some other reason. At least i finished by preventing most of the spam by just adding this: addEventHandler("onClientChatMessage",root, function (msg) if msg == "" or msg:find('www.',1,true) then cancelEvent(true) end end ) So It's enough for me, there is no spam or pub, but the mapper can still use outputchatbox to comment his map. Thank to all who helped me in this thread. Link to comment
Cadu12 Posted April 5, 2013 Share Posted April 5, 2013 You're welcome. If you want cancel message all maps, you can use: if getResourceInfo(res, "type") == "map" then cancelEvent() end Server-side only. Link to comment
Sex* Posted April 9, 2013 Share Posted April 9, 2013 You're welcome. If you want cancel message all maps, you can use: if getResourceInfo(res, "type") == "map" then cancelEvent() end Server-side only. Well, wtf is wrong with this then? Crashed my script. addEvent("onMapStarting",true) addEventHandler("onMapStarting",getRootElement(), function ( ) if getResourceInfo(res, "type") == "map" then cancelEvent() end Link to comment
Kenix Posted April 9, 2013 Share Posted April 9, 2013 You're welcome. If you want cancel message all maps, you can use: if getResourceInfo(res, "type") == "map" then cancelEvent() end Server-side only. Well, wtf is wrong with this then? Crashed my script. addEvent("onMapStarting",true) addEventHandler("onMapStarting",getRootElement(), function ( ) if getResourceInfo(res, "type") == "map" then cancelEvent() end You forgot ')' after condition. Link to comment
Sex* Posted April 10, 2013 Share Posted April 10, 2013 In what line did i forgot that? 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