Solved On Damage with arrow?

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

BaddCamden

Member
Nov 18, 2019
25
0
0
America
I am currently trying to shoot an arrow from a wand and it have a specified amount of damage, but I can't get it to tell whether it is a WandA arrow or a WandB arrow or even an arrow at all. Help?

Code:
on load:
register new shapeless recipe for stick named "&2&lBasic Wand&r" with lore "&2&n&lRight Click to use!" and " " and "&c Improve with 2 cobblestone," and "&c2 coal, and 1 dirt!" using stick, dirt, cobblestone, air, air, air, air, air, air
register new shapeless recipe for stick named "&c&oImproved &2Basic Wand&r" with lore "&2&n&lRight Click to use!" and " " and "&c Improve with 3 cobblestone," and "&c4 coal, and 1 dirt!" using stick named "&2&lBasic Wand&r", dirt, cobblestone, cobblestone, coal, coal, air, air, air
register new shapeless recipe for stick named "&9Better Wand&r" with lore "&2&n&lRight Click to use!" and " " and "&c Improve with " and "&c7 coal and 1 dirt!" using stick named "&c&oImproved &2Basic Wand&r", dirt, cobblestone, cobblestone, coal, coal, cobblestone, coal, coal

on rightclick with stick:
if name of tool of player is "&2&lBasic Wand&r":
shoot arrow from player at speed 5
set {arrow} to 1

on damage:
projectile is an arrow
projectile exists
set damage to {arrow}

Plugins:

Skript, skQuery, skVault
[doublepost=1574220454,1574220401][/doublepost]Also, how do I add a delay in between arrow shots so you can't spam the arrows?
Thanks :emoji_grinning:
 
Example Code using metadata:
code_language.skript:
on shoot:
    shooter is a player
    if name of shooter's held item is "&2&lBasic Wand&r":
        set metadata value "Damage" of event-projectile to "5"
        set metadata value "Wand" of event-projectile to "Basic Wand"
    if name of shooter's held item is "&c&oImproved &2Basic Wand&r":
        set metadata value "Damage" of event-projectile to "7"
        set metadata value "Wand" of event-projectile to "Improved Basic Wand"

on damage:
    "%damage cause%" is "projectile"
    set {_damage} to metadata value "Damage" of event-projectile
    set damage to {_damage} parsed as number
    set {_type} to metadata value "Wand" of event-projectile
    broadcast "%attacker% damaged %victim% by %damage% with %{_type}%."

# Example Cooldown
on rightclick holding stick:
   set {_cd} to difference between {shoot-arrow.%uuid of player%} and now
   if {_cd} is less than 1.5 seconds:
       stop
   set {shoot-arrow.%uuid of player%} to now
   shoot arrow from player at speed 5
 
Last edited:
Thank you! Can you show me a forum on metadata so in case there are similar problems in the future? :emoji_grinning:
Here is metadata in the docs:
https://skripthub.net/docs/?id=2622
It basically allows you to set custom data on entities/blocks while they exist so you can do some pretty cool stuff. Since the projectile in your code is an entity, it allows you to set custom data for them and retrieve it for whatever purposes. Metadata though does not save on a server restart but that really should not be an issue for what you are doing.
 
Last edited:
Status
Not open for further replies.