OnWorldItemDrop: Difference between revisions
Document upcoming 0.1.9 custom native keys, shared doors, server Lua callbacks and persistence; not a release |
Release 0.1.9 / BUILD264 / Protocol42: availability and download setup; preserve experimental limits |
||
| Line 49: | Line 49: | ||
<!-- customkeys019:start --> | <!-- customkeys019:start --> | ||
'''Available from 0.1.9 | '''Available from 0.1.9. Use matching updated server and clients.''' | ||
== Custom-key pending drop requests == | == Custom-key pending drop requests == | ||
Signature remains <code>(objectId, playerId, item, quantity, serverTimeMs)</code>. For custom keys, only the defining resource receives this pre-commit persistence request. The quantity is already deducted; object publication/pickup is quarantined until [[completeWorldItemDrop]]. Other resources should use [[onWorldItemDropCommitted]] for custom-key observation. Existing ordinary-item GothicRP/observer behavior is preserved. See [[Custom keys#Drop, pickup and persistence|full contract]]. | Signature remains <code>(objectId, playerId, item, quantity, serverTimeMs)</code>. For custom keys, only the defining resource receives this pre-commit persistence request. The quantity is already deducted; object publication/pickup is quarantined until [[completeWorldItemDrop]]. Other resources should use [[onWorldItemDropCommitted]] for custom-key observation. Existing ordinary-item GothicRP/observer behavior is preserved. See [[Custom keys#Drop, pickup and persistence|full contract]]. | ||
<!-- customkeys019:end --> | <!-- customkeys019:end --> | ||
Latest revision as of 13:28, 20 October 2026
onWorldItemDrop
Triggered for public server resources after a player-initiated world-item drop is durably committed and published. From 0.1.9, custom keys use this event as a pre-commit request to their defining resource instead; observers use onWorldItemDropCommitted. Read the custom-key contract below before handling those items.
Availability
This event is available in server-side scripts.
Callback signature
onWorldItemDrop(objectId, playerId, itemKey, quantity, serverTimeMs)
Parameters
| Name | Type | Description |
|---|---|---|
objectId |
int |
The positive server-assigned 64-bit ID of the published dropped item. |
playerId |
int |
The player whose inventory supplied the dropped item. |
itemKey |
string |
The stable inventory and world-item definition key. |
quantity |
int |
The committed quantity removed from inventory and published in the world. |
serverTimeMs |
int |
Server timestamp recorded when the accepted drop intent created the quarantined item. |
Examples
Handle the event:
addEventHandler("onWorldItemDrop", root, function(objectId, playerId, itemKey, quantity, serverTimeMs)
outputDebugString("Player " .. playerId .. " dropped " .. quantity .. "x " .. itemKey)
end)
Notes
- The runtime first quarantines the new object and removes the quantity from the authoritative inventory cache. The bundled GothicRP resource persists that change before confirming the transaction.
- Only a successful durable confirmation publishes the item and emits this callback to public resources. A failed or rolled-back drop publishes no public
onWorldItemDropevent and restores the authoritative inventory state when the session is still connected. - The active item is broadcast reliably before public callbacks run and is then included in late-join state. This is an observation event: do not remove the inventory quantity a second time.
- Player-initiated drops emit this event instead of onWorldItemSpawn.
Available from 0.1.9. Use matching updated server and clients.
Custom-key pending drop requests
Signature remains (objectId, playerId, item, quantity, serverTimeMs). For custom keys, only the defining resource receives this pre-commit persistence request. The quantity is already deducted; object publication/pickup is quarantined until completeWorldItemDrop. Other resources should use onWorldItemDropCommitted for custom-key observation. Existing ordinary-item GothicRP/observer behavior is preserved. See full contract.