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.

Solved If statement behaves differently in on craft event and command event

Discussion in 'Skript' started by grindser, Sep 14, 2021.

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

    grindser Member

    Joined:
    Sep 14, 2021
    Messages:
    14
    Likes Received:
    0
    I've got an on craft event that checks whether or not an item can be found in an array, however, the if statement will always output the false statement. When making a command with the exact same code, I get the expected results.

    Code (Text):
    1.  
    2. command /check <text>:
    3.     trigger:
    4.         if {list::*} contains arg-1:
    5.             send "Legal"
    6.         else:
    7.             send "Illegal"
    8.  
    9. on craft:
    10.     send "Checking if %event-item% can be found in the array"
    11.     if {list::*} contains event-item:
    12.         send "Legal"
    13.     else:
    14.         send "Illegal"
    The command will output "Legal" if the item name can be found, but the on craft event will always output "Illegal"
     
  2. Best Answer:
    Post #2 by TheCubPlays, Sep 14, 2021
  3. TheCubPlays

    TheCubPlays Member

    Joined:
    Jun 22, 2021
    Messages:
    42
    Likes Received:
    3
    I think that the issue is that on the second part of the code, you need to replace event-item with "%event-item%" because it can't know if it's a string or not.
     
  4. Minecoll_YT

    Supporter Forums Helper

    Joined:
    Dec 2, 2018
    Messages:
    650
    Likes Received:
    40
    try:
    Code (Text):
    1. if "%{list::*}%" contains "%event-item%":
    but that could lead to some issues
     
  5. grindser

    grindser Member

    Joined:
    Sep 14, 2021
    Messages:
    14
    Likes Received:
    0
    Awesome, that worked. Thanks!
     
Thread Status:
Not open for further replies.

Share This Page

Loading...