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 Variables comparison with numbers

Discussion in 'Skript' started by HKPNW-Owner, Jul 3, 2020.

Thread Status:
Not open for further replies.
  1. HKPNW-Owner

    HKPNW-Owner Member

    Joined:
    Feb 2, 2017
    Messages:
    33
    Likes Received:
    0
    Hello,
    Im facing a problem for comparing the variables which are numbers.


    Code (Text):
    1. command /checkb:
    2.     trigger:
    3.         set {test.a} to 10
    4.         set {test.b} to 11
    5.         if {test.a} > "9":
    6.             send "yes"
    7.         else:
    8.             send "no"
    I tried something like the codes above. It showed "No" after the command be issued. What's wrong with the comparison of variables? How can i solve this?
     
  2. Kush

    Kush Member

    Joined:
    Jan 29, 2017
    Messages:
    29
    Likes Received:
    2
    I'm not sure but it works when you replace ">" with "is greater than"

    Code (Text):
    1. command /checkb:
    2.     trigger:
    3.         set {test.a} to 10
    4.         set {test.b} to 11
    5.         if {test.a} is greater than 9:
    6.             send "yes"
    7.         else:
    8.             send "no"
     
  3. HKPNW-Owner

    HKPNW-Owner Member

    Joined:
    Feb 2, 2017
    Messages:
    33
    Likes Received:
    0
    Still showing "no" for me. I've no idea why.
     
  4. Kush

    Kush Member

    Joined:
    Jan 29, 2017
    Messages:
    29
    Likes Received:
    2
    I see in your main code you're putting quotes around the number 9, if you do this it won't work. I'm pretty sure this is because you are setting your variable to a number and when you try to read something with quotes it think it's a text. Use it exactly like i'v shown:

    Code (Text):
    1. command /checkb:
    2.     trigger:
    3.         set {test.a} to 10
    4.         set {test.b} to 11
    5.         if {test.a} is greater than 9:
    6.             send "yes"
    7.         else:
    8.             send "no"
     
  5. Juffix

    Juffix Member

    Joined:
    Apr 7, 2019
    Messages:
    19
    Likes Received:
    4
    As Kush said, You can't compare a number with text, you can still use these > = <
     
  6. HKPNW-Owner

    HKPNW-Owner Member

    Joined:
    Feb 2, 2017
    Messages:
    33
    Likes Received:
    0
    Solved. Thanks! :emoji_grinning:
     
Thread Status:
Not open for further replies.

Share This Page

Loading...