This hook is called when a player has tossed an item. The
pickup has not been spawned yet. Plugins may disallow the tossing, but in that case they
need to clean up - the player's client already thinks the item has been tossed so the
inventory needs to be re-sent to the player.
To get the item that is about to be tossed, call the cPlayer:GetEquippedItem() function.
Callback function
The default name for the callback function is OnPlayerTossingItem. It has the following signature:
function MyOnPlayerTossingItem(Player)
Parameters:
Name | Type | Notes |
Player | cPlayer | The player tossing an item |
If the function returns false or no value, other plugins' callbacks are called and finally Cuberite
creates the pickup for the item and tosses it, using cPlayer:TossHeldItem, cPlayer:TossEquippedItem,
or cPlayer:TossPickup. If the function returns true, no other callbacks are called for this event
and Cuberite doesn't toss the item.
Code examplesRegistering the callback
cPluginManager:AddHook(cPluginManager.HOOK_PLAYER_TOSSING_ITEM, MyOnPlayerTossingItem);
|