local config = {
storage = 12234 -- The storage of VIP players
}
local t = {
["bow"] = {
items = { -- this is the bow you remove for the new items
{2148, 1}, -- {BOW ITEM ID, COUNT}
},
newItems = { -- these are the items received for trading the bow
{2160, 1}, -- {NEW_ITEM_ID, COUNT}
{2152, 10},
}
},
["wand"] = {
items = {
{2148, 1},
},
newItems = {
{2160, 1},
{2152, 10},
}
},
}
function onSay(cid, words, param, channel)
local v, removeItems = t[param], 0
if(param == "") then
doPlayerSendCancel(cid, "Command requires param.")
return true
end
if(getPlayerStorageValue(cid, config.storage) > 0) then
for i = 1, #v.items do
if(getPlayerItemCount(cid, v.items[i][1]) >= v.items[i][2]) then
removeItems = removeItems + 1
end
end
if(removeItems ~= #v.items) then
for i = 1, #v.items do
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You need " .. v.items[i][2] .. "x " .. getItemNameById(v.items[i][1]) .. " for the exchange.")
end
else
for k = 1, #v.newItems do
local id = doCreateItemEx(v.newItems[k][1], v.newItems[k][2])
if(doPlayerAddItemEx(cid, id, false) ~= RETURNVALUE_NOERROR) then
return doPlayerSendCancel(cid, "You cannot carry the new items."), false
end
end
for i = 1, #v.items do
doPlayerRemoveItem(cid, v.items[i][1], v.items[i][2] or 1)
end
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_BLUE)
doCreatureSay(cid, "Congratulations! You have made an exchange.", TALKTYPE_ORANGE_1)
end
end
return true
end