Postado Novembro 17, 2017 7 anos Autor 32 minutos atrás, luanluciano93 disse: resolved then? do you think you can help me convert this function to tfs 1.2? function getAllItemsById(cid, id) local containers = {} local items = {} for i = CONST_SLOT_FIRST, CONST_SLOT_LAST do local sitem = getPlayerSlotItem(cid, i) if sitem.uid > 0 then if isContainer(sitem.uid) then table.insert(containers, sitem.uid) elseif not(id) or id == sitem.itemid then table.insert(items, sitem) end end end while #containers > 0 do for k = (getContainerSize(containers[1]) - 1), 0, -1 do local tmp = getContainerItem(containers[1], k) if isContainer(tmp.uid) then table.insert(containers, tmp.uid) elseif not(id) or id == tmp.itemid then table.insert(items, tmp) end end table.remove(containers, 1) end return items end It will return an array with the items. Example: Code (Text): for _, item in pairs(getAllItemsById(cid, 2222)) do doPlayerSay(cid, "I got an item with id " .. item.itemid .. ".") end
Postado Novembro 17, 2017 7 anos function Player.getAllItemsById(self, id) local containers = {} local items = {} for i = CONST_SLOT_HEAD, CONST_SLOT_AMMO do local item = self:getSlotItem(i) if item then if item:isContainer() then table.insert(containers, item:getUniqueId()) elseif not id or id == item:getId() then table.insert(items, item:getUniqueId()) end end end while #containers > 0 do for k = (Container(containers[1]):getSize() - 1), 0, -1 do local tmp = Container(containers[1]):getItem(k) if tmp:isContainer() then table.insert(containers, tmp:getUniqueId()) elseif not id or id == tmp:getId() then table.insert(items, tmp:getUniqueId()) end end table.remove(containers, 1) end return items end STYLLER OT 2022
Postado Novembro 17, 2017 7 anos Autor 36 minutos atrás, luanluciano93 disse: function Player.getAllItemsById(self, id) local containers = {} local items = {} for i = CONST_SLOT_HEAD, CONST_SLOT_AMMO do local item = self:getSlotItem(i) if item then if item:isContainer() then table.insert(containers, item:getUniqueId()) elseif not id or id == item:getId() then table.insert(items, item:getUniqueId()) end end end while #containers > 0 do for k = (Container(containers[1]):getSize() - 1), 0, -1 do local tmp = Container(containers[1]):getItem(k) if tmp:isContainer() then table.insert(containers, tmp:getUniqueId()) elseif not id or id == tmp:getId() then table.insert(items, tmp:getUniqueId()) end end table.remove(containers, 1) end return items end i try this: function getAllItemsById(self, id) local containers = {} local items = {} for i = CONST_SLOT_HEAD, CONST_SLOT_AMMO do local item = self:getSlotItem(i) if item then if item:isContainer() then table.insert(containers, item:getUniqueId()) elseif not id or id == item:getId() then table.insert(items, item:getUniqueId()) end end end while #containers > 0 do for k = (Container(containers[1]):getSize() - 1), 0, -1 do local tmp = Container(containers[1]):getItem(k) if tmp:isContainer() then table.insert(containers, tmp:getUniqueId()) elseif not id or id == tmp:getId() then table.insert(items, tmp:getUniqueId()) end end table.remove(containers, 1) end return items end function onSay(player, words, param) for _, item in pairs(getAllItemsById(player, 12571)) do player:sendTextMessage(messageType or MESSAGE_STATUS_CONSOLE_ORANGE, 'I got an item with id ' .. item.itemid .. '.') end end
Participe da conversa
Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.