SetMonsterHealth: Difference between revisions

From Wiki G1R-MP G1 Remake Multiplayer
Jump to navigation Jump to search
Document server-owned monsters and interactions
 
Document Lua APIs available or improved from G1R:MP 0.1.2
 
(One intermediate revision by the same user not shown)
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 ==
Line 31: Line 35:
* Setting health to zero transitions the monster into the server-owned death state.
* Setting health to zero transitions the monster into the server-owned death state.


[[Category:Lua Functions]]
[[Category:Server Functions]]
[[Category:Server Functions]]
[[Category:World Functions]]
[[Category:World Functions]]
[[Category:Monster Functions]]
[[Category:Monster Functions]]

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.