Schoot projectile in certain direction.

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

    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.

kittkarrkitt

Supporter
Jan 4, 2021
33
0
6
Hello, I need to know how to launch a projectile (snowball in this case) in a certain direction from the player. I have made a gun, that fires a snowball when it gets right clicked, but I need a shotgun variant. Just 1 bullet (snowball) is not enough, and it need some spread. Can I use like a certain amount of degrees from where the player is targeting to? This is my snowball launch code:


Code:
on right click:
    if player is holding an diamond named "gun":
        shoot snowball at speed 4.8

This is what I use.
upload_2021-1-16_19-24-58-png.5674
 
I made a whole script gun for myself bc i have nothing better to do at 12am
you can have it
Code:
command /weapon [<text>] [<player>]:
  permission: manager
  trigger:
    if arg-2 is not set:
      send "/weapon <weapon type or list> <player>"
     
    if arg-2 is set:
      if arg-1 is "list":
        send "1) AK-47"
        SEND "2) Bazooka"
      if arg-1 is "ak47":
        give arg-2 stick named "&cAK-47" with lore "&7Right click from a distance at a player.%newline%&7you're gonna be there soon :]"
        send "&aGave &f%arg-2% &aan AK-47." to player
      if arg-1 is "bazooka":
        give arg-2 diamond shovel named "&2&lBAZOOKA" with lore "&7Right click from a distance at a player.%newline%&7but it's &2&lBOOM BOOM&7..."
        send "&aGave &f%arg-2% &aa Bazooka." to player
     
on damage:
  projectile is a snowball
  attacker is holding a stick named "&cAK-47" with lore "&7Right click from a distance at a player.%newline%&7you're gonna be there soon :]":
    damage victim by 2 hearts
   
on projectile hit:
  projectile is an egg
  shooter is holding a diamond shovel named "&2&lBAZOOKA" with lore "&7Right click from a distance at a player.%newline%&7but it's &2&lBOOM BOOM&7...":
    shooter is in world "eventshub" or "allevents" or "build" or "parkours":
      send "&cBuddy not today. Be in another world not the %shooter's world% &cworld..." to shooter
    else:
      loop all living entities in radius 10 around projectile:
        damage loop-entity by 9 hearts
      create an explosion of force 10 at projectile
      set {air} to air
      loop all blocks in radius 5 around projectile:
        loop-block is not bedrock:
          set loop-block to {air}
 
   
on right click:
  player is holding a stick named "&cAK-47" with lore "&7Right click from a distance at a player.%newline%&7you're gonna be there soon :]":
    if {ammoak47.%player%} is greater or equal to 20:
      send "&aWeapon needs a reload! Left click to reload!"
    else:
      shoot a snowball from player at speed 1
      add 1 to {ammoak47.%player%}
     
on left click:
  player is holding a stick named "&cAK-47" with lore "&7Right click from a distance at a player.%newline%&7you're gonna be there soon :]":
    send "&aReloading."
    wait 3 ticks
    send "&aReloading.."
    wait 3 ticks
    send "&aReloading..."
    wait 3 ticks
    clear {ammoak47.%player%}
    send "&aReload succeeded! You may now shoot."
    play random.bowhit to player at volume 10
   
 
   
on rightclick:
  player is holding a diamond shovel named "&2&lBAZOOKA" with lore "&7Right click from a distance at a player.%newline%&7but it's &2&lBOOM BOOM&7...":
    set {baz} to difference between {baz.%player%} and now
    if {baz} is less than 5 seconds:
      send "&aReloading..."
      stop
    set {baz.%player%} to now
    shoot an egg from player at speed 1
it includes a bazooka and a reload system and an ak and a bazooka with blacklisted worlds in line 26
if you don't wanna get griefed then you can add blacklisted worlds
 
Status
Not open for further replies.