playerHealthOrArmourDecreased
Tells your gamemode when a player’s game reports less health or armour than before. It’s what their game says happened, not a confirmed hit.
Renamed in 0.28 from damageObserved; see renamed names.
Signature
Section titled “Signature”server.on("playerHealthOrArmourDecreased", ({ player, healthChange, armourChange, provenance, attacker, weapon }) => void)Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
player |
PlayerSnapshot |
The player. |
healthChange |
{ before: number; after: number } | null |
The change in health, or null if health didn’t change. |
armourChange |
{ before: number; after: number } | null |
The change in armour, or null. |
provenance |
"client-state" |
Where the observation comes from: the player’s own state reports. |
attacker |
null |
Always null for now. |
weapon |
null |
Always null for now. |
Example
Section titled “Example”import { server } from "nativemp";
server.on("playerHealthOrArmourDecreased", ({ player, healthChange }) => { if (healthChange) server.log(`${player.name} lost ${healthChange.before - healthChange.after} health`);});Related
Section titled “Related”players.setHealth: set healthplayerDied: a player has dieddamage.setPlayerDamagePolicy: friendly fire, scales and off, applied to each hit between games