Solved Adding a chat message to a variable as a number

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

Headteachers

New Member
Aug 12, 2019
7
0
0
24
Skript Version (do not put latest): Skript 2.2 (dev36)
Skript Author: bensku
Minecraft Version: 1.8.8
---

I'm trying to add the message [message is going to be a number] to a variable which serves as a balance [/bal], but it does not add.

Full Code:


Code (Skript):

  1. Code:
    command /test:
            trigger:
                    set {spec.amount.%player%} to true
    
    command /bal:
            trigger:
                    send "%{balance.%player%}%" to player
    
    on chat:
        if {spec.amount.%player%} is true:
            if player's money is greater than or equal to {_message}:
                cancel event
                set {_message} to message
                add message parsed as number to {bank.%player%}
                execute console command "eco take %player% %message%"
                set {spec.amount.%player%} to false
        else:
            stop
Errors on Reload:

N/A - This reloads without any errors, but does not add the message to the variable.

Console Errors: (if applicable)

N/A

Addons using (including versions):
SkRayFall 1.8.17, SkQuery 3.6.1-Lime, Skellett 1.9.6b, SkUtilities 0.9.2

Troubleshooting:

Have you tried searching the docs? Yes
Have you tried searching the forums? Yes
What other methods have you tried to fix it? I have tried adding the chat message to different variables.
 
Skript Version (do not put latest): Skript 2.2 (dev36)
Skript Author: bensku
Minecraft Version: 1.8.8
---

I'm trying to add the message [message is going to be a number] to a variable which serves as a balance [/bal], but it does not add.

Full Code:


Code (Skript):

  1. Code:
    command /test:
            trigger:
                    set {spec.amount.%player%} to true
    
    command /bal:
            trigger:
                    send "%{balance.%player%}%" to player
    
    on chat:
        if {spec.amount.%player%} is true:
            if player's money is greater than or equal to {_message}:
                cancel event
                set {_message} to message
                add message parsed as number to {bank.%player%}
                execute console command "eco take %player% %message%"
                set {spec.amount.%player%} to false
        else:
            stop
Errors on Reload:

N/A - This reloads without any errors, but does not add the message to the variable.

Console Errors: (if applicable)

N/A

Addons using (including versions):
SkRayFall 1.8.17, SkQuery 3.6.1-Lime, Skellett 1.9.6b, SkUtilities 0.9.2

Troubleshooting:

Have you tried searching the docs? Yes
Have you tried searching the forums? Yes
What other methods have you tried to fix it? I have tried adding the chat message to different variables.
You have a condition to check if the money from the player is greater than or equal to a variable, but that variable won't be set until 2 lines after the condition. Also, if it were set before, you would still have to parse it as a number. I would also recommend adding a check if the message is actually a number (so if the message parser as a number is set). You also don't need the `else: stop` part
 
the part to check if the message is a number, i think I've already tried this and it doesn't work but if you could help me on how to check if the message is a number then add it to my variable that'd be amazing
Can you show me the code you tried for that?
 
No since I didn't make a copy of said code I just tried a ton of different methods over the space of 5 minutes and the code i put above is what i finished at
You'll will have to set & parse the variable before the condition, start with that.
 
Status
Not open for further replies.