Solved Variables comparison with numbers

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

HKPNW-Owner

Member
Feb 2, 2017
33
0
6
27
Hello,
Im facing a problem for comparing the variables which are numbers.


Code:
command /checkb:
    trigger:
        set {test.a} to 10
        set {test.b} to 11
        if {test.a} > "9":
            send "yes"
        else:
            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?
 
I'm not sure but it works when you replace ">" with "is greater than"

Code:
command /checkb:
    trigger:
        set {test.a} to 10
        set {test.b} to 11
        if {test.a} is greater than 9:
            send "yes"
        else:
            send "no"
 
I'm not sure but it works when you replace ">" with "is greater than"

Code:
command /checkb:
    trigger:
        set {test.a} to 10
        set {test.b} to 11
        if {test.a} is greater than 9:
            send "yes"
        else:
            send "no"
Still showing "no" for me. I've no idea why.
 
Still showing "no" for me. I've no idea why.
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:
command /checkb:
    trigger:
        set {test.a} to 10
        set {test.b} to 11
        if {test.a} is greater than 9:
            send "yes"
        else:
            send "no"
 
As Kush said, You can't compare a number with text, you can still use these > = <
 
Status
Not open for further replies.