Parsing Strings for Admin Commands

Custom Admin Commands

I am trying to create my own custom admin commands, they are going really well; until I realised that I wanted to be able to run more than one commands at a time.

Eg.

Ff/Player;Fire/Player/Really blue;Explode/Player

My script at the moment, would only run “Ff/Player”.
But I would like it to run through all commands…

I have tried using

string patterns

to find “;” and then add the next string into a table. That worked but it only captured the first command after “;”.
So in theory it just does:
Ff/Player
Fire/Player
And doesn’t check for any other commands.

I then tried to do a

loop

which didn’t go to plan, I then researched more about the topic and it stated about

GMatch

which I tried, but it didn’t collect the strings correctly.

After which, I asked one of my friends and they suggested creating a Tokenizer (Tokens), but i’m not quite sure how to create one…

I tried reading about them, but can’t find any wiki pages about them, I tried looking through the forum to find someone had created one before but didn’t explain how it worked so wasn’t helpful to me…

Does anyone have and links to pages that could help me with this, or possible provide a sample code on how they work so that I could have ago and try make one which fits into my project.

Thank you in advance.

1 Like

Did you use the arguments for Gmatch correctly? Did you try it as /[ ]+/ ?

Sorry for not being much help, I’ve only done this in Javascript with .split(/[ ]+/) , hope they’re similar enough to where you can try to get something.

Try this:

don’t name your variable string on Roblox :crazy_face:

That’s a similar way to how I completed mine, with string being the player message, splitting the message into different sections, using “/” as the splitter. But as soon as I tried to then add a command splitter “;” it just didn’t function…

For example, my first script would be the command analyser and would pass the following onto the next module:
local cmd = msg:match("([%w]+)"):lower()
Then in the next module which finds the correct command, parses it through to the module with the command name.
The module would then have a similar format to all commands, some have extra arguments for colour etc…

This one is for “ff”:

msg:lower():match(cmd.."%/([%p%w]+)")

It runs the cmd name, waits for the splitter “/” to find the player name and then gives them the ForceField.
However, how would I then detect the command splitter “;” to register another command after it.
Eg.

Ff/Player(splitter)Fire/Player/Colour
OR
Ff/Player(splitter)Fire/Player/Colour;Sparkles/Player/Colour

I just can’t seem to find a way to use “;” to then find the next command…

1 Like

I attempted 3 different string patterns to register just the command name after “;” (the split), but it just seemed to be collecting all alphanumerical strings, rather than just the ones after the split…

1 Like

Is string.split what you’re looking for?

string.split would go through all commands.

for i,v in ipairs(string.split("Ff/Player;Fire/Player/Really blue;Explode/Player",";")) do
    print(i,v)
end
--> 1  Ff/Player
--> 2  Fire/Player/Really blue
--> 3  Explode/Player

String Library Docs-

3 Likes

How on earth did I miss that!
That’s exactly what I want,
Thank you so much!

1 Like

If you are good at other web server languages, you can use Replit to host maybe python web server. and you make a http request to the server address.