• 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!
  • If you're using Gesior 2012 or MyAAC, please review this thread for information about a serious security vulnerability and a fix.

Lua sell equipped item

alcapone

Member
Joined
Jan 13, 2021
Messages
231
Reaction score
17
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

Xikini

I whore myself out for likes
Senator
Joined
Nov 17, 2010
Messages
6,245
Solutions
545
Reaction score
4,488
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
OP
OP
A

alcapone

Member
Joined
Jan 13, 2021
Messages
231
Reaction score
17
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
 

Xikini

I whore myself out for likes
Senator
Joined
Nov 17, 2010
Messages
6,245
Solutions
545
Reaction score
4,488
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:
Top