KAyo Posted April 1, 2019 Posted April 1, 2019 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); });
Jorhoto Posted May 4, 2019 Posted May 4, 2019 (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 May 4, 2019 by Jorhoto
Legend Posted May 5, 2019 Posted May 5, 2019 (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 May 5, 2019 by Legend
Jorhoto Posted May 5, 2019 Posted May 5, 2019 (edited) Ok, so the workaround is to fabricate yourself the event. Thanks Edited May 5, 2019 by Jorhoto
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now