local config = {
[100] = {item, count, price},
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
local v = config[item.actionid]
if v then
if getPlayerMoney(cid) >= v[3] then
local id = doCreateItemEx(v[1], v[2] or 1)
if(doPlayerAddItemEx(cid, id, true) ~= RETURNVALUE_NOERROR) then
return doPlayerSendCancel(cid, "Sorry, you cannot carry this."), doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
end
doPlayerRemoveMoney(cid, v[3])
doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
doCreatureSay(cid, "You have bought a " .. getItemInfo(v[1]).name .. "!")
else
return doPlayerSendCancel(cid, "Sorry, you don't have enough money."), doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
end
end
return doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
end