OnPlayerDamage
onPlayerDamage
Triggered after authoritative damage changes a player's health.
Availability
This event is available in server-side scripts.
Callback signature
onPlayerDamage(playerId, damage, healthAfter, attackerId, damageType)
Parameters
| Name | Type | Description |
|---|---|---|
playerId |
int |
The damaged player ID. |
damage |
number |
The amount of damage applied. |
healthAfter |
number |
Authoritative health after damage. |
attackerId |
int |
The source player ID, or the runtime's no-player value. |
damageType |
string |
The damage source identifier. |
Examples
Handle the event:
addEventHandler("onPlayerDamage", root, function(playerId, damage, healthAfter, attackerId, damageType)
outputDebugString(getPlayerName(playerId) .. " now has " .. healthAfter .. " HP")
end)
Notes
- Use this event for observation and RP systems; do not apply the same damage a second time.