• 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!

Lua sell equipped item

alcapone

Member
Joined
Jan 13, 2021
Messages
246
Reaction score
19
Lua:
local function onSell(cid, item, subType, amount, ignoreCap, inBackpacks)
    local player = Player(cid)
    if not player then
        return false
    end

    if not getTable(player) then
        return false
    end

    local items = setNewTradeTable(getTable(player))
    if items[item].sellPrice and player:removeItem(items[item].itemId, amount) then
        player:addMoney(items[item].sellPrice * amount)
        return player:sendTextMessage(MESSAGE_INFO_DESCR, 'Sold '..amount..'x '..items[item].realName..' for '..items[item].sellPrice * amount..' gold coins.')
    else
        selfSay("You don't have item to sell.", cid)
    end
    return true
end



using this function is selling the equipped item
 
Solution
entire function
player:removeItem(itemId, count[, subType = -1[, ignoreEquipped = false]])

suggested edit
if items[item].sellPrice and player:removeItem(items[item].itemId, amount, -1, true) then
entire function
player:removeItem(itemId, count[, subType = -1[, ignoreEquipped = false]])

suggested edit
if items[item].sellPrice and player:removeItem(items[item].itemId, amount, -1, true) then
 
Solution
entire function
player:removeItem(itemId, count[, subType = -1[, ignoreEquipped = false]])

suggested edit
if items[item].sellPrice and player:removeItem(items[item].itemId, amount, -1, true) then
it worked, the same problem now is that he is selling items with Imbuement but I don't think there's anything to do
 
it worked, the same problem now is that he is selling items with Imbuement but I don't think there's anything to do
Only thing I can think of is to grab the player inventory and iterate through it manually, to see if there are any items that match your specifications.
Check for itemId, imbuements, et cetera.

loop through the player inventory and check for containers,
then get the container contents container:getItems([recursive = false]) use true for recursive,
 
Last edited:
Back
Top