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!


    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.

Help With Setting a String to Int. Then Comparing Two Int.

Discussion in 'Skript' started by Seminolee, Jun 24, 2020.

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

    Seminolee Member

    Jun 24, 2020
    Likes Received:

    I just started skripting so pardon if the code itself is absolute garbage. Im having trouble converting one of my strings (in this case my essentials economy balance) to an integer (So instead of $6,520 ill have 6250). This is so I can compare it to another string (of which I convert to an integer right after I convert the first string). In the end, I want to make sure the balance ism greater than or equal to the bet. I have pasted my code below. I get an error as well saying I cannot remove the elements ($ and ,) from the first string. Any help is greatly appreciated! Please lmk if you need any clarification.

    Code (Text):
    1. Command /rps [<text>]:
    3.     trigger:
    5.         if arg 1 is not set:
    6.             send "&4Please Define a Bet! /rps <bet>" to player
    8.         if arg 1 is set:
    9.             set {_bet,%player%} to arg 1
    10.             set {_bal,%player%} to balance of player
    11.             send "Bet: %{_bet,%player%}%" to player
    12.             send "Balance: %{_bal,%player%}%" to player
    13.             replace all "$" in "%{_bal,%player%}%" with ""
    14.             replace all "," in "%{_bal,%player%}%" with ""
    15.             set {_newbal,%player%} to {_bal,%player%} parsed as an integer
    16.             set {_newbet,%player%} to {_bet,%player%} parsed as an integer
    17.             if {_newbal,%player%}  is greater than or equal to {_newbet,%player%}:
    18.                 send "Placeholder... To be added later." to player
    19.             if {_newbal,%player%} is less than {_newbet,%player%}:
    20.                 broadcast "You don't have enough money!"
    21.             else:
    22.                 broadcast "Please enter in a valid number."
  2. rick_Kraut

    rick_Kraut Member

    Feb 20, 2020
    Likes Received:
    1. Probably want to parse arg 1 as an int before setting it to a variable
      1. After affirming it is a number, then you should check its validity.
    2. I haven't messed with skript with essentials together, but from this post https://www.spigotmc.org/threads/essentials-economy-in-skript.311630/#post-2954924 I figure you don't need to clean up the balance.
    otherwise, you could try sending arg 1, and the players balance, along with their type (unsure of how to send types via message though)
Thread Status:
Not open for further replies.

Share This Page