OnPlayerConsumableUse
onPlayerConsumableUse
Triggered after the server accepts or rejects a consumable-use request.
Availability
This event is available in server-side scripts.
Callback signature
onPlayerConsumableUse(playerId, itemId, sequence, accepted, rejectReason, quantityRemaining, mana, maxMana, appliedRestore)
Parameters
| Name | Type | Description |
|---|---|---|
playerId |
int |
The player using the consumable. |
itemId |
int |
The consumable item ID. |
sequence |
int |
The client request sequence. |
accepted |
bool |
Whether the server accepted the use. |
rejectReason |
int |
The rejection reason code, or zero when accepted. |
quantityRemaining |
int |
Authoritative quantity remaining. |
mana |
number |
Authoritative mana after the request. |
maxMana |
number |
The player's maximum mana. |
appliedRestore |
number |
The amount of mana actually restored. |
Examples
Handle the event:
addEventHandler("onPlayerConsumableUse", root, function(playerId, itemId, sequence, accepted, rejectReason, quantityRemaining, mana, maxMana, appliedRestore)
if accepted then
outputChatBox("Restored " .. appliedRestore .. " mana.", playerId, 100, 160, 255)
end
end)
Notes
- This event observes authoritative inventory and mana changes; do not remove the item again.