Skript Version: 2.2dev23
Skript Author: Bensku
Minecraft Version: 1.10.2
---
Full Code:
I saw this code in another help post. [ https://forums.skunity.com/threads/particle-trail.2646/#post-6204 ]
I would like to define data to a proyectile (Name of the shooter and damage or a number) so, in a "on damage" event it'll check for the data of the proyectile.
But i looked in the docs and forums, doesnt seems to be posible. Any ideas?
Other Useful Info:
I can add any addons, that isnt a problem.
Addons using :
skRayFall 1.9.7 , SkQuery 1.10 , TuSKe 1.7.4
Have you tried searching the docs? Yes
Have you tried searching the forums? Yes
What other methods have you tried to fix it?
I tryied with this code
But, is vulnerable. A player can shoot with a pistol and change to a sniper before the projectile hits the victim, and the damage event will check the Sniper instead of the pistol :/
**SOLVED**
I use the TagAPI [https://forums.skunity.com/resources/tagapi.89/] from Mr_Simba, and SkStuff. Here is my test code that already works!
Skript Author: Bensku
Minecraft Version: 1.10.2
---
Full Code:
I saw this code in another help post. [ https://forums.skunity.com/threads/particle-trail.2646/#post-6204 ]
code_language.skript:
on entity shoot:
if event-entity is a player:
#Arrow projectile:
#Make it so bows will only shoot snowballs :P
broadcast "%shot arrow%"
spawn snowball at location above player
#Skript doesn't have a proper way to define an entity. So I'm using this spawning method workaround.
#I might make an effect to define a projectile and create data on top of that projectile, Like name etc.
set shot projectile to last spawned snowball
push shot projectile in direction of player at speed (arrow speed + 0.25)
broadcast "%shot projectile%"
But i looked in the docs and forums, doesnt seems to be posible. Any ideas?
Other Useful Info:
I can add any addons, that isnt a problem.
Addons using :
skRayFall 1.9.7 , SkQuery 1.10 , TuSKe 1.7.4
Have you tried searching the docs? Yes
Have you tried searching the forums? Yes
What other methods have you tried to fix it?
I tryied with this code
Java:
on right click using stone hoe:
if the name of player's tool is coloured "&7Pistol":
shoot snowball at speed 40
on right click using a gold hoe:
if the name of player's tool is coloured "&7Sniper":
shoot snowball at speed 70
on damage:
projectile is a snowball
if the name of shooter's tool is coloured "&7Pistol":
damage victim by 1 heart
if the name of shooter's tool is coloured "&7Sniper":
damage victim by 3 hearts
**SOLVED**
I use the TagAPI [https://forums.skunity.com/resources/tagapi.89/] from Mr_Simba, and SkStuff. Here is my test code that already works!
code_language.skript:
command /gun:
trigger:
give a stone hoe named coloured "&7Pistol" to player
give a gold hoe named coloured "&7Sniper" to player
on right click using stone hoe:
if the name of player's tool is coloured "&7Pistol":
spawn snowball at player's head #Note that the color is &c
push last spawned snowball in direction of player at speed 1
setKeyValueTag(last spawned snowball, "pistol", "%player%")
set {_m} to getKeyValueTag(last spawned snowball, "pistol")
send "&cFired: %{_m}%"
on right click using a gold hoe:
if the name of player's tool is coloured "&7Sniper":
spawn snowball at player's head #Note that the color is &c
push last spawned snowball in direction of player at speed 1
setKeyValueTag(last spawned snowball, "sniper", "%player%")
set {_m} to getKeyValueTag(last spawned snowball, "sniper")
send "&2Fired: %{_m}%"
on damage:
projectile exists
if hasKeyValueTag(projectile, "pistol") is true:
set {_player} to getKeyValueTag(last spawned snowball, "pistol") parsed as a player
set the shooter to {_player}
broadcast "&c->%shooter%"
stop
if hasKeyValueTag(projectile, "sniper") is true:
set {_player} to getKeyValueTag(last spawned snowball, "sniper") parsed as a player
set the shooter to {_player}
broadcast "&2->%shooter%"
stop
Last edited: