OnWorldItemSpawn
onWorldItemSpawn
IMPROVED FROM UPDATE 0.1.2
This event 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.
Triggered after spawnItem or spawnTestItem creates and publishes a synchronized world item.
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 positive server-assigned 64-bit world-item object ID. |
itemKey |
string |
The stable item definition key. |
quantity |
int |
The authoritative stack quantity; currently one for spawnItem and spawnTestItem.
|
x |
number |
Published X coordinate in Unreal centimetres. |
y |
number |
Published Y coordinate in Unreal centimetres. |
z |
number |
Published Z coordinate in Unreal centimetres. |
sourcePlayerId |
int |
The connected player whose latest snapshot was used to place the item. |
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
- The item is broadcast reliably before this observation event and remains in the authoritative late-join state until it is picked up.
- Coordinates intentionally mirror the synchronized world-item packet and therefore use Unreal centimetres rather than the metre convention used by player transform events.
- Player-initiated inventory drops do not emit this event. They emit onWorldItemDrop only after their durable inventory transaction commits and the quarantined item is published.