OnNpcSpawn
Jump to navigation
Jump to search
onNpcSpawn
Triggered after a resource creates a synchronized scripted human NPC.
Availability
This event is available in server-side scripts.
Callback signature
onNpcSpawn(npcId, name, skinKey, x, y, z, sourceResource)
Parameters
| Name | Type | Description |
|---|---|---|
npcId |
int |
The server-assigned NPC identifier. |
name |
string |
The NPC's validated display name. |
skinKey |
string |
The NPC's stable body-and-face appearance 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 owns the NPC. |
Examples
Handle the event:
addEventHandler("onNpcSpawn", root, function(npcId, name, skinKey, x, y, z, sourceResource)
outputDebugString("Spawned NPC " .. name .. " (" .. npcId .. ")")
end)
Notes
- The complete visual state is also sent on relevance entry and late join.