KAyo

PlayerDamage

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);
});

 

 

Share this post


Link to post
Share on other sites
Posted (edited)

Hello, I have the same issue (using C#).

Any workaround? Or shall I just move to node.js which seems better maintained?

 

Thanks ;)

Edited by Jorhoto

Share this post


Link to post
Share on other sites
Posted (edited)

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

Share this post


Link to post
Share on other sites
Posted (edited)

Ok, so the workaround is to fabricate yourself the event.

Thanks ;)

Edited by Jorhoto

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.