For 40 seconds, set all arrows fired to have effects

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

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

CosmicThing2

Member
Nov 8, 2020
1
0
1
30
Hello all,

I've recently started using Skript and am really stuck with how to do a few things. I'd like to have a script that does the following. (Note that this uses a custom item/handle in the first part which triggers when the item is just right clicked. This works fine and my query isn't related to this, it's just the projectile part I'm confused on).

(When a player right clicks a custom item - provided by another plugin, apply glowing to everyone but the player and then...) For 40 seconds check all arrows fired by the player. If the arrow hits another player, it applies a weakness 1 potion effect. After the 40 seconds the script then stops and the arrows return to normal.

I initially tried using 'loop 40 seconds' but Skript really didn't like that so I wondered if I could do it with a while loop and a variable 'ended' like this:

Code:
on CustomItems handle:
    if the action id is "ranger":
        remove player's held item from player's inventory
        loop all players:
            if loop-player is not player:
                apply glowing to loop-player for 40 seconds
        {ended} = 0
        while {ended} is less than 160:
            projectile exists
            projectile is arrow
            apply weakness 1 to target for 15 seconds
            add 1 to {ended}
            wait for 0.25 seconds

This does run but doesn't work properly as I know 'target' isn't right. It's almost like I need another event for the second part. But I don't want the projectile part to run before the first custom items part.

Would really appreciate any advice. How do I make something keep occurring for a set amount of time?

Thank you!
 
Status
Not open for further replies.