Closed peonso closed 8 years ago
@peonso , do you have this function in libs?
function SellPlayerEmptyVials(cid)
emptyvialmoney = 0
while doPlayerRemoveItem(cid, 2006, 1, 0) == true do
emptyvialmoney = (emptyvialmoney+5)
end
if getNumberValue(emptyvialmoney) > 0 then
doPlayerAddMoney(cid, getNumberValue(emptyvialmoney))
return true
else
return false
end
end
No, it works 100%? I was thinking about update sell module, some NPCs are using it and it bugs, it buy full vials.
Try my code first, if it works ok you'll have more time to think about sell module
Thanks @tarantonio!
This:
function sellPlayerEmptyVials(cid)
local emptyvialmoney = 0
while doPlayerRemoveItem(cid, 2006, 1, 0) == true do
emptyvialmoney = 5 + emptyvialmoney
end
if emptyvialmoney > 0 then
doPlayerAddMoney(cid, emptyvialmoney)
return true
else
return false
end
end
And this:
if msgcontains(msg, 'vial') or msgcontains(msg, 'deposit') or msgcontains(msg, 'flask') then
npcHandler:say("I will pay you 5 gold for every empty vial. Ok?", 1)
talk_state = 857
elseif talk_state == 857 and msgcontains(msg, 'yes') then
if sellPlayerEmptyVials(cid) == true then
npcHandler:say("Here's your money!", 1)
talk_state = 0
else
npcHandler:say("You don't have any empty vials!", 1)
talk_state = 0
end
end
https://github.com/peonso/tibialegacyserver/issues/78#issuecomment-250509710
shopModule:addSellableItem({'vial', 'potion', 'flask'}, 2006, 5)