Solved Can't read if variable is set?

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

SmallDev

Member
Apr 6, 2020
39
0
6
I'm making a shop, and have a lot of things working now, but I want to check if a player has his or her boost set up, if not I want to set it to 1, but when I check if it is, I always get the output that it wasn't any help would be appreciated thx.
Code:
on right click on entity:
            if name of entity is "Ye Old Fisherman":
                        if player's held item is not a cod:
                                    send "&c&lThat's not a fish!!!!!!" to player
                        else:                           
                                    if {_Boost.%player%} is set:
                                                set {_Money::1} to 10
                                                if lore of held item contains "&7Caught":   
                                                            if held item's lore contains "cm":
                                                                        set {_Original} to held item's lore
                                                                        delete line 2 of held item's lore
                                                                        set line 1 of held item's lore to regex replace all "cm" with "" in held item's lore
                                                                        set {_lore::1} to held item's lore
                                                                        set {_lore::2} to uncolored {_lore::1}
                                                                        set lore of held item to {_Original}
                                                                        set {_lore::3} to {_lore::2} parsed as a number
                                                                        remove 1 of held item from player
                                                                        add {_lore::3} to player's balance
                                                                        send "&6$%{_lore::2}% &fwas recieved!!!" to player
                                                                        delete {_Money::*}
                                                                        delete {_lore::*}
                                                                        delete {_Original}
                                                                        delete {_SellMultiplier}
                                    else if {_Boost.%player%} is not set:
                                                set {_Boost.%player%} to 1
                                                send "&5Your All Set!!!!!" to player
 
Try to add after "if {_Boost.%player%} is set:" this:

Code:
if {_Boost.%player%} is 1:

and for the else you can use your messages from the "else" query for "if {_Boost.%player%} is set:"
 
I'm making a shop, and have a lot of things working now, but I want to check if a player has his or her boost set up, if not I want to set it to 1, but when I check if it is, I always get the output that it wasn't any help would be appreciated thx.
Code:
on right click on entity:
            if name of entity is "Ye Old Fisherman":
                        if player's held item is not a cod:
                                    send "&c&lThat's not a fish!!!!!!" to player
                        else:                          
                                    if {_Boost.%player%} is set:
                                                set {_Money::1} to 10
                                                if lore of held item contains "&7Caught":  
                                                            if held item's lore contains "cm":
                                                                        set {_Original} to held item's lore
                                                                        delete line 2 of held item's lore
                                                                        set line 1 of held item's lore to regex replace all "cm" with "" in held item's lore
                                                                        set {_lore::1} to held item's lore
                                                                        set {_lore::2} to uncolored {_lore::1}
                                                                        set lore of held item to {_Original}
                                                                        set {_lore::3} to {_lore::2} parsed as a number
                                                                        remove 1 of held item from player
                                                                        add {_lore::3} to player's balance
                                                                        send "&6$%{_lore::2}% &fwas recieved!!!" to player
                                                                        delete {_Money::*}
                                                                        delete {_lore::*}
                                                                        delete {_Original}
                                                                        delete {_SellMultiplier}
                                    else if {_Boost.%player%} is not set:
                                                set {_Boost.%player%} to 1
                                                send "&5Your All Set!!!!!" to player
Are you aware that every variable that starts with an underscore (_) is local, meaning it will be deleted after the trigger ends.
 
Status
Not open for further replies.