ReZurrecti0n Posted May 26, 2012 Share Posted May 26, 2012 (edited) 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 May 27, 2012 by Guest Link to comment
Guest Guest4401 Posted May 26, 2012 Share Posted May 26, 2012 No, you can't merge like that. If you merge it with or, only /Test1 will work and not /Test2 Link to comment
ReZurrecti0n Posted May 26, 2012 Author Share Posted May 26, 2012 Yea I didn't think it was possible, thanx for the response Link to comment
Castillo Posted May 26, 2012 Share Posted May 26, 2012 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
ReZurrecti0n Posted May 27, 2012 Author Share Posted May 27, 2012 (edited) Thank you Solid Snake 14, I appreciate the response... I'll give it a shot at my next chance Update: Works like a charm, thanx again Edited May 27, 2012 by Guest Link to comment
Castillo Posted May 27, 2012 Share Posted May 27, 2012 You're welcome. P.S: It works, I've tested it. 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