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

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

Seminolee

Member
Jun 24, 2020
1
0
0
23
Hi,

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:
Command /rps [<text>]:

    trigger:
        
        if arg 1 is not set:
            send "&4Please Define a Bet! /rps <bet>" to player

        if arg 1 is set:
            set {_bet,%player%} to arg 1
            set {_bal,%player%} to balance of player
            send "Bet: %{_bet,%player%}%" to player
            send "Balance: %{_bal,%player%}%" to player
            replace all "$" in "%{_bal,%player%}%" with ""
            replace all "," in "%{_bal,%player%}%" with ""
            set {_newbal,%player%} to {_bal,%player%} parsed as an integer
            set {_newbet,%player%} to {_bet,%player%} parsed as an integer
            if {_newbal,%player%}  is greater than or equal to {_newbet,%player%}:
                send "Placeholder... To be added later." to player
            if {_newbal,%player%} is less than {_newbet,%player%}:
                broadcast "You don't have enough money!"
            else:
                broadcast "Please enter in a valid number."
 
  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)
 
Status
Not open for further replies.