DamagePlayer

From Wiki G1R-MP G1 Remake Multiplayer
Revision as of 09:52, 15 August 2026 by QCherry (talk | contribs) (Complete Lua function catalog)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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 produces onPlayerHit.
  • When health reaches zero, the normal onPlayerDeath policy is executed.
  • Damage is rejected while the target is already downed or dead.