DamagePlayer: Difference between revisions
Jump to navigation
Jump to search
Automatyczna aktualizacja dokumentacji funkcji |
Complete Lua function catalog |
||
| Line 36: | Line 36: | ||
* Damage is rejected while the target is already downed or dead. | * Damage is rejected while the target is already downed or dead. | ||
[[Category:Lua Functions]] | |||
[[Category:Server Functions]] | [[Category:Server Functions]] | ||
[[Category:Player Functions]] | [[Category:Player Functions]] | ||
[[Category:Life State Functions]] | [[Category:Life State Functions]] | ||
Latest revision as of 09:52, 15 August 2026
damagePlayer
Applies authoritative script damage to a living player.
Syntax
bool damagePlayer(int playerId, number amount [, int attackerId = 0, string damageType = "script"])
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
playerId |
int |
yes | The connected player identifier. |
amount |
number |
yes | Positive damage amount, up to 100000. |
attackerId |
int |
no | Optional connected attacker id; use 0 for server or environment damage. |
damageType |
string |
no | A safe damage-type key up to 32 characters; defaults to script. |
Returns
Returns true when damage is accepted and applied; otherwise returns false.
Examples
Apply environmental fire damage:
damagePlayer(playerId, 15, 0, "fire")
Notes
- Available only in server-side resource scripts.
- The function updates authoritative health and emits
onPlayerDamage. A non-zero attacker also producesonPlayerHit. - When health reaches zero, the normal
onPlayerDeathpolicy is executed. - Damage is rejected while the target is already downed or dead.