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 Shoot arrow that cannot be picked up?

Discussion in 'Skript' started by SeriousGuy888, Jul 20, 2019.

Thread Status:
Not open for further replies.
  1. SeriousGuy888

    SeriousGuy888 Member

    Joined:
    Jul 20, 2019
    Messages:
    2
    Likes Received:
    0
    Already solved.

    Hi. I'm trying to write a guns script. The gun would fire an arrow but I don't want people to be able to pick up those arrows. Is there a way to do that?

    Code (Text):
    1.     if player has 1 {@pistolammo}:
    2.         shoot arrow from the player at speed 2
    3.         #I want to make it shoot an arrow that can't be picked up
    4.         remove 1 {@pistolammo} from player
    Nevermind. I found a solution.


    Code (Text):
    1. on right click with iron hoe:
    2.     name of player's held item is "§rPistol §7(Right Click)"
    3.     cancel event
    4.     if player does not have 1 {@pistolammo}:
    5.         set action bar of player to "§4You do not have ammo!"
    6.     if player has 1 {@pistolammo}:
    7.         shoot an arrow from the player at speed 4
    8.         set {_arrow} to last shot arrow
    9.         remove 1 {@pistolammo} from player
    10.         add "{pickup:0b}" to the nbt of {_arrow}
     
    #1 SeriousGuy888, Jul 20, 2019
    Last edited: Jul 22, 2019
  2. couger44

    Supporter

    Joined:
    Feb 19, 2017
    Messages:
    714
    Likes Received:
    31
    Try with:
    Code (Skript):
    1.  
    2. on pickup:
    3.     if event-item is arrow:
    4.         cancel event
    At the moment it is the only way I can think of doing in script.
     
  3. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    You can do it with skript-mirror, here is a quick little test I did, and it worked
    Code (Skript):
    1. import:
    2.     org.bukkit.entity.AbstractArrow$PickupStatus
    3.  
    4. command /test:
    5.     trigger:
    6.         shoot arrow from the player at speed 2
    7.         set {_a} to last shot arrow
    8.         {_a}.setPickupStatus(PickupStatus.DISALLOWED)
     
  4. SeriousGuy888

    SeriousGuy888 Member

    Joined:
    Jul 20, 2019
    Messages:
    2
    Likes Received:
    0
    Is there a way I maybe put a tag on the arrow that I spawned and detect that? Or maybe can I can do something with the reason the arrow was spawned like on the Skript documentation where you can detect the reason a mob is spawned.
     
  5. couger44

    Supporter

    Joined:
    Feb 19, 2017
    Messages:
    714
    Likes Received:
    31
    I didn't try that command. But try using:
    Code (Skript):
    1.  
    2. on pickup:
    3.     if event-item is arrow: # or 'if event-item is a arrow'
    4.         cancel event
    --- Double Post Merged, Jul 22, 2019, Original Post Date: Jul 22, 2019 ---
    or as ShaneBee said, try using Skript-mirror with the code was he sent.
     
  6. aescraft

    aescraft Well-Known Member

    Joined:
    Mar 1, 2017
    Messages:
    295
    Likes Received:
    13
    What minecraft version are you using? As skript mirror is not updated as far as I know. Thanks!
     
  7. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    I tested using Paper 1.14.4 and skript-mirror 2.0.0
     
Thread Status:
Not open for further replies.

Share This Page

Loading...