1. 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!

  2. LOOKING FOR A VERSION OF SKRIPT?

    You can always check out our Wiki for downloads and any other information about Skript!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Problem with list variables and “contains”

Discussion in 'Skript' started by D0XY, Jul 9, 2018.

Thread Status:
Not open for further replies.
  1. D0XY

    D0XY Member

    Joined:
    May 4, 2018
    Messages:
    35
    Likes Received:
    0
    Using newest version of Skript on MC 1.8.9.

    No add-ons. Would like to keep it this way.


    This is a very simple, broad version of my command:

    Code (Skript):
    1. else if arg 1 is “addrank”:
    2.     if {listvariable::*} contains “%arg-2%
    3.          message “already rank”
    4.     else:
    5.          add arg 2 to {listvariable::*}
    6.          message%arg-2% added”
    7. else if arg 1 is “removerank”:
    8.     if {listvariable::*} contains “%arg-2%”:
    9.          remove arg 2 from {listvariable::*}
    10.          message%arg-2% removed”
    11.     else:
    12.         message%arg-2% is not a rank!
    13. else if arg 1 is “clearranks”:
    14.     clear {listvariable::*}
    15.     message “cleared”
    16. else if arg 1 is “listranks”:
    17.     If size of {listvariable::*} < 1:
    18.         message “no ranks!
    19.     else:
    20.         message%{listvariable::*}%
    The problem is after I add the rank to {listvariable::*}, when I try to remove it, it says “examplerank1 is not a rank!”. When I use the list command, it clearly shows that it is a command. Also, after I used the remove command, when I add a rank which I already added before, it no longer stops me from doing so. I am pretty positive that the “contains” is the culprit to this problem. The “contains” seems to only be working for the addrank command. After entering the removecommand, it stops working.

    If this problem is confusing to understand, I will put a YouTube link here tomorrow.
     
  2. FinalPlayer024

    FinalPlayer024 Active Member

    Joined:
    Oct 19, 2017
    Messages:
    95
    Likes Received:
    4
    Code (Skript):
    1. loop {listvariable::*}:
    2.   loop-value = "%arg 2%"
    ?
     
  3. DieHollander_

    DieHollander_ Active Member

    Joined:
    Mar 25, 2018
    Messages:
    188
    Likes Received:
    12
    Code (Skript):
    1. function contains(1:object,2:objects) :: boolean:
    2.     loop {_2::*}:
    3.         if loop-value is {_1}:
    4.             return true
    5.     return false
    6.    
    7.    
    8. #Example:
    9. command /test:
    10.     trigger:
    11.         if contains(arg-2,{listvariable::*}) is true:
    12.             message "true"
     
  4. Efnilite

    Supporter

    Joined:
    May 12, 2018
    Messages:
    218
    Likes Received:
    15
    Medals:
    maybe try this if the others didnt work
    Code (Skript):
    1. if "%{listvariable::*}%" contains "%arg-2%":
     
  5. FinalPlayer024

    FinalPlayer024 Active Member

    Joined:
    Oct 19, 2017
    Messages:
    95
    Likes Received:
    4
    From Rezz's Snippets :emoji_stuck_out_tongue:
     
  6. DieHollander_

    DieHollander_ Active Member

    Joined:
    Mar 25, 2018
    Messages:
    188
    Likes Received:
    12
    No, its just basic coding.
     
  7. Mr_Simba

    Mr_Simba King of the Pridelands
    Moderator Supporter

    Joined:
    Dec 9, 2016
    Messages:
    257
    Likes Received:
    55
    Medals:
    When you say "newest version of Skript" do you mean Bensku's dev-36? Because the issue with "contains" checks not working is supposed to be fixed in the latest version.
     
  8. D0XY

    D0XY Member

    Joined:
    May 4, 2018
    Messages:
    35
    Likes Received:
    0
    Actually, I don’t know. I installed Skript from the official bukkit page 2 months ago. Probably isn’t the newest version anyway, xd.

    Would you mind giving me the link to the fork? I’m too lazy to find it right now, sorry.
    --- Double Post Merged, Jul 9, 2018, Original Post Date: Jul 9, 2018 ---
    Also, I might release this Skript later on SpigotMC, but do the players have to install this “Bensku Dev-36” for my code to work?
     
  9. Mr_Simba

    Mr_Simba King of the Pridelands
    Moderator Supporter

    Joined:
    Dec 9, 2016
    Messages:
    257
    Likes Received:
    55
    Medals:
    Yeah, they'll need the latest version to not get the same errors you are getting. But regardless most people in the Skript community use Bensku's fork, it's the de facto primary version of Skript nowadays. The latest versions can always be found here.
     
    • Agree Agree x 1
Thread Status:
Not open for further replies.

Share This Page

Loading...