Jump to content

PlayerDamage


KAyo

Recommended Posts

I tried the PlayerDamage event on server and client side which only outputs a text to the chat for testing at first.
But on both variants the events didnt got triggered. Why?

mp.events.add("playerDamage", (player, healthLoss, armorLoss) => {
    mp.gui.chat.push("You lost: " + healthLoss);
});

 

 

Link to comment
Share on other sites

  • 4 weeks later...

Render and save health in variables.

 

For example in JS:

var lastHealth = 0;
const localPlayer = mp.players.local;

mp.events.add('render',  function() {
    var healthLoss = 0;
    if(lastHealth != localPlayer.getHealth()) {
        healthLoss = lastHealth - localPlayer.getHealth();
        lastHealth = localPlayer.getHealth();
    }
    if(healthLoss > 0) {
        // your code
    }
});

 

Edited by Legend
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...