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.

How do I fix this?

Discussion in 'Skript' started by GlacialDew, Jun 17, 2018.

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

    GlacialDew Member

    Joined:
    Apr 8, 2018
    Messages:
    40
    Likes Received:
    3
    I want it to where players can only place a maximum of blocks, but I cant figure out how to lay it out, this is what I have so far but it doesnt stop players from placing over the max.


    Code (Skript):
    1. on place:
    2.     set {owner::%event-block%} to player
    3.     if event-block is spruce wood planks:
    4.         if {%player%.wood.placed} is equal to {%player%.max.wood}:
    5.             cancel event
    6.             send "&6%{%player%.wood.placed}%&7/&6%{%player%.max.wood}% &7Max Wood Reached!"
    7.             stop
    8.         if {%player%.wood.placed} is not equal to {%player%.max.wood}:
    9.             set {%player%.wood.placed} to {%player%.wood.placed} + 1
    10.             send "&6%{%player%.wood.placed}%&7/&6%{%player%.max.wood}% &7Wood Placed"
    11.             stop
     
  2. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    231
    its because {%player%.wood.placed} has never been set, so adding 1 to it is like adding 1 to air, nothing there

    so do something like
    if {%player%.wood.placed} is not set:
    set {%player%.wood.placed} to 0 (or 1, whichever you choose)
     
  3. GlacialDew

    GlacialDew Member

    Joined:
    Apr 8, 2018
    Messages:
    40
    Likes Received:
    3
    its already set to 0
     
  4. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    231
    hmmm odd....
    i thought it had to be set first.
    Anyways i copied your code into a test skript, added in a command to set the max wood thing, tested with 3 and it works fine.
    So im not really sure what your trouble is here?
     
  5. GlacialDew

    GlacialDew Member

    Joined:
    Apr 8, 2018
    Messages:
    40
    Likes Received:
    3
    whenever i use it, it will either not stop it from placing once over the max, or it wont allow me to place anything .-.
     
  6. saipar

    saipar Member

    Joined:
    Nov 29, 2017
    Messages:
    26
    Likes Received:
    0
    Code (Skript):
    1.  
    2. on place:
    3.     set {owner::%event-block%} to player
    4.     if event-block is spruce wood planks:
    5.         if {%player%.wood.placed} >= {%player%.max.wood}:
    6.             cancel event
    7.             send "&6%{%player%.wood.placed}%&7/&6%{%player%.max.wood}% &7Max Wood Reached!"
    8.         else if {%player%.wood.placed} < {%player%.max.wood}:
    9.             add 1 to {%player%.wood.placed}
    10.             send "&6%{%player%.wood.placed}%&7/&6%{%player%.max.wood}% &7Wood Placed"
    11.  
     
Thread Status:
Not open for further replies.

Share This Page

Loading...