GTX Posted January 17, 2013 Share Posted January 17, 2013 For example I have: outputChatBox"hi" Then I want to cancel this (with cancelEvent() or something). So, it will not output "hi" into chatbox. Got it? Thanks in advance! Link to comment
DiSaMe Posted January 17, 2013 Share Posted January 17, 2013 Put this code in the resources which use outputChatBox: addEvent("onOutputChatBox", false) _outputChatBox = outputChatBox function outputChatBox(text, visibleTo, r, g, b, colorCoded) local success = triggerEvent("onOutputChatBox", root, text, visibleTo, r, g, b, colorCoded) if success then return _outputChatBox(text, visibleTo, r, g, b, colorCoded) else return false end end Then cancelling the event "onOutputChatBox" will make triggerEvent return false, therefore preventing the true outputChatBox (which was renamed to _outputChatBox) function from being called: function cancelMessage(text, visibleTo, r, g, b, colorCoded) if text == "hi" then cancelEvent() end end addEventHandler("onOutputChatBox", root, cancelMessage) Link to comment
GTX Posted January 17, 2013 Author Share Posted January 17, 2013 Thanks but there are about 1000 resources which have to be cancelled. Is there another way? Link to comment
Smart. Posted January 17, 2013 Share Posted January 17, 2013 https://wiki.multitheftauto.com/wiki/OnChatMessage Link to comment
DiSaMe Posted January 17, 2013 Share Posted January 17, 2013 Oh, damn, so my code is useless Link to comment
GTX Posted January 20, 2013 Author Share Posted January 20, 2013 https://wiki.multitheftauto.com/wiki/OnChatMessage Thanks! But how do I check if chatbox outputs a resource? And if this resource is a map? Link to comment
3NAD Posted January 20, 2013 Share Posted January 20, 2013 Did you mean this, getResourceInfo Link to comment
Anderl Posted January 20, 2013 Share Posted January 20, 2013 https://wiki.multitheftauto.com/wiki/OnChatMessage Thanks! But how do I check if chatbox outputs a resource? And if this resource is a map? Chatbox can't output a resource, you probably wanted to said "outputs a resource name". If so, use getResources, iterate through the array returned by it and check if the resource's name is the one outputted. Use getResourceInfo to find out resource's name and its details ( type, author, description, ... ). Link to comment
Cadu12 Posted January 20, 2013 Share Posted January 20, 2013 theElement: Player element if chatbox output was done via say, teamsay or me. Resource if it was done via outputChatBox. You can use getResourceInfo with that. Link to comment
csiguusz Posted January 20, 2013 Share Posted January 20, 2013 Oh, damn, so my code is useless Not useless, it's awesome. I like your idea and I always like to learn new things, so maybe I will use this once. 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