OnWorldItemSpawn
onWorldItemSpawn
Triggered when the server creates a synchronized pickup item in the world.
Availability
This event is available in server-side scripts.
Callback signature
onWorldItemSpawn(objectId, itemKey, quantity, x, y, z, sourcePlayerId)
Parameters
| Name | Type | Description |
|---|---|---|
objectId |
int |
The authoritative world-item object ID. |
itemKey |
string |
The stable item definition key. |
quantity |
int |
The spawned quantity. |
x |
number |
Spawn X coordinate in metres. |
y |
number |
Spawn Y coordinate in metres. |
z |
number |
Spawn Z coordinate in metres. |
sourcePlayerId |
int |
The player associated with the spawn request, if any. |
Examples
Handle the event:
addEventHandler("onWorldItemSpawn", root, function(objectId, itemKey, quantity, x, y, z, sourcePlayerId)
outputDebugString("Spawned " .. quantity .. "x " .. itemKey .. " as world item " .. objectId)
end)
Notes
- Synchronized items are server-owned and are included in late-join state.