Jump to content

How to trigger function when outputChatBox tries to output.


GTX

Recommended Posts

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...