players.setHealth
Sets a player’s health.
Signature
Section titled “Signature”players.setHealth(player: PlayerTarget, health: number): Promise<ActionResult>Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
player |
PlayerTarget |
The player, or their ID. |
health |
number |
The new health, 0 to 1000. A normal maximum is 100. |
Returns
Section titled “Returns”A promise of an ActionResult: applied once the player’s game has carried it out, rejected with a code, or timeout after five seconds without an answer.
Example
Section titled “Example”import { commands, players } from "nativemp";
commands.register("heal", async (player) => { await players.setHealth(player, 100);});Related
Section titled “Related”players.setArmour: the other half of a player’s protectionplayerHealthOrArmourDecreased: health going down
A captured Player keeps this effect bound to its connection across awaits; see Async handlers.