Solved Need to know something before I make this Skript

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

TobyMinceraft

Member
Jul 21, 2019
18
2
3
25
Hi, all. No, I don't need help with a script I currently have, but rather I need to know if what I'm about to do is even possible using Skript or an add-on. I will try my best to explain, but even me saying it in my head is confusing. Here goes.

I'm creating a script that will search a variable list (known in my script as a "database", but it's just a list), show this list to the player, and then the player can do as they wish with that info. I'm wondering if it's possible to search a list (based on command arguments) for specific results, but ONLY show results matching a certain argument (negating the rest of the info in the lists). I will be using multiple lists. I do not want to do this all manually, but I can if need be. If you're still reading this, I hope I haven't confused you by now.

TL;DR
Search a variable list for a specified argument, and show only the matching results in chat

Minecraft Version: 1.14.3 (for certain reasons)
Server Version: PaperSpigot, git-Paper-134 (MC: 1.14.3) (again, for certain reasons)
Skript Plugin Version: Skript-2.4-beta7 (fork by bensku)
Addons: SkQuery 4.1.1, Ersatz 1.0
 
Hi, all. No, I don't need help with a script I currently have, but rather I need to know if what I'm about to do is even possible using Skript or an add-on. I will try my best to explain, but even me saying it in my head is confusing. Here goes.

I'm creating a script that will search a variable list (known in my script as a "database", but it's just a list), show this list to the player, and then the player can do as they wish with that info. I'm wondering if it's possible to search a list (based on command arguments) for specific results, but ONLY show results matching a certain argument (negating the rest of the info in the lists). I will be using multiple lists. I do not want to do this all manually, but I can if need be. If you're still reading this, I hope I haven't confused you by now.

TL;DR
Search a variable list for a specified argument, and show only the matching results in chat

Minecraft Version: 1.14.3 (for certain reasons)
Server Version: PaperSpigot, git-Paper-134 (MC: 1.14.3) (again, for certain reasons)
Skript Plugin Version: Skript-2.4-beta7 (fork by bensku)
Addons: SkQuery 4.1.1, Ersatz 1.0
This isn't very hard to do, you can just loop the list, check if the loop-value is what you want (e.g. `if loop-value contains "test":`), and if so, send it to the player. Example:

Code:
loop {_list::*}:
    if loop-value contains "query":
        message loop-value
 
You see, this is why the forums exist, because the wiki (even the ones by bensku and Njol) did not help with what I needed.
Thank you for helping!
 
I know how to check if a list contains the value. I just needed skript to send all matching results from said list.
Oh ok sec
[doublepost=1569515928,1569515772][/doublepost]
I know how to check if a list contains the value. I just needed skript to send all matching results from said list.
Code:
loop {list::*}:
    if loop-value contains "%arg-1%":
        send "%loop-index% %loop-value%"

Ok the other kids thing was wrong anyway this is it.

Sends: 1. %arg-1%bot
2. %arg-1%no
3. %arg-1%hi
4. %arg-1%weird
[doublepost=1569522143][/doublepost]
Code:
command /list [<text>] [<text>]:
    trigger:
        if arg-1 is "help":
            send "&cHelp:%nl%&7/list search [Name]%nl%&7/list add [Name]%nl%&7/list remove%nl%&7/list show"
        if arg-1 is not set:
            if arg-2 is not set:
                send "&c/list help"
        if arg-1 is "add":
            if {listv2::*} contains arg-2:
                send "&c%arg-2% already exists!"
            else:
                add arg-2 to {listv2::*}
                send "&aSucessfully added %arg-2% &ato the list."
        if arg-1 is "search":
            if {list::*} contains arg-2:
                loop {list::*}:
                    if loop-value contains arg-2:
                        send "&c%loop-index%&f: %loop-value%"
        if arg-1 is "remove":
            if {list::*} contains arg-2:
                remove arg-2 from {list::*}
                send "&aSucessfully removed %arg-2% &afrom the list."
        if arg-1 is "show":
            loop {list::*}:
                send "%loop-index% %loop-value%"

Here's an example
[doublepost=1569522218][/doublepost]Also contains will register words as %arg-1%withextraonit
If you want only specific things use =
 
With what I was wanting to do, it actually doesn't matter the words with extra text, as the extra text would actually be more words.
I do thank you for helping, though. Will be testing more soon.
 
Status
Not open for further replies.