"Add" not working

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

MusicManSK

Active Member
Nov 30, 2017
230
11
18
Hello i have a code:
code_language.skript:
command /coins [<text>] [<text>] [<text>]:
    Usage: /coins [give|set] [player] [amount]
    trigger:
        if arg-1 is not set:
            send "&6You have &e&l%{coins::%player%}% Coins" to player
        if arg-1 is "give":
            if player has the permission "coins.admin":
                if arg-2 and arg-3 are set:
                    #set {coins::%arg-2%} to arg-3 + {coins::%arg-2%}
                    add arg-3 to {coins::%arg-2%}
                    send "&6Added &e&l%arg-3% Coins &r&6for &b%arg-2%&6! &6Actual Coins: &e&l%{coins::%arg-2%}% Coins" to player
                else:
                    send "/coins [give|set] [player] [amount]" to player
            else:
                send "&6You have &e&l%{coins::%player%}% Coins" to player
        else if arg-1 is "set":
            if player has the permission "coins.admin":
                if arg-2 and arg-3 is set:
                    set {coins::%arg-2%} to arg-3
                    send "&6Setted &e&l%arg-3% Coins &r&6for &b%arg-2%&6! &6Actual Coins: &e&l%{coins::%arg-2%}% Coins" to player
                else:
                    send "/coins [give|set] [player] [amount]" to player
            else:
                send "&6You have &e&l%{coins::%player%}% Coins" to player
        else:
            if player has the permission "coins.admin":
                send "/coins [give|set] [player] [amount]" to player
            else:
                send "&6You have &e&l%{coins::%player%}% Coins" to player
but when i type "/coins set MataxePlay 5" it returns:
ORwr.png

and when i type "/coins give MataxePlay 10" it returns:
wLh6.png

you can see that "give" command not working.. plzz help
 
the arg is text so you have to parse it as a number
code_language.skript:
add (arg-3 parsed as number) to {coins::%arg-2%}
you need to do it for setting it too, the reason it "works" right now is because its just setting the variable to the number as a text i.e. "5", not an actual number
code_language.skript:
set {coins::%arg-2%} to (arg-3 parsed as number)
 
I think that you may use the "arg-3" line as an integer or as a number. You can do like this:
code_language.skript:
command /coins [<text>] [<text>] [<integer>]:
or like this
code_language.skript:
command /coins [<text>] [<text>] [<number>]:

If i'm correct, this is solved. If i'm not, tell me.
[doublepost=1514384159,1514384062][/doublepost]Oops, i answered a second later @Donut. Yeah, it's because the arg-3 is text and not number/integer.
 
@FishRekt very good idea.. im going to try it..
@Donut good idea too.. its same :emoji_grinning:
[doublepost=1514387041,1514386864][/doublepost]Nice!
thx guys.. it needed "integer"
LOCK
 
Status
Not open for further replies.