Em alguns servidores a função 'doPlayerRemoveItem' não tem o parâmetro 'ignoreEquipped', fazendo com que o jogador acabe vendendo os itens que estão nos slots(equipados).
Esta função(gambiarra) serve para que o jogador ao vender itens no npc, o mesmo só compre itens que estiverem dentro da bp.
Primeiramente coloque essas duas funções na lib do seu ot caso você não tenha:
https://pastebin.com/raw/BfRLcrLA
agora vá em \data\npc\lib\npcsystem e abra o seu modules.lua
substitua essa função:
-- Callback onSell() function. If you wish, you can change certain Npc to use your onSell().
function ShopModule:callbackOnSell(cid, itemid, subType, amount, ignoreCap, inBackpacks)
if(self.npcHandler.shopItems[itemid] == nil) then
error("[ShopModule.onSell]", "items[itemid] == nil")
return false
end
if(self.npcHandler.shopItems[itemid].sellPrice == -1) then
error("[ShopModule.onSell]", "Attempt to sell a non-sellable item")
return false
end
local parseInfo = {
[TAG_PLAYERNAME] = getPlayerName(cid),
[TAG_ITEMCOUNT] = amount,
[TAG_TOTALCOST] = amount * self.npcHandler.shopItems[itemid].sellPrice,
[TAG_ITEMNAME] = self.npcHandler.shopItems[itemid].realName
}
if(subType < 1) then
subType = -1
end
if(doPlayerRemoveItem(cid, itemid, amount, subType)) then
local msg = self.npcHandler:getMessage(MESSAGE_SOLD)
msg = self.npcHandler:parseMessage(msg, parseInfo)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, msg)
doPlayerAddMoney(cid, amount * self.npcHandler.shopItems[itemid].sellPrice)
if(NPCHANDLER_CONVBEHAVIOR ~= CONVERSATION_DEFAULT) then
self.npcHandler.talkStart[cid] = os.time()
else
self.npcHandler.talkStart = os.time()
end
return true
else
local msg = self.npcHandler:getMessage(MESSAGE_NEEDITEM)
msg = self.npcHandler:parseMessage(msg, parseInfo)
doPlayerSendCancel(cid, msg)
if(NPCHANDLER_CONVBEHAVIOR ~= CONVERSATION_DEFAULT) then
self.npcHandler.talkStart[cid] = os.time()
else
self.npcHandler.talkStart = os.time()
end
return false
end
end
por esta:
-- Callback onSell() function. If you wish, you can change certain Npc to use your onSell().
function ShopModule:callbackOnSell(cid, itemid, subType, amount, ignoreCap, inBackpacks)
if(self.npcHandler.shopItems[itemid] == nil) then
error("[ShopModule.onSell]", "items[itemid] == nil")
return false
end
if(self.npcHandler.shopItems[itemid].sellPrice == -1) then
error("[ShopModule.onSell]", "Attempt to sell a non-sellable item")
return false
end
local parseInfo = {
[TAG_PLAYERNAME] = getPlayerName(cid),
[TAG_ITEMCOUNT] = amount,
[TAG_TOTALCOST] = amount * self.npcHandler.shopItems[itemid].sellPrice,
[TAG_ITEMNAME] = self.npcHandler.shopItems[itemid].realName
}
if(subType < 1) then
subType = -1
end
if getPlayerSlotItem(cid, CONST_SLOT_BACKPACK).itemid ~= 0 then
local bp = getPlayerSlotItem(cid, CONST_SLOT_BACKPACK)
local z = getContainerItemsById(bp, itemid)
if #z >= amount then
for i = 1, amount do
doRemoveItem(z[i].uid)
end
local msg = self.npcHandler:getMessage(MESSAGE_SOLD)
msg = self.npcHandler:parseMessage(msg, parseInfo)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, msg)
doPlayerAddMoney(cid, amount * self.npcHandler.shopItems[itemid].sellPrice)
if(NPCHANDLER_CONVBEHAVIOR ~= CONVERSATION_DEFAULT) then
self.npcHandler.talkStart[cid] = os.time()
else
self.npcHandler.talkStart = os.time()
end
return true
else
local msg = self.npcHandler:getMessage(MESSAGE_NEEDITEM)
msg = self.npcHandler:parseMessage(msg, parseInfo)
doPlayerSendCancel(cid, msg)
if(NPCHANDLER_CONVBEHAVIOR ~= CONVERSATION_DEFAULT) then
self.npcHandler.talkStart[cid] = os.time()
else
self.npcHandler.talkStart = os.time()
end
return false
end
else
doPlayerSendCancel(cid, "I only buy items that are inside a BackPack")
if(NPCHANDLER_CONVBEHAVIOR ~= CONVERSATION_DEFAULT) then
self.npcHandler.talkStart[cid] = os.time()
else
self.npcHandler.talkStart = os.time()
end
return false
end
end