I don't recieve items when I click on the shop

Discussion in 'Skript' started by SoloStrafe, Mar 16, 2019.

  1. Please help:
    Code (Text):
    command /shop:
        trigger:
            open chest with 1 row named "&c&lMINEPORT &8- &7Shop" to player
            wait 1 tick
            format slot 0 of player with a diamond sword with lore "&c&lMINEPORT &8- &7{@DSwordMoney}$" to close then run [make console execute command "buydsword %player%"]
            format slot 1 of player with a bow with lore "&c&lMINEPORT &8- &7{@BowMoney}$" to close then run [make console execute command "buybow %player%"]
            format slot 2 of player with a arrow with lore "&c&lMINEPORT &8- &7{@ArrowMoney}$" to close then run [make console execute command "buyarrows %player%"]
            format slot 3 of player with a firework with lore "&c&lMINEPORT &8- &7{@FireworkMoney}" to close then run [make console execute command "buyfire %player%"]

    on skript start:
        set {_dsword} to diamond sword
        enchant {_dsword} with sharpness 1000
        enchant {_dsword} with unbreaking 1000

    command /buydsword <player>:
        executable by: console
        trigger:
            if {balance.%arg-1%} is greater than {@DSwordMoney}:
                give 1 of {_dsword} to arg-1
                send "&c&lMINEPORT &8- &7Item bought."
            if {balance.%arg-1%} is less than {@DSwordMoney}:
                send "&c&lMINEPORT &8- &7You do not have enough money"
    Idk whats wrong, there's nothing wrong when I do /skript reload all,

    its just when I click on the diamond sword in the shop menu, it doesn't say or give me anything
     
  2. Variables that start with an underscore are called Local Variables.
    They are local to the event they are in.
    So when your script is loaded, those variables are set and never used.

    Your command will not use those variables since they are local to the load event.

    just change this line
    Code (Text):
    give 1 of {_dsword} to arg-1
    to
    Code (Text):
    give arg-1 1 of diamond sword of sharpness 1000 and unbreaking 1000
     
  3. Hey, that would've worked but that is not the issue, I just found out that the problem is with the
    Code (Text):
    if {balance.%arg-1%} is greater than {@DSwordMoney}:
    when it is removed, it works perfectly, with it, the item doesn't come into my inventory
     
  4. Show the code where you set the balance variable and the option
     
  5. Here's my whole code
    Code (Text):
    options:
        moneyperkill: 200
        DSwordMoney: 5000
        BowMoney: 10000
        ArrowMoney: 200
        FireworkMoney: 1000
    #Change numbers to whatever number

    every 1 second:
        loop all players:
            if {balance.%loop-player%} is not set:
                set {balance.%loop-player%} to 0

    on first join:
        set {balance.%player%} to 0
    on death:
        if player is attacker:
            add 200 to {balance.%attacker%}

    command /balance:
        trigger:
            send "&c&lMINEPORT &8- &7%{balance.%player%}%$"
    command /shop:
        trigger:
            open chest with 1 row named "&c&lMINEPORT &8- &7Shop" to player
            wait 1 tick
            format slot 0 of player with a diamond sword with lore "&c&lMINEPORT &8- &7{@DSwordMoney}$" to close then run [make console execute command "buydsword %player%"]
            format slot 1 of player with a bow with lore "&c&lMINEPORT &8- &7{@BowMoney}$" to close then run [make player execute command "/buybow"]
            format slot 2 of player with a arrow with lore "&c&lMINEPORT &8- &7{@ArrowMoney}$" to close then run [make console execute command "buyarrows %player%"]
            format slot 3 of player with a firework with lore "&c&lMINEPORT &8- &7{@FireworkMoney}" to close then run [make console execute command "buyfire %player%"]


    command /buydsword <player>:
        executable by: player
        trigger:
            if {balance.%arg-1%} is greater than {@DSwordMoney}:
                give 1 of diamond sword of sharpness 10000 and unbreaking 10000 to arg-1
                send "&c&lMINEPORT &8- &7Item bought." to arg-1
            if {balance.%arg-1%} is less than {@DSwordMoney}:
                send "&c&lMINEPORT &8- &7You do not have enough money" to arg-1

    on skript start:
        set {_bow} to bow
        enchant {_bow} with power 1000
        enchant {_bow} with unbreaking 1000

    command /buybow:
        executable by: player
        trigger:
            if {balance.%player%} is greater than {@BowMoney}:
                give 1 of {_bow} to arg-1
                send "&c&lMINEPORT &8- &7Item bought." to player
            if {balance.%player%} is less than {@BowMoney}:
                send "&c&lMINEPORT &8- &7You do not have enough money" to player
    command /buyarrows <player>:
        executable by: console
        trigger:
            if {balance.%arg-1%} is greater than {@ArrowMoney}:
                give 16 of arrow to arg-1
                send "&c&lMINEPORT &8- &7Item bought." to arg 1  
            if {balance.%arg-1%} is less than {@ArrowMoney}:
                send "&c&lMINEPORT &8- &7You do not have enough money" to arg 1
    command /buyfire <player>:
        executable by: console
        trigger:
            if {balance.%arg-1%} is greater than {@FireworkMoney}:
                give 32 of firework to arg-1
                send "&c&lMINEPORT &8- &7Item bought." to arg 1
            if {balance.%arg-1%} is less than {@FireworkMoney}:
                send "&c&lMINEPORT &8- &7You do not have enough money" to arg 1

    command /setbalance <player> <text>:
        permission: set.balance
        trigger:
            set {balance.%arg-1%} to arg-2
            send "&c&lMINEPORT &8- &7%arg-1%'s money is now set to %arg-2%"
            send "&c&lMINEPORT &8- &7Your money is now at %arg-2%" to arg 1
     
  6. You have to use number as your 2nd argument in the setbalance cmd
     
  7. Okay, thanks, but that's not the problem, the problem is when I click on an item in the GUI, it doesn't come into my inventory or says the message
     
  8. Yes, and the problem is that your balance variable is not a number. It's a text. You can't compare a text with a number.
     
  9. Ohhhhhh, thanks for the help, it works now!
     

Share This Page