Skip to content

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.

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

false refuses the sale; anything else (or nothing) lets it through

-- the smith buys weapons alone, and puts them up for sale again at twice the price
function 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)
end

OnPlayerBuy · SetShopItem · GetShopMoney · the Shops and vendors group of the index