eduher Posted July 26, 2016 Posted July 26, 2016 Hello who can tell me what I can function How to use DOS command to run into one of EXAMPLE : I have two commands A command ( run a function) B command (executes another function ) But I want a C- command run the A and B Command could help someone
Captain Cody Posted July 26, 2016 Posted July 26, 2016 addCommandHandler("testa",testfunction) addCommandHandler("testb",testfunction2) addCommandHandler("testc",{testfunction,testfunction2})
shaio Posted July 26, 2016 Posted July 26, 2016 Server.lua - function functionA(player,cmd) end function functionB(player,cmd) end addCommandHandler("testa",functionA) addCommandHandler("testb",functionB) addCommandHandler("testc",{functionA,functionB}) Like Cody said, but you need the player,cmd inside of () on function - IF SERVERSIDE, if its clientside then just cmd inside () Client.lua - function functionA(cmd) end function functionB(cmd) end addCommandHandler("testa",functionA) addCommandHandler("testb",functionB) addCommandHandler("testc",{functionA,functionB})
Walid Posted July 26, 2016 Posted July 26, 2016 @Codyl , What's this ???? you need to added the function name not a table.
.:HyPeX:. Posted July 26, 2016 Posted July 26, 2016 @Codyl , What's this ???? you need to added the function name not a table. I think id need to run tests, but i belive this should work due to how lua works.
Captain Cody Posted July 26, 2016 Posted July 26, 2016 @Shaio you don't need to put CMD in the function at all @Walid Saw it in a script a while back that I was fixing, it gave no errors and worked.
Walid Posted July 26, 2016 Posted July 26, 2016 @Walid Saw it in a script a while back that I was fixing, it gave no errors and worked. Try it by yourself and post the code here.
Captain Cody Posted July 26, 2016 Posted July 26, 2016 That's odd, I know for a fact I've seen it used before, and it for sure worked. Maybe I just have wrong format. addCommandHandler("testa",testfunction) addCommandHandler("testb",testfunction2) addCommandHandler("testc",testfunction) addCommandHandler("testc",testfunction2) but try that I guess.
Walid Posted July 26, 2016 Posted July 26, 2016 That's odd, I know for a fact I've seen it used before, and it for sure worked. Maybe I just have wrong format. It's very simple it can be like this: Method 1: -- function A function functionA(player,cmd) outputChatBox("test A command",player) end addCommandHandler("testa",functionA) -- function B function functionB(player,cmd) outputChatBox("test B command",player) end addCommandHandler("testb",functionB) local functions = {functionA,functionB} for i,v in pairs(functions) do addCommandHandler("testc",v) end Method 2: function allfunctions(player,cmd) if cmd == "testa" then -- testa code here elseif cmd == "testb" then -- testb code here elseif cmd == "testc" -- testa code here -- testb code here end end addCommandHandler("testa",allfunctions) addCommandHandler("testb",allfunctions) addCommandHandler("testc",allfunctions)
Captain Cody Posted July 26, 2016 Posted July 26, 2016 Well what I was saying is, there is a way to do the command handler with a table, I just forgot the right format
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