OnPlayerSell
The player is about to sell to a shop - return false to refuse.
The player carries amount of the item (their last inventory report says so) and the shop can pay amount x price.
Return false and nothing moves. The items sold vanish - a shop does not put them on its shelf by itself; a mode that
wants a second-hand stall does it here with SetShopItem.
Syntax
Section titled “Syntax”function OnPlayerSell(pid, shop, class, amount, price) -- ...end| Parameter | Type | |
|---|---|---|
pid |
number | the seller |
shop |
number | the shop |
class |
string | the item’s class GUID |
amount |
number | how many |
price |
number | Groschen a piece, what the shop pays |
Returns
Section titled “Returns”false refuses the sale; anything else (or nothing) lets it through
Example
Section titled “Example”-- the smith buys weapons alone, and puts them up for sale again at twice the pricefunction OnPlayerSell(pid, shop, class, amount, price) local info = GetItemInfo(class) if not info or info.category ~= "MeleeWeapon" then SendClientMessage(pid, COLOR_RED, "The smith deals in weapons alone.") return false end SetShopItem(shop, class, price * 2, amount)endSee also
Section titled “See also”OnPlayerBuy · SetShopItem · GetShopMoney · the Shops and vendors group of the index
