Hi, im copy a code from npc sell items but if i buy amount less than 20. used 2 slot in inventory and bought four instead of two
i bought 10 small healt potion and used 5 slot in bag
my question is how can I use only 1 slot. if i bought 2 health in bag appear as 4
Sorry for my bad english :'c !
i bought 10 small healt potion and used 5 slot in bag
my question is how can I use only 1 slot. if i bought 2 health in bag appear as 4
Sorry for my bad english :'c !
Lua:
local tradeOffers =
{
-- BUY OFFERS
{id=8704, buy=20, sell=0, name='small health potion'},
-- SELL OFFERS
{id=7636, buy=0, sell=5, name='empty potion flask'},
}
local items, data = {}
for i = 1, #tradeOffers do
data = tradeOffers[i]
items[data.id] = {id = data.id, buy = data.buy, sell = data.sell, name = data.name}
end
local onBuy = function(cid, item, subType, amount, ignoreCap, inBackpacks)
if items[item].buy ~= 0 then
doPlayerRemoveMoney(cid, amount * items[item].buy)
for i = 1, amount do
doPlayerAddItem(cid, items[item].id, amount)
end
npcHandler:say("Tu compraste "..amount.." "..items[item].name.." Por "..items[item].buy * amount.." gold coins.", cid)
end
end