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!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Skript Using "Loops"

Discussion in 'Tutorials' started by acai, Dec 3, 2020.

  1. acai

    acai Active Member

    Joined:
    Oct 23, 2020
    Messages:
    89
    Likes Received:
    1
    Hello! Welcome to my second tutorial.
    This is a very simple lesson, but I am using it in a way some people would not.
    We will be using loops to count players, entities, and blocks today!
    How do I use loops, you may ask? After an event and the correct syntax, you can use a loop.

    Let's start with an event, shall we?
    I will be using Every 5 seconds for this event.
    Code (Text):
    1. every 5 seconds:
    Now, let's add the "loop". I will be using "loop all players:", which will loop a command for every player in your server.
    Code (Text):
    1. every 5 seconds:
    2.   loop all players:
    What should you do next to count the players? First, we must set the variable to 0, with the "on script load:" event. I prefer this to options, because options is more complicated than an event.

    Code (Text):
    1. on script load:
    2.   set {pcount} to 0
    Next, we must add on to the every 5 seconds event. Now we can add other commands regarding variables.
    Code (Text):
    1. every 5 seconds:
    2.   loop all players:
    3.     add 1 to {pcount}
    You can repeat this with anything! Blocks, entities, and mobs!
    Instead of "mobs", you will use "loop-mob".
    Instead of "player", you will use "loop-player".
    Instead of "entity", you will use "loop-entity".
    And so on, and so on. Basically, any type of entity you'll be able to use outside of loops, just with "loop-" before the type.




     

Share This Page

Loading...