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!

  2. LOOKING FOR A VERSION OF SKRIPT?

    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.

Solved +1 added when mine blocks

Discussion in 'Skript' started by Mattllama987, Nov 22, 2020.

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

    Mattllama987 Active Member

    Joined:
    Aug 5, 2018
    Messages:
    225
    Likes Received:
    7
    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 (Text):
    1. on break:
    2.     if name of player's held item contains "&8[&b&lStarter Pickaxe&8]":
    3.         set {_spawnerpick} to uncoloured name of player's tool
    4.         set {_spawnerpick} to ({_spawnerpick} parsed as number) + 1
    5.         set name of player's tool to "&8[&b&lStarter Pickaxe&8] &8[&a&l%{_spawnerpick}%&8]"
     
    • Useful Useful x 1
  2. Goose

    Supporter

    Joined:
    Nov 23, 2019
    Messages:
    429
    Likes Received:
    30
    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 (Text):
    1. on break:
    2.     if name of player's tool contains "&8[&b&lStarter Pickaxe&8]":
    3.         set {_name} to uncolored name of player's tool
    4.         replace all "&8[&b&lStarter Pickaxe] &8[&a&l" and "&8]" in {_name} with ""
    5.         set {_} to ({_name} parsed as int) + 1
    6.         set name of player's tool to "&8[&b&lStarter Pickaxe] &8[&a&l%{_}%&8]"
     
  3. Mattllama987

    Mattllama987 Active Member

    Joined:
    Aug 5, 2018
    Messages:
    225
    Likes Received:
    7
    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 (Text):
    1. command /starterpick:
    2.     trigger:
    3.         give player a diamond pickaxe of unbreaking 50, efficiency 10 and fortune 5 named "&8[&b&lStarter Pickaxe&8] &8[&a&l0&8]"
    4. on break:
    5.     if name of player's tool contains "&8[&b&lStarter Pickaxe&8]":
    6.         set {_name} to uncolored name of player's tool
    7.         replace all "&8[&b&lStarter Pickaxe] &8[&a&l" and "&8]" in {_name} with ""
    8.         set {_} to ({_name} parsed as int) + 1
    9.         set name of player's tool to "&8[&b&lStarter Pickaxe] &8[&a&l%{_}%&8]"
     
  4. DeadlySkyLord

    DeadlySkyLord Member

    Joined:
    May 23, 2020
    Messages:
    11
    Likes Received:
    0
    Try this
    Code (Text):
    1. command /starterpick:
    2.     trigger:
    3.         give player a diamond pickaxe of unbreaking 50, efficiency 10 and fortune 5 named "&8[&b&lStarter Pickaxe&8] &8[&a&l0&8]"
    4.  
    5. on break:
    6.     if name of player's tool contains "&8[&b&lStarter Pickaxe&8]":
    7.         set {_name} to uncolored name of player's tool
    8.         replace all "[Starter Pickaxe] [" and "]" in {_name} with ""
    9.         set {_} to ({_name} parsed as int) + 1
    10.         set name of player's tool to "&8[&b&lStarter Pickaxe] &8[&a&l%{_}%&8]"
     
  5. Mattllama987

    Mattllama987 Active Member

    Joined:
    Aug 5, 2018
    Messages:
    225
    Likes Received:
    7
    Same thing. Only adds +1, and then wont add anymore.
     
    • Like Like x 1
  6. DeadlySkyLord

    DeadlySkyLord Member

    Joined:
    May 23, 2020
    Messages:
    11
    Likes Received:
    0
    Code (Text):
    1.  
    2. command /starterpick:
    3.     trigger:
    4.         give player a diamond pickaxe of unbreaking 50, efficiency 10 and fortune 5 named "&8[&b&lStarter Pickaxe&8] &8[&a&l0&8]"
    5.  
    6. on break:
    7.     if name of player's tool contains "&8[&b&lStarter Pickaxe&8]":
    8.         set {_name} to uncolored name of player's tool
    9.         replace all "[Starter Pickaxe] [" and "]" in {_name} with ""
    10.         set {_} to ({_name} parsed as int) + 1
    11.         set name of player's tool to "&8[&b&lStarter Pickaxe&8] &8[&a&l%{_}%&8]"
     
    • Useful Useful x 1
  7. Mattllama987

    Mattllama987 Active Member

    Joined:
    Aug 5, 2018
    Messages:
    225
    Likes Received:
    7
    works like a charm. Thank you! :emoji_slight_smile:
     
    • Like Like x 1
Thread Status:
Not open for further replies.

Share This Page

Loading...