Error with adding a argument to a balance

Discussion in 'Skript' started by Kingtheking22222, Mar 30, 2020.

  1. Hello,

    #I am not very well a skript and only have a handful of experience with skript.#

    I am having a problem with this command

    Code (Text):
    command /deposit [<number>]:
        trigger:
            if arg-1 is more than {balance1::%player%}:
                send "{@tag} &cYou have not enough money!" to player
                stop
            if arg-1 < 0:
                send "{@tag} &cYou can't deposit negative amount!" to player
                stop
            else:
                add arg-1 to {balance2::%player%}
                remove arg-1 from {balance1::%player%}
                send "{@tag} &aYou deposited &e%arg-1% cash&a." to player

    I can get arg-1 to add (x) number to balance2 but I can't get it to remove a (x) number from balance1.
    I hope to have this fixed soon so I can continue with this skript and add more.

    FYI: {balance1::%player%} is the Player's balance and {balance2::%player%} is their Bank balance.

    Thanks,
    King
     
  2. Sorry, But in the post at the top, I forgot what to explain more of the error.

    Basically a player can do /deposit 1000 and it would say "You deposited 1000 money." But since I can't get the skript to remove 1000 from their balance the player can just keep doing /deposit 1000 and, put how much they want on their bank account without them losing their bank money from their balance. But I haven't added a /withdraw yet because I found this error.

    Also, I don't get any errors when reloading the skript and the server which is odd. It just says "Successfully reloaded bank.sk!" when I do /sk reload bank. And there is no console errors because it does successfully reloads.

    And I am using the most up-to-date version of skript.

    Sorry,
    King
     
  3. Also, If possible how would you change this code to support a /withdraw?
     
  4. I recommend naming variables in a way that is easy to understand for others, because "1" and "2" are meaningless to people who haven't written the code, so you should name then {balancebank and {balancepersonal or something like that. (always try to make your code understandable by another person, it can be of big help in the future, if you happen to get extra developers or something working with you)

    your code is right and it shouldn't have this kind of problem, it could come down to addons/custom syntax conflicts, or just outdated version of Skript. (most up-to-date is meaningless, tell the version string! the current latest version is in alpha testing and it may have issues, also with the introduction of nightly builds, your latest may become unlatest after just a few hours) also you could try resetting your balance variables, maybe they're of incompatible types.