GTX Posted April 11, 2014 Share Posted April 11, 2014 Hello. I want to cancel resource's outputChatBox. I tried with onChatMessage but I can't use cancelEvent there. If I try onClientChatMessage, I can't get the resource. Any other idea? Because I want to cancel outputChatBox from another resource/map. There are like 1000 maps and I can't override outputChatBox 1000 times... Thanks in advance. Link to comment
Bonsai Posted April 11, 2014 Share Posted April 11, 2014 I don't know any other way than overriding. You could create a small script that does this and use some tool to copy it into every resource + some function that goes through all resources and adds it to meta. Link to comment
Mr_Moose Posted April 11, 2014 Share Posted April 11, 2014 function preventSpam(text) if string.match(text,"text") then cancelEvent() -- don't output it end end addEventHandler("onClientChatMessage", getRootElement(), preventSpam) The solution is onClientChatMessage, just make sure that you add this code in a resource that starts before the resources who's chat box you want to block, otherwise it has no effect. That can be reorganize the resources in server config since they will start in the order they are listed in. Also remember to set "text" to a part of the text output you want to block. Link to comment
GTX Posted April 11, 2014 Author Share Posted April 11, 2014 function preventSpam(text) if string.match(text,"text") then cancelEvent() -- don't output it end end addEventHandler("onClientChatMessage", getRootElement(), preventSpam) The solution is onClientChatMessage, just make sure that you add this code in a resource that starts before the resources who's chat box you want to block, otherwise it has no effect. That can be reorganize the resources in server config since they will start in the order they are listed in. Also remember to set "text" to a part of the text output you want to block. I wanted to get resource, not text. I don't know any other way than overriding.You could create a small script that does this and use some tool to copy it into every resource + some function that goes through all resources and adds it to meta. I was thinking about that too. Thanks, I will try it. Link to comment
Mr_Moose Posted April 12, 2014 Share Posted April 12, 2014 I'm sure you know what kind of text you want to block, otherwise just change line 2 to check for resources instead with these functions: resource getResourceFromName ( string resourceName ) string getResourceName ( resource res ) The important thing is that onClientChatMessage is added before the resources you want to disable chat outputs for. 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