Hi, I'm trying to make admin commands which allow you to run more than one command at a time; Almost like batch.

At the moment, my code can read command names, pass it to the parser who then distributes to the correct module to perform the action. However, like I stated, I want to be able to fire more than one command at a time.

Key:

/ - Next argument (match pattern)

; - Split commands

Eg.

At the moment: Fire/Player/Colour What I want: Fire/Player/Colour;Ff/Player

My code:

game.Players.PlayerAdded:Connect(function(Player)
print(Player.Name, Player.userId)
Player.Chatted:Connect(function(msg)
	local isAdmin = {[14946581] = true, [22] = true, [22] = true}

	local cmd = msg:match("([%w]+)"):lower()
	
	
--if isAdmin[Player.UserId] then
	
local Sender = require(script.Functions.Sender)
  Sender.Send(Player,cmd,msg)
wait()
local xtra = msg:match("%;([%w]+)")
print(xtra)

if xtra ~= nil then
	wait(1)
	local cmd = xtra
	Sender.Send(Player,cmd,msg)
end

--end
	end)
	
end)

With this script at the moment, it allows me to run "ff/player" but if I add a ";" after the command, it runs the second command and not the first. Eg.

"kill/player;ff/player" Instead of reading it and going, right kill player, it skips to the ";" and does the "ff" part instead...

Any ideas how to fix this so I can use more than one command at a time?

Thank you.

6 comments

1

What about having some sort of queue that searches through the command string and every time it recognizes a command, add that to the queue (an array of commands to perform) then perform all the commands when done reading the string?

0

I like that idea but i'm not quite sure how to perform it... Ahaha sorry!

0

Which bit? You seem to be doing well with using regular expressions to find each command in the string. If you need help with that bit, just ask. The other bit where I was talking about a queue I meant each time you find a command in the string, add it to a table and then when you're done call each command in the table.

1

by regular expressions i meant the character class sets bit on this page. didn't know roblox called them something different. i'm bad with wording. https://developer.roblox.com/en-us/articles/string-patterns-reference

0

I understand regular expressions - String Patterns - But i'm unsure about creating a queue. I just tried it out with the "table.insert" and it worked, but only for one item found. Eg. ff/player;unff/player;unsparkles/player. It only captures the first ; which is unff...

0

Plus i'm unsure how I would allow the commands to continue from where the command last left off. Eg, ff/player;unfire/player;sparkles player. As far as I know, the message would resume back from the start...