defining variables as the result of cmds (NEED HELP PLEASE HELP)

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

DPPPPP

Member
Jul 22, 2023
25
0
1
24
Hey can you help me with something?

command /upefficiency:
trigger:
execute console command "/balance %player%"
set {_bal1} to last ran code or whatever the result of the above cmd is (IDK HOW TO DO IT)
if player's tool is not a pickaxe:
send "&4Please hold a Pickaxe"
if player's tool is a pickaxe:
send "&aYour Balance is %{_bal1}%"
if {_bal1} is greater than 100:
if tool of the player is not enchanted:
enchant the player's tool with efficiency 1
I just need help with the part in bold to check if player has enough currency!
 
Your issue is that you're using local variables instead of a list variable. Whenever you wanna store a stat like money/coins/etc in a variable in skript, you always want to store it in any variable that isn't local.

# Example of a local variable
Code:
command /test:
    trigger:
        set {_examp} to 2
        send "%{_examp}% is a local variable that will not save outside this command!" to player

To use a list variable, simply attach two colons at the end of it and make sure not to use any underscores. For example:
Code:
command /test:
    if {examp::%player%} is not set: # This is an example of a variable that'll save!
        send "Your Examp stat was not set and thus was changed to 0!" to player
        set {examp::%player%} to 0

command /buysword: # Example of a basic shop system (Can be made more efficient with functions when using many shop items)
    trigger:
        if {examp::%player%} >= 1000: # If player has a score of 1k attached to their examp variable.
            remove 1000 from {examp::%player%} # Always put this first in case of delays like on line 11
            send "You successfully just bought x1 sword!" to player
            wait 2 ticks
            send "Remaining Balance: %{examp::%player%}%" to player
 
well, if you are using Essentials and Vault, Ersatz has a line of code that can help.
```typescript
set {_bal1} to placeholder "%%vault_eco_balance%%"
```
^ Assuming u want {_bal1} to be the balance of player
 
Last edited:
  • Like
Reactions: Luke_Sky_Walker
Your issue is that you're using local variables instead of a list variable. Whenever you wanna store a stat like money/coins/etc in a variable in skript, you always want to store it in any variable that isn't local.

# Example of a local variable
Code:
command /test:
    trigger:
        set {_examp} to 2
        send "%{_examp}% is a local variable that will not save outside this command!" to player

To use a list variable, simply attach two colons at the end of it and make sure not to use any underscores. For example:
Code:
command /test:
    if {examp::%player%} is not set: # This is an example of a variable that'll save!
        send "Your Examp stat was not set and thus was changed to 0!" to player
        set {examp::%player%} to 0

command /buysword: # Example of a basic shop system (Can be made more efficient with functions when using many shop items)
    trigger:
        if {examp::%player%} >= 1000: # If player has a score of 1k attached to their examp variable.
            remove 1000 from {examp::%player%} # Always put this first in case of delays like on line 11
            send "You successfully just bought x1 sword!" to player
            wait 2 ticks
            send "Remaining Balance: %{examp::%player%}%" to player
He's having an issue with getting the player's essentialsX (Vault) balance, not a Skript custom currency.