Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to get chat parameters? No idea where to start.

Asked by 5 years ago

Hello, I've been wondering how to get chat parameters like when you use admin commands you got the choices of all, me, others, admins, etc. I have no idea where to start with this and if you could tell me how or point me in the direction that would be appreciated.

0
Actually, I would use string.match. It’s much more efficient than string.sub in my opinion. I can go into more detail later if you want but all you need is here: https://wiki.roblox.com/index.php?title=Global_namespace/String_manipulation#string.match http://lua-users.org/wiki/PatternsTutorial https://www.lua.org/manual/5.3/manual.html#6.4.1 T1mes 230 — 5y

1 answer

Log in to vote
1
Answered by
chomboghai 2044 Moderation Voter Community Moderator
5 years ago

Just use string.sub.

If your admin command is ;kill DogeDark211, you can see that the first 6 characters are ;kill (including the space), and everything after that is the parameter. So using the method above we can receive the entire input by saying string.sub(";kill DogeDark211", 7).

The first argument is the string you'd like to get the substring of, usually you'd use a variable, and it'd look something more like string.sub(command, ...). The second argument is the index of the string you want to begin the substring at. For our case, the parameter starts at the 7th character in the string, so we start at 7. The third argument is the index you want the substring to end at. This argument is optional, and if we don't include it then the method will take the substring starting from your second argument, (or 7 in our case), until the end.

You would use the third argument when you have multiple parameters, such as ;tp me DogeDark211. Here, you would substring starting from 5 up until you detect a space, then substring again from that position until the end.

Hope this helps :)

0
Thank you. DogeDark211 81 — 5y
Ad

Answer this question