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

winterwolf007

New Member
Feb 24, 2017
8
4
0
23
Hello Everyone, all this tutorial requires is Skript

Today, I'll be making a tutorial on arrow effects. There are 3 other effects that can be used. They are endersignal, fire, and smoke. Today, I'll be showing you the explode effect.

Now, we will be coding the event, the permission, and to define what was shot

code_language.skript:
on shoot:
    shooter has permission "arrow.explode"
    projectile is arrow

This piece of code doesn't really do much right now. All it does is when someone shoots, and someone has the permission 'arrow.explode', and defining as the item shot as an arrow.

Now we will be adding looping and checking if a variable is 1.

code_language.skript:
on shoot:
    shooter has permission "explode.shoot"
    projectile is arrow
        loop 100 times:
            if {es.%shooter%} is 1:

This code also doesn't do much. All it does is when someone shoots, and someone has the permission 'arrow.explode', and defining as the item shot as an arrow. It also loops 100 times and in the loop, it checks if {es.%shooter%} is 1. We will get to {es.%shooter%} later in this tutorial.

Now we will be adding the effect. I will be using the exploding effect. I will also make it so the loop doesn't happen all at once by adding a wait time.

code_language.skript:
on shoot:
    shooter has permission "explode.shoot"
    projectile is arrow
        loop 100 times:
            if {es.%shooter%} is 1:
               wait 0.03 seconds
               create a fake explosion at location of projectile

This makes it so when someone shoots an arrow and the shooter has the permission 'explode.shoot', it loops 100 times, checking if {es.%shooter%} is 1, waiting 0.03 seconds, and creating a fake explosion at the location of the projectile.

Now, we wouldn't want the effect to keep going once it hits an entity or block. This is why we have the {es.%shooter%} code in the example. This will make it so when the arrow hits an object, it changes the {es.%shooter%}, making the loop end.

code_language.skript:
on shoot:
    shooter has permission "explode.shoot"
    projectile is arrow
        loop 100 times:
            if {es.%shooter%} is 1:
                wait 0.03 seconds
                create a fake explosion at location of projectile

on projectile hit:
    projectile is arrow
    set {es.%shooter%} to 0

This makes it so when the arrow with the effect (caused by the loop) hits something, it changes the check code, making the loop end. It changes it by when the projectile (arrow) hits something, it changes {es.%shooter%}

Now, how are we going to get {es.%shooter%} back to 1? We can fix this by inserting code, setting {es.%shooter%} back to 1.

code_language.skript:
on shoot:
    shooter has permission "explode.shoot"
    projectile is arrow
    set {es.%shooter%} to 1
        loop 100 times:
            if {es.%shooter%} is 1:
                wait 0.03 seconds
                create a fake explosion at location of projectile

on projectile hit:
    projectile is arrow
    set {es.%shooter%} to 0

Now, when a player shoots an arrow with permission arrow.explode, checks if the projectile is an arrow, it sets {es.%shooter%} to 1, and checks if {es.%shooter%} is 1, and if it is, it creates a fake explosion at the location of the arrow every 0.03 seconds in the loop. If the arrow hits something, it changes the check in the loop, ending the loop.