OnPlayerConsumableUse

From Wiki G1R-MP G1 Remake Multiplayer
Revision as of 22:31, 14 August 2026 by QCherry (talk | contribs) (Update Lua event reference)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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.