OnPlayerConsumableCommitRequested
onPlayerConsumableCommitRequested
AVAILABLE FROM UPDATE 0.1.3
This event is available in G1R:MP 0.1.3 and later. The contract below includes the compatibility guarantees introduced in that update.
Triggered after an authoritative consumable use passes validation and reserves one item, requesting durable stage-one inventory persistence.
Availability
This event is available in server-side scripts.
Callback signature
onPlayerConsumableCommitRequested(playerId, itemKey, inventoryItemId, sequence, commitKey, quantityRemaining, health, maxHealth, mana, maxMana, strength, dexterity, alcohol, swampweed, appliedHealth, appliedMana, periodicTicks, periodicHealthPerTick, periodicManaPerTick, deltaHealth, deltaMaxHealth, deltaMana, deltaMaxMana, deltaStrength, deltaDexterity, deltaAlcohol, deltaSwampweed)
Parameters
| Name | Type | Description |
|---|---|---|
playerId |
int |
The player using the consumable. |
itemKey |
string |
The stable native inventory key of the consumable. |
inventoryItemId |
int |
The native numeric consumable ID. |
sequence |
int |
The positive client request sequence. |
commitKey |
string |
An opaque key that uniquely identifies this durable operation. |
quantityRemaining |
int |
The authoritative quantity remaining after the in-memory reservation. |
health |
number |
Projected health after the instant part of the effect. |
maxHealth |
number |
Projected maximum health. |
mana |
number |
Projected mana after the instant part of the effect. |
maxMana |
number |
Projected maximum mana. |
strength |
number |
Projected strength. |
dexterity |
number |
Projected dexterity. |
alcohol |
number |
Projected alcohol progression value. |
swampweed |
number |
Projected swampweed progression value. |
appliedHealth |
number |
Projected instant health change after clamping. |
appliedMana |
number |
Projected instant mana change after clamping. |
periodicTicks |
int |
The number of periodic ticks authored for the item. |
periodicHealthPerTick |
number |
Authored health change per periodic tick. |
periodicManaPerTick |
number |
Authored mana change per periodic tick. |
deltaHealth |
number |
Authored instant health delta. |
deltaMaxHealth |
number |
Authored maximum-health delta. |
deltaMana |
number |
Authored instant mana delta. |
deltaMaxMana |
number |
Authored maximum-mana delta. |
deltaStrength |
number |
Authored strength delta. |
deltaDexterity |
number |
Authored dexterity delta. |
deltaAlcohol |
number |
Authored alcohol delta. |
deltaSwampweed |
number |
Authored swampweed delta. |
Examples
Handle the event:
addEventHandler("onPlayerConsumableCommitRequested", root, function(playerId, itemKey, inventoryItemId, sequence, commitKey, quantityRemaining, health, maxHealth, mana, maxMana, strength, dexterity, alcohol, swampweed, appliedHealth, appliedMana, periodicTicks, periodicHealthPerTick, periodicManaPerTick, deltaHealth, deltaMaxHealth, deltaMana, deltaMaxMana, deltaStrength, deltaDexterity, deltaAlcohol, deltaSwampweed)
outputDebugString("Consumable commit requested: " .. itemKey .. " #" .. sequence)
end)
Notes
- This advanced durability-lifecycle callback is part of the stable server-side Lua contract beginning with update 0.1.3.
- The bundled
gothic_rpresource owns persistence and is the only resource authorized to acknowledge this request withcompletePlayerConsumableUse. Other resources must treat it as read-only. - The callback is not emitted for requests rejected before validation and reservation.
quantityRemainingalready reflects the reserved item. - A Lua return value does not accept or reject the operation. Do not remove the item or apply the projected progression values again.
- Use
sequencetogether with the opaquecommitKeyto correlate later lifecycle callbacks.