How to update player variables when the player deals damage?

Started by Octave_ on

Topic category: Help with modding (Java Edition)

Last seen on 00:46, 5. Jun 2023
Joined Apr 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How to update player variables when the player deals damage?

I have been trying to find a way to modify (specifically increase) a player variable when the player damages an entity. I have tried using the 'Entity Attacked' global trigger to increase the player variable, however that doesn't seem to work.

Any insight would be greatly appreciated!

Last seen on 00:59, 19. Oct 2022
Joined Feb 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
The problem would be that by…
Mon, 05/03/2021 - 17:02

The problem would be that by hitting an entity
and increasing the player variable,
you have selected the entity and not the player.
I don't know if there is a way to run it on behalf of the source entity.
But I give you an alternative solution
first procedure
second procedure

Last seen on 00:46, 5. Jun 2023
Joined Apr 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I've tried this and while it…
Wed, 05/05/2021 - 12:08

I've tried this and while it does update the player variable, another issue arises where the variable is not getting saved when I reload the world, detailed here: https://mcreator.net/forum/73577/player-variable-gui-stuck-0-when-reloa…. I appreciate the help, it's just really unfortunate that there doesn't seem to be any other way to update player variables when a player attacks an entity (perhaps that could be added in a future update "Player damages mob/entity" trigger, if Klemen is updating anymore).

Last seen on 00:59, 19. Oct 2022
Joined Feb 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Are you using the player…
Wed, 05/05/2021 - 17:02

Are you using the player variable, permanent?
Uso la nbt como puente para añadir valores a la variable de jugador permanente, luego coloca la nbt en 0, ya que la nbt no guarda valores permanentes

4