local SHOP = {
[ACTION_ID] = {
reward = ITEM_ID,
cost = 100,
count = 1,
}
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
local t = SHOP[item.actionid]
if t then
if(doPlayerRemoveMoney(cid, t.cost)) then
local id = doCreateItemEx(t.reward, t.count or 1)
if(doPlayerAddItemEx(cid, id) ~= RETURNVALUE_NOERROR) then
return doPlayerSendCancel(cid, "You cannot carry this item."), false
end
doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_BLUE)
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You have purchased " .. getItemName(t.reward) .. ".")
else
doPlayerSendCancel(cid, "You do not have enough money.")
end
end
return true
end