Solved String contains value from list

  • 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.

Xletron

Member
Jul 3, 2020
4
0
0
35
Hi, I don't know that much about skript, but is it possible if I can check if a string contains one of the values from a list?

For example,
If string is "hello my name is xletron"
and if the list contains "name"

so it would trigger something as "name" is in the string

Maybe the list contains
Hello
Something
Yes

the strings are "hello im xletron"
"something hello"
"yes i am xletron"

Then all of these would trigger as they contain hello, something, yes.

But "noone is xletron" would not trigger as it doesnt contain anything from the list
 
Last edited:
Code:
# When the skript loads.
on load:
    # Add name to a list called list.
    add "name" to {list::*}
    add "something" to {list::*}

# When a player send a message.
on message:
    # Loop the list.
    loop {list::*}:
        # Check if message contains the loop value.
        if message contains loop-value:
            #do something here.

# Make a command. (/string hello my name is chrille)  
command /string [<text>]:
    # Trigger is so the command knows what to do.
    trigger:
        # Loop the list.
        loop {list::*}:
            # Check if argument 1 contains the loop value.
            if arg 1 contains loop-value:
                #do something here.

Hope this helps and explains it properly.
Message me on discord: Chrille#9088 for further help.
 
Status
Not open for further replies.