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 Mob spawn skript

Discussion in 'Skript' started by 83y, Dec 16, 2020.

Tags:
Thread Status:
Not open for further replies.
  1. 83y

    83y New Member

    Joined:
    Nov 7, 2019
    Messages:
    8
    Likes Received:
    0
    Here is my code, read the notes within the skript:
    Code (Text):
    1. command /start:
    2.   trigger:
    3.     set {mobs} to 1
    4.     set {time} to 10
    5.     loop all players:
    6.       set {dead::%loop-player%} to false
    7.       while {dead::%loop-player%} is false:
    8.         broadcast "%{time}%"
    9.  
    10. # rounds divides time by 1.2 and rounds down
    11.  
    12.         set {time} to floor({time} / 1.2)
    13.         broadcast "%{time}%"
    14.  
    15. # eg. if input were 10 output would be 8
    16.  
    17.         set {time} to "%{time}% seconds"
    18.  
    19. # converts {time} an integer into a string and adds " seconds" onto the end
    20.  
    21.         broadcast "%{time}%"
    22.  
    23. # I am aiming to get it so it will eg. wait 8 seconds i've tried putting the integer
    24. # in and adding seconds on at the end but this just gives an error.
    25. # what should I do? plz help.
    26.  
    27.         wait {time}
    28.         set {_random} to floor({mobs})
    29.         broadcast "%{_random}%"
    30.         if {time} <= 3:
    31.           broadcast "mobs"
    32.           add 0.2 to {mobs}
    33.         else:
    34.           remove 1 from {time}
    35.  
    36. # the multiplier of how many mobs increase (rounds downwards)
    37.  
    38.           add 0.2 to {mobs}
    39.  
    40.         spawn {_random} of creeper above loop-player
     
  2. Best Answer:
    Post #2 by MusicManSK, Dec 16, 2020
  3. MusicManSK

    MusicManSK Active Member

    Joined:
    Nov 30, 2017
    Messages:
    232
    Likes Received:
    11
    You have converted `integer` into `string`, but you also have to parse it as `timespan` like so:
    Code (Text):
    1. set {time} to "%{time}% seconds" parsed as timespan
    So your code became:
    Code (Text):
    1. command /start:
    2.   trigger:
    3.     set {mobs} to 1
    4.     set {time} to 10
    5.     loop all players:
    6.       set {dead::%loop-player%} to false
    7.       while {dead::%loop-player%} is false:
    8.         broadcast "%{time}%"
    9.  
    10. # rounds divides time by 1.2 and rounds down
    11.  
    12.         set {time} to floor({time} / 1.2)
    13.         broadcast "%{time}%"
    14.  
    15. # eg. if input were 10 output would be 8
    16.  
    17.         set {time} to "%{time}% seconds" parsed as timespan
    18.  
    19. # converts {time} an integer into a string and adds " seconds" onto the end
    20.  
    21.         broadcast "%{time}%"
    22.  
    23. # I am aiming to get it so it will eg. wait 8 seconds i've tried putting the integer
    24. # in and adding seconds on at the end but this just gives an error.
    25. # what should I do? plz help.
    26.  
    27.         wait {time}
    28.         set {_random} to floor({mobs})
    29.         broadcast "%{_random}%"
    30.         if {time} <= 3:
    31.           broadcast "mobs"
    32.           add 0.2 to {mobs}
    33.         else:
    34.           remove 1 from {time}
    35.  
    36. # the multiplier of how many mobs increase (rounds downwards)
    37.  
    38.           add 0.2 to {mobs}
    39.  
    40.         spawn {_random} of creeper above loop-player
     
    • Like Like x 1
  4. 83y

    83y New Member

    Joined:
    Nov 7, 2019
    Messages:
    8
    Likes Received:
    0
    Thank you @MusicManSK it worked, I didn't know you could parse as timespan
     
Thread Status:
Not open for further replies.

Share This Page

Loading...