Ir para conteúdo

Featured Replies

  • Respostas 23
  • Visualizações 1.7k
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • luanluciano93
    luanluciano93

    -- <talkaction words="!test" script="teste.lua" /> function onSay(player, words, param) local resultId = db.storeQuery("SELECT `player_id`,`pid`,`sid`,CONVERT(`attributes` USING latin1) AS `at

  • luanluciano93
    luanluciano93

    -- <talkaction words="!test" script="teste.lua" /> function onSay(player, words, param) local resultId = db.storeQuery("SELECT `player_id`,`pid`,`sid`,CONVERT(`attributes` USING latin1) AS `at

  • luanluciano93
    luanluciano93

    -- <talkaction words="!test" script="teste.lua" /> function onSay(player, words, param) local resultId = db.storeQuery("SELECT `player_id`,`sid`, CONVERT(`attributes` USING latin1) AS `attr` F

Postado
  • 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):
  1. for _, item in pairs(getAllItemsById(cid, 2222)) do
  2.     doPlayerSay(cid, "I got an item with id " .. item.itemid .. ".")
  3. end
Postado
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

 

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

 

 

 

image.png

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.

Visitante
Responder

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.6k

Informação Importante

Confirmação de Termo