local coin = 9020 --coin id
local itan = 2195 --item for sale
local cname = getItemNameById(coin)
local iname = getItemNameById(itan)
function onUse(cid, item, frompos, item2, topos)
if getPlayerItemCount(cid, coin) >= 30 then
doSendMagicEffect(getThingPos(cid), CONST_ME_GIFT_WRAPS)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You bought '..iname..' for 30 '..cname..'"s)
doPlayerAddItem(cid, itan)
doPlayerRemoveItem(cid, coin, 30)
elseif getPlayerItemCount(cid, coin) <= 29 then
doSendMagicEffect(getThingPos(cid), CONST_ME_PUFF)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You don\'t have enough '..cname..'s to buy '..iname..'")
end
return TRUE
end