OnWorldItemSpawn: Difference between revisions
Jump to navigation
Jump to search
Update Lua event reference |
Document Lua events available or improved from G1R:MP 0.1.2 |
||
| Line 1: | Line 1: | ||
= onWorldItemSpawn = | = onWorldItemSpawn = | ||
Triggered | <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 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.</div> | |||
</div> | |||
Triggered after <code>spawnItem</code> or <code>spawnTestItem</code> creates and publishes a synchronized world item. | |||
== Availability == | == Availability == | ||
| Line 15: | Line 19: | ||
! Name !! Type !! Description | ! Name !! Type !! Description | ||
|- | |- | ||
| <code>objectId</code> || <code>int</code> || The | | <code>objectId</code> || <code>int</code> || The positive server-assigned 64-bit world-item object ID. | ||
|- | |- | ||
| <code>itemKey</code> || <code>string</code> || The stable item definition key. | | <code>itemKey</code> || <code>string</code> || The stable item definition key. | ||
|- | |- | ||
| <code>quantity</code> || <code>int</code> || The | | <code>quantity</code> || <code>int</code> || The authoritative stack quantity; currently one for <code>spawnItem</code> and <code>spawnTestItem</code>. | ||
|- | |- | ||
| <code>x</code> || <code>number</code> || | | <code>x</code> || <code>number</code> || Published X coordinate in Unreal centimetres. | ||
|- | |- | ||
| <code>y</code> || <code>number</code> || | | <code>y</code> || <code>number</code> || Published Y coordinate in Unreal centimetres. | ||
|- | |- | ||
| <code>z</code> || <code>number</code> || | | <code>z</code> || <code>number</code> || Published Z coordinate in Unreal centimetres. | ||
|- | |- | ||
| <code>sourcePlayerId</code> || <code>int</code> || The player | | <code>sourcePlayerId</code> || <code>int</code> || The connected player whose latest snapshot was used to place the item. | ||
|} | |} | ||
| Line 39: | Line 43: | ||
== Notes == | == 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. | |||
[[Category:Lua Events]] | [[Category:Lua Events]] | ||
[[Category:Server Events]] | [[Category:Server Events]] | ||
[[Category:World Events]] | [[Category:World Events]] | ||
Latest revision as of 18:41, 3 September 2026
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.