SetMonsterHealth: Difference between revisions

From Wiki G1R-MP G1 Remake Multiplayer
Jump to navigation Jump to search
Complete Lua function catalog
Document Lua APIs available or improved from G1R:MP 0.1.2
 
Line 1: Line 1:
<!-- This page is generated automatically from the function definition: setMonsterHealth. -->
= setMonsterHealth =
= setMonsterHealth =
<div style="background:#fff5f5; border:1px solid #d13b3b; border-left:5px solid #d13b3b; color:#111111; padding:0.85rem 1rem; margin:0.75rem 0 1rem;">
<div style="color:#111111; font-weight:bold; letter-spacing:0.04em;">IMPROVED FROM UPDATE 0.1.2</div>
<div style="color:#111111; margin-top:0.25rem;">This function is available in earlier releases and has corrected or expanded behavior in G1R:MP 0.1.2 and later. The contract below describes the updated behavior.</div>
</div>
Sets a monster's authoritative health.
Sets a monster's authoritative health.


Line 18: Line 22:


== Returns ==
== Returns ==
Returns <code>true</code> when the value is accepted; otherwise returns <code>false</code>.
Returns <code>true</code> when the value is accepted; otherwise returns <code>false</code>. Values above the monster's current maximum health are rejected.


== Examples ==
== Examples ==

Latest revision as of 18:40, 3 September 2026

setMonsterHealth

IMPROVED FROM UPDATE 0.1.2
This function is available in earlier releases and has corrected or expanded behavior in G1R:MP 0.1.2 and later. The contract below describes the updated behavior.

Sets a monster's authoritative health.

Syntax

bool setMonsterHealth(string monsterId, number health)

Parameters

Name Type Required Description
monsterId string yes The opaque decimal monster identifier returned by spawnMonster or getMonsters.
health number yes The non-negative health value to apply.

Returns

Returns true when the value is accepted; otherwise returns false. Values above the monster's current maximum health are rejected.

Examples

Restore a monster to full health:

local health, maximum = getMonsterHealth(monsterId)
setMonsterHealth(monsterId, maximum)

Notes

  • Available only in server-side resource scripts.
  • Setting health to zero transitions the monster into the server-owned death state.