itHyperoX Posted November 12, 2017 Share Posted November 12, 2017 Hi, how can i add two table.concat into 1 function ? addCommandHandler("oxquestion",function(player, cmd, ..., ...) local questionText = table.concat({ ... }, " ") local answerText = table.concat({ ... }, " ") end) debug: "expected near ','.. Link to comment
Tails Posted November 12, 2017 Share Posted November 12, 2017 no, but ... just contains all the arguments, you can do args = {...} then do table.concat(args[1], " ") but better would be to use the global var 'arg' to do this: local questionText = table.concat(arg[1], " ") local answerText = table.concat(arg[2], " ") hope this helps Link to comment
Administrators Lpsd Posted November 12, 2017 Administrators Share Posted November 12, 2017 (edited) You don't. You need the command syntax to be different, such as: /oxquestion This is the question text|This is the answer text addCommandHandler("oxquestion",function(player, cmd, ...) local t = table.concat({ ... }, " ") local questionTable = {} local answerTable = {} local switch = false for i,v in ipairs(t) do if v == "|" then switch = true else if switch then table.insert(answerTable, v) else table.insert(questionTable, v) end end table.remove(t, i) end end) "|" is the separator for question/answer. Edited November 12, 2017 by LopSided_ 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