Jump to content

Multiple Same Commands Question [RESOLVED]


Recommended Posts

I don't even think this is actually possible, but it's worth a shot anyway:

I have a /Test1 command and then a /Test2 command that will perform the same exact function

but instead of doing something like this:

addCommandHandler("Test1",TestFunction) 
addCommandHandler("Test2",TestFunction) 

Is there a way of merging them together? Such as...

addCommandHandler("Test1" or "Test2",TestFunction) 

Edited by Guest
Link to comment

You can use this:

local _addCommandHandler = addCommandHandler 
  
function addCommandHandler ( commandName, func, restricted, caseSensitive, ... ) 
    if ( type ( commandName ) ~= "table" ) then 
        _addCommandHandler ( commandName, func, restricted, caseSensitive, ... ) 
    else 
        for index, command in ipairs ( commandName ) do 
            _addCommandHandler ( command, func, restricted, caseSensitive, ... ) 
        end 
    end 
end 
  
addCommandHandler ( { "hello", "world" }, -- Both commands will work for the same function. 
    function ( thePlayer, commandName ) 
        outputChatBox ( commandName ) 
    end 
) 

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...