• Hey! Register here to create your account, engage with the community, and talk about what is new!

How to get the damager in the Entity Take Damage event?

IceFreeze008

New member
Joined
Oct 30, 2020
Messages
9
Reaction score
0
I want to get the player who hits an entity so that I can find out which item the player used to hit the entity. For testing purposes, I have a SendMessage block immediately after the event, which is set to all players. In there are two books. One named "%victim" and the other one named "%damager". When I hit the entity (a zombie) with a sword or my hand, the chat shows the name of the entity (all good so far) and then just "%damager" and not the name of the player, as I would have expected. What am I doing wrong?

The Code:
code.png

The Chat:
chat.png
 
Solution
Update: I solved it by moving the whole code into the player event "Player Damage Entity Event". Now I can just use %victim for the entity and %default for the player.

IceFreeze008

New member
Joined
Oct 30, 2020
Messages
9
Reaction score
0
Update: I solved it by moving the whole code into the player event "Player Damage Entity Event". Now I can just use %victim for the entity and %default for the player.
 
Solution
Top Bottom