OnWorldItemPickup: Difference between revisions

From Wiki G1R-MP G1 Remake Multiplayer
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:
<!-- This page is generated from the verified Lua event definition: onWorldItemPickup. -->
= onWorldItemPickup =
= onWorldItemPickup =
Triggered after the server validates a synchronized world-item pickup.
<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 the server accepts a synchronized world-item pickup and applies its authoritative inventory grant.


== Availability ==
== Availability ==
Line 8: Line 12:
== Callback signature ==
== Callback signature ==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
onWorldItemPickup(objectId, playerId, itemKey, quantityRemaining, serverTimeMs)
onWorldItemPickup(objectId, playerId, itemKey, quantity, serverTimeMs)
</syntaxhighlight>
</syntaxhighlight>


Line 15: Line 19:
! Name !! Type !! Description
! Name !! Type !! Description
|-
|-
| <code>objectId</code> || <code>int</code> || The world-item object ID.
| <code>objectId</code> || <code>int</code> || The positive server-assigned 64-bit world-item object ID.
|-
|-
| <code>playerId</code> || <code>int</code> || The player that picked up the item.
| <code>playerId</code> || <code>int</code> || The player that picked up the item.
Line 21: Line 25:
| <code>itemKey</code> || <code>string</code> || The stable item definition key.
| <code>itemKey</code> || <code>string</code> || The stable item definition key.
|-
|-
| <code>quantityRemaining</code> || <code>int</code> || Quantity left in the world after pickup.
| <code>quantity</code> || <code>int</code> || The complete accepted world-stack quantity granted to the player.
|-
|-
| <code>serverTimeMs</code> || <code>int</code> || Server timestamp of the accepted pickup.
| <code>serverTimeMs</code> || <code>int</code> || Server timestamp of the accepted pickup.
Line 29: Line 33:
Handle the event:
Handle the event:
<syntaxhighlight lang="lua" line>
<syntaxhighlight lang="lua" line>
addEventHandler("onWorldItemPickup", root, function(objectId, playerId, itemKey, quantityRemaining, serverTimeMs)
addEventHandler("onWorldItemPickup", root, function(objectId, playerId, itemKey, quantity, serverTimeMs)
     outputDebugString(getPlayerName(playerId) .. " picked up " .. itemKey)
     outputDebugString(getPlayerName(playerId) .. " picked up " .. itemKey)
end)
end)
Line 35: Line 39:


== Notes ==
== Notes ==
* When quantity reaches zero, clients remove the synchronized pickup from the world.
* The server has already added <code>quantity</code> to its authoritative native inventory cache before this observation event. Do not grant the same items again from the handler.
* The picked-up tombstone is broadcast reliably and the object is removed from active late-join state before callbacks run. The bundled GothicRP resource then persists the inventory grant asynchronously.
* Rejected, stale, duplicate, out-of-range, or over-capacity pickup attempts do not emit this event.


[[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

onWorldItemPickup

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 the server accepts a synchronized world-item pickup and applies its authoritative inventory grant.

Availability

This event is available in server-side scripts.

Callback signature

onWorldItemPickup(objectId, playerId, itemKey, quantity, serverTimeMs)

Parameters

Name Type Description
objectId int The positive server-assigned 64-bit world-item object ID.
playerId int The player that picked up the item.
itemKey string The stable item definition key.
quantity int The complete accepted world-stack quantity granted to the player.
serverTimeMs int Server timestamp of the accepted pickup.

Examples

Handle the event:

addEventHandler("onWorldItemPickup", root, function(objectId, playerId, itemKey, quantity, serverTimeMs)
    outputDebugString(getPlayerName(playerId) .. " picked up " .. itemKey)
end)

Notes

  • The server has already added quantity to its authoritative native inventory cache before this observation event. Do not grant the same items again from the handler.
  • The picked-up tombstone is broadcast reliably and the object is removed from active late-join state before callbacks run. The bundled GothicRP resource then persists the inventory grant asynchronously.
  • Rejected, stale, duplicate, out-of-range, or over-capacity pickup attempts do not emit this event.