Krasher I'd rather do this:
@name Array Test
@persist Players:array
runOnChat(1)
LS = owner():lastSaid():explode(" ")
Clk = chatClk(owner())
if(Clk & LS:string(1) == "/r")
{
findByClass("player")
Players = findToArray()
}
if(Clk & LS:string(1) == "/i")
{
print(Players[LS:string(2):toNumber(),entity]:name())
}
Players:array will hold all the players the chip finds in the "/r" if-statement (the first if line.)
If you type /r again all the indexes of the old will be replaced with the new find values.
LS = owner():lastSaid():explode(" ")this is similar to krashers but instead of :lower() its :explode(" ") which turns it into an array.
This array makes an index for each space you type and the value for that index is anything but a space. Example:
this is a test.
Index|Value
1: this
2: is
3: a
4: test.
Clk = chatClk(owner())You don't have to use this, I do in all my chat cmd e2's just because I believe its good coding practice.
Similar to above, when you have used the /r cmd it will make the Players:array equal to what it finds. And when you type /i <value> it will print what it finds at that index. Example again:
Index | Name
1. Bob
2. Joe
3. Dirt
/i 1 = Bob
/i 2 = Joe
/i 3 = Dirt
Any value under 1 and any value over 3 will still run the chip and print a "space"
also if you do something like below:
/i tom
it will also run the chip but will not be of much help.
but the way the /r is coded, it will run even if you do this:
/r tom
I'm not much of the explainer online meet me ingame and I'm more of a help
P.s sry about stealing you thread krasher