OnPlayerHit
Jump to navigation
Jump to search
onPlayerHit
Triggered after the server validates that one player hit another player.
Availability
This event is available in server-side scripts.
Callback signature
onPlayerHit(attackerId, targetId, damage, damageType, actionId)
Parameters
| Name | Type | Description |
|---|---|---|
attackerId |
int |
The attacking player ID. |
targetId |
int |
The hit player ID. |
damage |
number |
Validated damage applied by the server. |
damageType |
string |
Damage source such as melee, spell, bow, crossbow, or a script-defined type. |
actionId |
int or nil |
The replicated action ID when the originating flow provides one. |
Examples
Handle the event:
addEventHandler("onPlayerHit", root, function(attackerId, targetId, damage, damageType, actionId)
outputDebugString(getPlayerName(attackerId) .. " hit " .. getPlayerName(targetId) .. " for " .. damage)
end)
Notes
- The final
actionIdis omitted by some scripted damage paths; handlers must acceptnil.