Hello, I’m making an admin command and I want to give a reason when you use a command.
Ex:
/kick player no cheating
How would I make “no cheating” into one string?
Thank you.
Hello, I’m making an admin command and I want to give a reason when you use a command.
Ex:
/kick player no cheating
How would I make “no cheating” into one string?
Thank you.
How would I get the ignore the others part though? I know I have to loop through the strings and ignore it, but how would I add it?
for _, word in pairs(message) do
if not word[1] and not word[2] then
table.concat(word3+)
end
end
That was an example I don’t if it will work though.
Thank you I’ll try that
Use the third and fourth parameters to indicate the starting and ending index of the array. In your case, you would only need to use the third parameter to indicate the start.
Use the builtin select()
function to splice the elements and then concat the end portion
The first parameter tells it at what index to start the splice
local command = "kick player no cheating abc abc abc"
local elements = {}
for element in string.gmatch(command, "([^ ]+)") do
table.insert(elements, element)
end
local str = table.concat({select(3, unpack(elements))}, ' ')
print(str) --> no cheating abc abc abc
There is no need to do all of that. table.concat()
allows you to specify starting and ending indices.
Can you give me a code example please. I think I got it, but I’m not sure. I got this so far:
table.concat() is a documented function.
you originally said table.join
and then edited it, mb
Following the code sample you sent above: table.concat(message, " ", 3)
Just remove the first two arguments out of the split since it’s logically the command and the target.
local commandGiven = "/kick player no cheating"
local split = string.split(commandGiven, ' ')
local reason = table.concat(split, " ", 3)
Thank you, I probably should have looked at the document first I didn’t know you have to add the number after
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.