• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Script Npc: doPlayerAddItem

Aggroz

New Member
Joined
Feb 14, 2019
Messages
2
Reaction score
0
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

36759

i bought 10 small healt potion and used 5 slot in bag

36760


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
 
erase the while loop


local onBuy = function(cid, item, subType, amount, ignoreCap, inBackpacks)
if items[item].buy ~= 0 then
doPlayerRemoveMoney(cid, amount * items[item].buy)
doPlayerAddItem(cid, items[item].id, amount)
npcHandler:say("Tu compraste "..amount.." "..items[item].name.." Por "..items[item].buy * amount.." gold coins.", cid)
end
end
 
Back
Top