Solved +1 added when mine blocks

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

Mattllama987

Active Member
Aug 5, 2018
225
7
18
24
Hello everyone! I need a little help with something. It should be a fast easy problem. I want to be able to see how many blocks have been mined with each pickaxe. When i mine a block, it would add +1 to a variable, and then update the name of the players tool to the amount of blocks mined. Does that make sense? This is the code i have so far. I get no errors. Just wont add +1

Thanks!
~Matt
Code:
on break:
    if name of player's held item contains "&8[&b&lStarter Pickaxe&8]":
        set {_spawnerpick} to uncoloured name of player's tool
        set {_spawnerpick} to ({_spawnerpick} parsed as number) + 1
        set name of player's tool to "&8[&b&lStarter Pickaxe&8] &8[&a&l%{_spawnerpick}%&8]"
 
You see, when you try to parse {_spawnerpick} as an integer, you're actually trying to parse "&8[&b&lStarter Pickaxe&8]" as an integer, which we know cant happen.

You can try this:
Code:
on break:
    if name of player's tool contains "&8[&b&lStarter Pickaxe&8]":
        set {_name} to uncolored name of player's tool
        replace all "&8[&b&lStarter Pickaxe] &8[&a&l" and "&8]" in {_name} with ""
        set {_} to ({_name} parsed as int) + 1
        set name of player's tool to "&8[&b&lStarter Pickaxe] &8[&a&l%{_}%&8]"
 
You see, when you try to parse {_spawnerpick} as an integer, you're actually trying to parse "&8[&b&lStarter Pickaxe&8]" as an integer, which we know cant happen.

You can try this:
Code:
on break:
    if name of player's tool contains "&8[&b&lStarter Pickaxe&8]":
        set {_name} to uncolored name of player's tool
        replace all "&8[&b&lStarter Pickaxe] &8[&a&l" and "&8]" in {_name} with ""
        set {_} to ({_name} parsed as int) + 1
        set name of player's tool to "&8[&b&lStarter Pickaxe] &8[&a&l%{_}%&8]"
Thank you for getting back with me! But that does the same thing. It adds only +1, and wont add anymore :/

this is the whole code:

Code:
command /starterpick:
    trigger:
        give player a diamond pickaxe of unbreaking 50, efficiency 10 and fortune 5 named "&8[&b&lStarter Pickaxe&8] &8[&a&l0&8]"
on break:
    if name of player's tool contains "&8[&b&lStarter Pickaxe&8]":
        set {_name} to uncolored name of player's tool
        replace all "&8[&b&lStarter Pickaxe] &8[&a&l" and "&8]" in {_name} with ""
        set {_} to ({_name} parsed as int) + 1
        set name of player's tool to "&8[&b&lStarter Pickaxe] &8[&a&l%{_}%&8]"
 
Try this
Code:
command /starterpick:
    trigger:
        give player a diamond pickaxe of unbreaking 50, efficiency 10 and fortune 5 named "&8[&b&lStarter Pickaxe&8] &8[&a&l0&8]"

on break:
    if name of player's tool contains "&8[&b&lStarter Pickaxe&8]":
        set {_name} to uncolored name of player's tool
        replace all "[Starter Pickaxe] [" and "]" in {_name} with ""
        set {_} to ({_name} parsed as int) + 1
        set name of player's tool to "&8[&b&lStarter Pickaxe] &8[&a&l%{_}%&8]"
 
Try this
Code:
command /starterpick:
    trigger:
        give player a diamond pickaxe of unbreaking 50, efficiency 10 and fortune 5 named "&8[&b&lStarter Pickaxe&8] &8[&a&l0&8]"

on break:
    if name of player's tool contains "&8[&b&lStarter Pickaxe&8]":
        set {_name} to uncolored name of player's tool
        replace all "[Starter Pickaxe] [" and "]" in {_name} with ""
        set {_} to ({_name} parsed as int) + 1
        set name of player's tool to "&8[&b&lStarter Pickaxe] &8[&a&l%{_}%&8]"
Same thing. Only adds +1, and then wont add anymore.
 
  • Like
Reactions: FrostPVP™️
Code:
command /starterpick:
    trigger:
        give player a diamond pickaxe of unbreaking 50, efficiency 10 and fortune 5 named "&8[&b&lStarter Pickaxe&8] &8[&a&l0&8]"
 
on break:
    if name of player's tool contains "&8[&b&lStarter Pickaxe&8]":
        set {_name} to uncolored name of player's tool
        replace all "[Starter Pickaxe] [" and "]" in {_name} with ""
        set {_} to ({_name} parsed as int) + 1
        set name of player's tool to "&8[&b&lStarter Pickaxe&8] &8[&a&l%{_}%&8]"
 
Code:
command /starterpick:
    trigger:
        give player a diamond pickaxe of unbreaking 50, efficiency 10 and fortune 5 named "&8[&b&lStarter Pickaxe&8] &8[&a&l0&8]"
 
on break:
    if name of player's tool contains "&8[&b&lStarter Pickaxe&8]":
        set {_name} to uncolored name of player's tool
        replace all "[Starter Pickaxe] [" and "]" in {_name} with ""
        set {_} to ({_name} parsed as int) + 1
        set name of player's tool to "&8[&b&lStarter Pickaxe&8] &8[&a&l%{_}%&8]"
works like a charm. Thank you! :emoji_slight_smile:
 
  • Like
Reactions: FrostPVP™️
Status
Not open for further replies.