1. 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!

  2. LOOKING FOR A VERSION OF SKRIPT?

    You can always check out our Wiki for downloads and any other information about Skript!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Solved Preventing text in integer? (arg-2)

Discussion in 'Skript' started by Adrihun, May 8, 2017.

Thread Status:
Not open for further replies.
  1. Adrihun

    Adrihun Member

    Joined:
    Feb 1, 2017
    Messages:
    368
    Likes Received:
    6
    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 (Skript):
    1. command /changemoney [<offline player>] [<text>]:
    2.     permission: money.set
    3.     permission message: Not allowed!
    4.     trigger:
    5.         arg 1 is set:
    6.             arg 2 is set:
    7.                 set {_num} to arg-2 parsed as an integer
    8.                 if arg 1 is online:
    9.                     if arg 1 is player:
    10.                         send "You can't change YOUR money"
    11.                         stop
    12.                     difference between {sql_.diff.setmoney::%player%} and now is less than 30 seconds:
    13.                         send "Cooldown"
    14.                         stop
    15.                     if {_num} is greater than 500000:
    16.                         send "too high"
    17.                         stop
    18.                     set {sql_.diff.setmoney::%player%} to now
    19.                     {@run_async} is "true":
    20.                         $ thread
    21.                     set {_message} to addmoney(arg 1, {_num}, 1)
    22.                     send "worked!"
    23.                     send arg-1 title "Money!!" with subtitle "&bYou now have %{_num}%" for 3 seconds
    24.  
    25.                 else:
    26.                     send "player offline"
    27.             else:
    28.                 send "wrong usage"
    29.         else:
    30.             send "wrong usage"
     
  2. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,181
    Likes Received:
    220
    Replace "arg 2 is set" with "arg 2 is number"

    Or replace in first line "[<text>]" with "[<number>]"
     
  3. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,181
    Likes Received:
    220
    Tha condition doesn't exist, sadly.

    Just check if the {_num} var is set before use it.
     
  4. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,181
    Likes Received:
    220
    Code (Skript):
    1. command /changemoney [<offline player>] [<text>]:
    2.     permission: money.set
    3.     permission message: Not allowed!
    4.     trigger:
    5.         if arg-2 parsed as integer isn't set:
    6.             send "Invalid integer"
    7.             stop
    8.         arg 1 is set:
    9.             arg 2 is set:
    10.                 set {_num} to arg-2 parsed as an integer
    11.                 if arg 1 is online:
    12.                     if arg 1 is player:
    13.                         send "You can't change YOUR money"
    14.                         stop
    15.                     difference between {sql_.diff.setmoney::%player%} and now is less than 30 seconds:
    16.                         send "Cooldown"
    17.                         stop
    18.                     if {_num} is greater than 500000:
    19.                         send "too high"
    20.                         stop
    21.                     set {sql_.diff.setmoney::%player%} to now
    22.                     {@run_async} is "true":
    23.                         $ thread
    24.                     set {_message} to addmoney(arg 1, {_num}, 1)
    25.                     send "worked!"
    26.                     send arg-1 title "Money!!" with subtitle "&bYou now have %{_num}%" for 3 seconds
    27.  
    28.                 else:
    29.                     send "player offline"
    30.             else:
    31.                 send "wrong usage"
    32.         else:
    33.             send "wrong usage"
     
    • Funny Funny x 1
    • Winner Winner x 1
Thread Status:
Not open for further replies.

Share This Page

Loading...