Solved Preventing text in integer? (arg-2)

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

Adrihun

Member
Feb 1, 2017
368
6
0
Okay, so I have a money changer script where if you type in /changemoney it will change the players money.
BUT if someone types in /changemoney Name Lol, it will mess up the script and will give <none> to the player.

How can i block this so they can only put in numbers in like
1,2,3...

Here is my script

code_language.skript:
command /changemoney [<offline player>] [<text>]:
    permission: money.set
    permission message: Not allowed!
    trigger:
        arg 1 is set:
            arg 2 is set:
                set {_num} to arg-2 parsed as an integer
                if arg 1 is online:
                    if arg 1 is player:
                        send "You can't change YOUR money"
                        stop
                    difference between {sql_.diff.setmoney::%player%} and now is less than 30 seconds:
                        send "Cooldown"
                        stop
                    if {_num} is greater than 500000:
                        send "too high"
                        stop
                    set {sql_.diff.setmoney::%player%} to now
                    {@run_async} is "true":
                        $ thread
                    set {_message} to addmoney(arg 1, {_num}, 1)
                    send "worked!"
                    send arg-1 title "Money!!" with subtitle "&bYou now have %{_num}%" for 3 seconds

                else:
                    send "player offline"
            else:
                send "wrong usage"
        else:
            send "wrong usage"
 
code_language.skript:
command /changemoney [<offline player>] [<text>]:
    permission: money.set
    permission message: Not allowed!
    trigger:
        if arg-2 parsed as integer isn't set:
            send "Invalid integer"
            stop
        arg 1 is set:
            arg 2 is set:
                set {_num} to arg-2 parsed as an integer
                if arg 1 is online:
                    if arg 1 is player:
                        send "You can't change YOUR money"
                        stop
                    difference between {sql_.diff.setmoney::%player%} and now is less than 30 seconds:
                        send "Cooldown"
                        stop
                    if {_num} is greater than 500000:
                        send "too high"
                        stop
                    set {sql_.diff.setmoney::%player%} to now
                    {@run_async} is "true":
                        $ thread
                    set {_message} to addmoney(arg 1, {_num}, 1)
                    send "worked!"
                    send arg-1 title "Money!!" with subtitle "&bYou now have %{_num}%" for 3 seconds

                else:
                    send "player offline"
            else:
                send "wrong usage"
        else:
            send "wrong usage"
 
Status
Not open for further replies.