OnPlayerUseCarryItem
A player pressed or let go of the left mouse button while holding a carry item the mode made usable.
Only for items SetCarryItemUse made usable, and only once the item is in the hands (a press during the pickup counts
nothing). Each press is followed by its release - also when the item leaves the hands with the button still down: then the
release comes first and OnPlayerPutDownCarryItem after it - so a mode can time a hold. Presses come at most ten a second.
Nothing plays by itself: the mode decides what a press does - an upper-body emote (PlayPlayerEmote, the built-in
"drink" or one of AddEmote’s), a sound (PlaySoundAt), an item, a message. On a tankard or a stein the press still
sips (SetCarryItemDrink) unless this returns false; on anything else the return value is ignored.
Syntax
Section titled “Syntax”function OnPlayerUseCarryItem(pid, id, item, pressed) -- ...end| Parameter | Type | |
|---|---|---|
pid |
number | the carrier |
id |
number | the carry item’s entity id |
item |
string | the item’s name, or its class GUID |
pressed |
boolean | true the button went down, false it was let go |
Returns
Section titled “Returns”on a tankard’s or a stein’s press false skips its sip; otherwise ignored
Example
Section titled “Example”-- a smith's hammer: each strike plays a gesture and rings the anvil (a sound file of the mode's)function OnPlayerUseCarryItem(pid, id, item, pressed) if pressed and item == "normalHammer" then PlayPlayerEmote(pid, "point") local x, y, z = GetPlayerPos(pid) PlaySoundAt(x, y, z, "anvil_strike.ogg") endendSee also
Section titled “See also”SetCarryItemUse · GetCarryItemUse · OnPlayerPutDownCarryItem · the Carry items group of the index
