I want to be able to make chat commands that work with multiple parameters. I can do single parameter commands, such as: /kick or /create , but I want to be able to things such as: /add or /ban . I'm trying to accomplish this for my universe place, where each player can have their own place, but also be able to control who can come in it. Much like VIP servers, but more controlled in my honest opinion. :)
✓ ANSWER ACCEPTED
How to make advanced chat commands? [SOLVED]
1 answer
✓ Accepted answer
You could write a function which separates the input into a table of values (so for example "/kick " would produce {"/kick", ""}) and then work on those values. An example of such a function (which is probably much less efficient than what it could be; there are probably better examples out there) is this:
function Split(input)
local CurrentWord, ToReturn = "", {}
for i = 1, #input do
if input:sub(i, i) == " " and CurrentWord ~= "" then
table.insert(ToReturn, CurrentWord)
CurrentWord = ""
else
CurrentWord = CurrentWord .. input:sub(i, i)
end
end
table.insert(ToReturn, CurrentWord)
return ToReturn
end
I'm assuming you know how to make simple chat commands.
1 comment
0
You are so helpful! :) I thank you very much as in my almost 7 years of scripting, I never thought to do it that way! :)
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
If IDidMakeThat answered your question, then why not hit the accept answer button below his name?
It wasn't an option when I responded. :/