OnMonsterSpawn
onMonsterSpawn
Triggered after the server creates a synchronized monster.
Availability
This event is available in server-side scripts.
Callback signature
onMonsterSpawn(monsterId, monsterType, x, y, z, sourceResource)
Parameters
| Name | Type | Description |
|---|---|---|
monsterId |
string |
Stable 64-bit monster ID represented as a string. |
monsterType |
string |
Normalized monster type key. |
x |
number |
Spawn X coordinate in metres. |
y |
number |
Spawn Y coordinate in metres. |
z |
number |
Spawn Z coordinate in metres. |
sourceResource |
string |
The resource that requested the spawn. |
Examples
Handle the event:
addEventHandler("onMonsterSpawn", root, function(monsterId, monsterType, x, y, z, sourceResource)
outputDebugString("Spawned " .. monsterType .. " with ID " .. monsterId)
end)
Notes
- Monster IDs must remain strings in Lua to preserve all 64-bit values.