• TibiaFace

    Tibiaface | Una comunidad Open Tibia donde encontras : mapas, scripts, Otserver, npc y amigos etc ...

    .
    demo menumenu

    Afiliados



    Votar:

    [Pedido] autoloot system

    Compartir:

    Ver el tema anterior Ver el tema siguiente Ir abajo  Mensaje (Página 1 de 1.)

    1[Pedido] autoloot system Empty [Pedido] autoloot system Jue Ago 26, 2021 2:41 pm

    akane

    akane
    Miembro
    Miembro
    Descripcion escribió:hola a todos, quisiera pedirles ayuda con un autoloot system para otx 4 ya que los que he probado no me funcionan :c.

    seria para algo asi [Tienes que estar registrado y conectado para ver este vínculo]
    Imagen Explicativa escribió:Imagen Explicativa: [Pedido] autoloot system ChyqrgD
    Version del Scripts: OTx Old Version(0.3.7)

    2 participantes

    2[Pedido] autoloot system Empty Re: [Pedido] autoloot system Vie Ago 27, 2021 9:50 am

    [Admin] God Maya

    [Admin] God Maya
    Administrador
    Administrador
    al fin que es tu consola otx 4 o otx 0.3.7 por me confunde



    [Pedido] autoloot system YNU5B25
    2 participantes
    http://www.tibiaface.com

    3[Pedido] autoloot system Empty Re: [Pedido] autoloot system Vie Ago 27, 2021 1:08 pm

    akane

    akane
    Miembro
    Miembro
    es otx 4, el otro lo puse por poner

    2 participantes

    4[Pedido] autoloot system Empty Re: [Pedido] autoloot system Vie Ago 27, 2021 3:34 pm

    [Admin] God Maya

    [Admin] God Maya
    Administrador
    Administrador
    data/lib

    Código:

    AUTOLOOTSYSTEMNAME = "auto looting system"
    AUTOLOOTDELAY = 10
    AUTOLOOTCORPSEAID = 87078
    MAXAUTOLOOTITEMS = 10
    AUTOLOOTBLOCKEDITEM = {12632}
    AUTOLOOTITEMID = 1951
    AUTOLOOTONLYONCE = true
    AUTOLOOTATTRS = {"name", "description"} -- here you can type item attriburtes you want the auto loot system to copy in case you are using some attributes modifying system that drop items with attributes

    function doSetAutoLootCorpseAid(cid, pos, lookcorpse)
        local corpse = getTileItemById(pos, lookcorpse).uid
        if corpse == 0 then
           return true
       end

        if not isCorpse(corpse) then
           return true
       end
       
        local corpseOwner = getItemAttribute(corpse, 'corpseowner')
        local cid = corpseOwner and getPlayerByGUID(corpseOwner) or cid
        if not isPlayer(cid) then
           return true
       end

        return doItemSetAttribute(corpse, "aid", AUTOLOOTCORPSEAID)
    end

    function isItemBackpack(itemid)
        if isItemContainer(itemid) and getItemInfo(itemid).wieldPosition == 3 then
            return true
        end
        return false
    end

    function doSendAutoLootMessage(cid, playerautoloot)
        local msgs = ''
        local donelootc, doneloottext = playerautoloot[1][1], ""
        if donelootc > 0 then
            local s, i = '', 0
            for item, value in pairs(playerautoloot[1][2]) do
                local iteminfo, count = getItemInfo(item), value[2]
                if count > 1 then
                    local defaultname = getItemNameById(item)
                    s = count.." "..(iteminfo.stackable and iteminfo.showCount and iteminfo.plural or (string.sub(defaultname, -1) == 's' and defaultname or iteminfo.plural))
                else
                    s = (iteminfo.article == '' and "" or iteminfo.article .. " ")..value[1]
                end
                i = i+1
                doneloottext = doneloottext..(i > 1 and (i == donelootc and " & " or ", ") or "")..s
            end
            msgs = msgs..(msgs ~= '' and ', y' or 'Y').."ou have auto looted "..doneloottext
        end

        local noweightloot, noweightloottext = playerautoloot[2][1], ""
        if noweightloot > 0 then
            local s, i = '', 0
            for item, value in pairs(playerautoloot[2][2]) do
                local iteminfo, count = getItemInfo(item), value[2]
                if count > 1 then
                    local defaultname = getItemNameById(item)
                    s = count.." "..(iteminfo.stackable and iteminfo.showCount and iteminfo.plural or (string.sub(defaultname, -1) == 's' and defaultname or iteminfo.plural))..' that weigh '
                else
                    s = (iteminfo.article == '' and "" or iteminfo.article .. " ")..value[1].." that weighs "
                end
                i = i+1
                noweightloottext = noweightloottext..(i > 1 and (i == noweightloot and " & " or ", ") or "")..s..doNumberPrecision(getItemWeightById(item, 1)*count, 2).." oz"
            end
            msgs = msgs..(msgs ~= '' and ', y' or 'Y').."ou don't have enough capacity for "..noweightloottext
        end

        local noslotlootc, noslotloottext = playerautoloot[3][1], ""
        if noslotlootc > 0 then
            local s, i = '', 0
            for item, value in pairs(playerautoloot[3][2]) do
                local iteminfo, count = getItemInfo(item), value[2]
                if count > 1 then
                    local defaultname = getItemNameById(item)
                    s = count.." "..(iteminfo.stackable and iteminfo.showCount and iteminfo.plural or (string.sub(defaultname, -1) == 's' and defaultname or iteminfo.plural))
                else
                    s = (iteminfo.article == '' and "" or iteminfo.article .. " ")..value[1]
                end
                i = i+1
                noslotloottext = noslotloottext..(i > 1 and (i == noslotlootc and " & " or ", ") or "")..s
            end
            msgs = msgs..(msgs ~= '' and ', y' or 'Y').."ou don't have enough space for "..noslotloottext
        end

        local noslotcontainerlootc, noslotcontainerloottext = playerautoloot[4][1], ""
        if noslotcontainerlootc > 0 then
            local s, i = '', 0
            for item, value in pairs(playerautoloot[4][2]) do
                local iteminfo, count = getItemInfo(item), value[2]
                if count > 1 then
                    local defaultname = getItemNameById(item)
                    s = count.." "..(iteminfo.stackable and iteminfo.showCount and iteminfo.plural or (string.sub(defaultname, -1) == 's' and defaultname or iteminfo.plural))
                else
                    s = (iteminfo.article == '' and "" or iteminfo.article .. " ")..value[1]
                end
                i = i+1
                noslotcontainerloottext = noslotcontainerloottext..(i > 1 and (i == noslotcontainerlootc and " & " or ", ") or "")..s
            end
            msgs = msgs..(msgs ~= '' and ', y' or 'Y').."ou don't have enough space in container for "..noslotcontainerloottext
        end

        if msgs ~= '' then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "["..string.upper(AUTOLOOTSYSTEMNAME).."]: "..msgs..".")
        end
    end

    --- recursive function to loop throught containers inside containers to update stacks, save cap with transformitem function, remove remainder to disable auto stacking in lua
    function doUpdateAutoLootChildContainers(item, containers, remainder, lootcontainers) --- loot to backpacks
        for c = 1, #containers do
            if (#lootcontainers > 0 and not isInArray(lootcontainers, containers[c])) or #lootcontainers == 0 then --- prevents looping through parent-container/auto-loot-backpack that previously looped through, loot to backpacks
                local childcontainers = {}
                for s = 0, getContainerSize(containers[c])-1 do
                    local citem = getContainerItem(containers[c], s)
                    if (#lootcontainers > 0 and not isInArray(lootcontainers, citem.uid)) or #lootcontainers == 0 then --- prevents looping through parent-container/auto-loot-backpack that previously looped through, loot to backpacks
                        if isContainer(citem.uid) and getContainerSize(citem.uid) > 0 then
                            table.insert(childcontainers, citem.uid)
                        else
                            if citem.itemid == item.itemid and citem.type < 100 then
                                local tempitemtype, newamount = citem.type, remainder > 0 and remainder or item.type
                                doTransformItem(citem.uid, item.itemid, tempitemtype+newamount)
                                if tempitemtype+newamount > 100 then
                                    remainder = tempitemtype+newamount-100
                                else
                                    return RETURNVALUE_NOERROR, 0
                                end
                            end
                        end
                        if s == getContainerSize(containers[c])-1 and #childcontainers > 0 then
                            local ccontainersreturn, ccrremainder = doUpdateAutoLootChildContainers(item, childcontainers, remainder, lootcontainers) --- loot to backpacks
                            if ccontainersreturn == RETURNVALUE_NOERROR then
                                return RETURNVALUE_NOERROR, 0
                            end
                            remainder = ccrremainder
                        end
                    end  --- loot to backpacks
                end
            end  --- loot to backpacks
        end
        return -1, remainder
    end
    --- recursive function to loop throught containers inside containers to update stacks, save cap with transformitem function, remove remainder to disable auto stacking in lua

    --- recursive function to loop throught containers inside containers to get all auto loot backpacks, loot to backpacks
    function getAutoLootChildContainersById(id, containertable, item, notempty, single)
        local containers = {}
        for c = 1, #containertable do
            local childcontainers = {}
            for s = 0, getContainerSize(containertable[c])-1 do
                local citem = getContainerItem(containertable[c], s)
                if isContainer(citem.uid) then
                    if getContainerSize(citem.uid) > 0 then
                        table.insert(childcontainers, citem.uid)
                    end
                    if citem.itemid == id and ((notempty and getContainerSize(citem.uid) > 0) or (not notempty and getContainerSize(citem.uid) < getContainerCap(citem.uid))) then
                        table.insert(containers, citem)
                        if not isItemStackable(item) or single then
                            return containers
                        end
                    end
                end
                if s == getContainerSize(containertable[c])-1 and #childcontainers > 0 then
                    local containeritems = getAutoLootChildContainersById(id, childcontainers, item, notempty, single)
                    if #containeritems > 0 then
                        for i = 1, #containeritems do
                            table.insert(containers, containeritems[i])
                        end
                    end
                end
            end
        end
        return containers
    end
    --- recursive function to loop throught containers inside containers to get all auto loot backpacks, loot to backpacks

    --- loot to backpacks
    function getAutoLootBackpackById(id, list)
        for i = 1, #list do
            local pitem = string.explode(list[i], ",")
            if getItemIdByName(pitem[1], false) == id then
                return getItemIdByName(pitem[2], false)
            end
        end
    end
    --- loot to backpacks

    --- loot to backpacks
    function getPlayerAutoLootContainersById(cid, item, list, notempty, single)
        local containers, containeritemid = {}, getAutoLootBackpackById(item, list)
        if not containeritemid or getPlayerItemCount(cid, containeritemid) == 0 then
            return containers
        end

        local slots, invecontainers = {3, 5, 6, 10}, {}
        for i = 1, #slots do
            local slotitem = getPlayerSlotItem(cid, slots[i])
            if slotitem.itemid > 0 and isContainer(slotitem.uid) then
                if getContainerSize(slotitem.uid) > 0 then
                    table.insert(invecontainers, slotitem.uid)
                end
                if slotitem.itemid == containeritemid and ((notempty and getContainerSize(slotitem.uid) > 0) or (not notempty and getContainerSize(slotitem.uid) < getContainerCap(slotitem.uid))) then
                    table.insert(containers, slotitem.uid)
                    if not isItemStackable(item) or single then
                        return containers
                    end
                end
            end
        end
        if #invecontainers > 0 then
            local containeritems = getAutoLootChildContainersById(containeritemid, invecontainers, item, notempty, single)
            if #containeritems > 0 then
                for i = 1, #containeritems do
                    table.insert(containers, containeritems[i].uid)
                end
            end
        end
        return containers
    end
    --- loot to backpacks

    function doPlayerCopyAutoLootItem(cid, item, list) -- last variable for looting to backpacks
        --- save cap with transformitem function, remove remainder to disable auto stacking in lua
        local containeritems = getPlayerAutoLootContainersById(cid, item.itemid, list, false, true) -- loot to backpacks
        if isItemStackable(item.itemid) then
            if getPlayerItemCount(cid, item.itemid) == 0 then
                --- loot to backpack that got at least 1 empty slot
                if #containeritems > 0 then
                    for c = 1, #containeritems do
                        return doAddContainerItemEx(containeritems[c], getThing(doCreateItemEx(item.itemid, item.type)).uid), 0
                    end
                end
                --- loot to backpack that got at least 1 empty slot
                return doPlayerAddItemEx(cid, getThing(doCreateItemEx(item.itemid, item.type)).uid, false), 0
            else
                --- loot to backpacks
                local lootcontainers, remainder = getPlayerAutoLootContainersById(cid, item.itemid, list, true, false), 0
                if #lootcontainers > 0 then
                    local autolootchildcontainers = {}
                    for c = 1, #lootcontainers do
                        for s = 0, getContainerSize(lootcontainers[c])-1 do
                            local autolootcontainer = getContainerItem(lootcontainers[c], s)
                            if isContainer(autolootcontainer.uid) and getContainerSize(autolootcontainer.uid) > 0 then
                                table.insert(autolootchildcontainers, autolootcontainer.uid)
                            else
                                if autolootcontainer.itemid == item.itemid and autolootcontainer.type < 100 then
                                    local tempitemtype, newamount = autolootcontainer.type, remainder > 0 and remainder or item.type
                                    doTransformItem(autolootcontainer.uid, item.itemid, tempitemtype+newamount)
                                    if tempitemtype+newamount > 100 then
                                        remainder = tempitemtype+newamount-100
                                    else
                                        return RETURNVALUE_NOERROR, 0
                                    end
                                end
                            end
                        end
                        --- loot to backpack that got at least 1 empty slot
                        if #containeritems > 0 then
                            for i = 1, #containeritems do
                                if containeritems[i] == lootcontainers[c] then
                                    return doAddContainerItemEx(containeritems[i], getThing(doCreateItemEx(item.itemid, remainder > 0 and remainder or item.type)).uid), 0
                                end
                            end
                        end
                        --- loot to backpack that got at least 1 empty slot
                        if c == #lootcontainers and #autolootchildcontainers > 0 then
                            local ccontainersreturn, ccrremainder = doUpdateAutoLootChildContainers(item, autolootchildcontainers, remainder, {})
                            if ccontainersreturn == RETURNVALUE_NOERROR then
                                return RETURNVALUE_NOERROR, 0
                            end
                            remainder = ccrremainder
                        end
                    end
                end
                --- loot to backpacks
                --- loop through player's inventory
                local slots, containers = {3, 5, 6, 10}, {}
                for i = 1, #slots do
                    local slotitem = getPlayerSlotItem(cid, slots[i])
                    if slotitem.itemid ~= 0 then
                        if (#lootcontainers > 0 and not isInArray(lootcontainers, slotitem.uid)) or #lootcontainers == 0 then --- prevents looping through parent-container/auto-loot-backpack that previously looped through, loot to backpacks
                            if isContainer(slotitem.uid) and getContainerSize(slotitem.uid) > 0 then
                                table.insert(containers, slotitem.uid)
                            else
                                if slotitem.itemid == item.itemid and slotitem.type < 100 then
                                    local tempitemtype, newamount = slotitem.type, remainder > 0 and remainder or item.type
                                    doTransformItem(slotitem.uid, item.itemid, tempitemtype+newamount)
                                    if tempitemtype+newamount > 100 then
                                        remainder = tempitemtype+newamount-100
                                    else
                                        return RETURNVALUE_NOERROR, 0
                                    end
                                end
                            end
                        end --- loot to backpacks
                    end
                end
                --- loop through player's inventory
             
                --- loop through containers inside inventory containers
                if #containers > 0 then
                    for c = 1, #containers do
                        local ccontainersreturn, ccrremainder = doUpdateAutoLootChildContainers(item, containers, remainder, lootcontainers) --- loot to backpacks
                        if ccontainersreturn == RETURNVALUE_NOERROR then
                            return RETURNVALUE_NOERROR, 0
                        end
                        remainder = ccrremainder
                    end
                end
                --- loop through containers inside inventory containers
             
                --- loot to backpack that got at least 1 empty slot
                if #containeritems > 0 then
                    for c = 1, #containeritems do
                        return doAddContainerItemEx(containeritems[c], getThing(doCreateItemEx(item.itemid, remainder > 0 and remainder or item.type)).uid), 0
                    end
                end
                --- loot to backpack that got at least 1 empty slot
                return doPlayerAddItemEx(cid, getThing(doCreateItemEx(item.itemid, remainder > 0 and remainder or item.type)).uid, false), remainder
            end
        end
        --- save cap with transformitem function, remove remainder to disable auto stacking in lua
     
        --- loot to backpack that got at least 1 empty slot
        if #containeritems > 0 then
            for c = 1, #containeritems do
                return doAddContainerItemEx(containeritems[c], doCopyItem(item, AUTOLOOTATTRS).uid), 0
            end
        end
        --- loot to backpack that got at least 1 empty slot
        return doPlayerAddItemEx(cid, doCopyItem(item, AUTOLOOTATTRS).uid, false), 0 -- remove last variable to disable auto stacking in lua
    end

    function doAutoLootItem(cid, item, list) -- last variable for looting to backpacks
        if getItemWeight(item.uid) > getPlayerFreeCap(cid) then
            return 2, 0 -- 2 no enough cap -- 2 last variables to disable auto stacking in lua
        end

        local additem, remainder = doPlayerCopyAutoLootItem(cid, item, list) -- last variable for looting to backpacks
        if additem == RETURNVALUE_NOTENOUGHROOM then
            --- save cap with transformitem function, remove remainder to disable auto stacking in lua
            if remainder > 0 then
                doPlayerSave(cid)
                doRemoveItem(item.uid, item.type-remainder)
            end
            --- save cap with transformitem function, remove remainder to disable auto stacking in lua
            return 3, remainder -- 3 no enough room, remove last variable to disable auto stacking in lua
        end

        if additem == RETURNVALUE_CONTAINERNOTENOUGHROOM then
            --- save cap with transformitem function, remove remainder to disable auto stacking in lua
            if remainder > 0 then
                doPlayerSave(cid)
                doRemoveItem(item.uid, item.type-remainder)
            end
            --- save cap with transformitem function, remove remainder to disable auto stacking in lua
            return 4, remainder -- 4 no room in container, remove last variable to disable auto stacking in lua
        end
       
        doPlayerSave(cid)
        doRemoveItem(item.uid)
        return 1, 0 -- remove last 2 variables to disable auto stacking in lua
    end

    --- recursive function to loop throught containers inside containers of corpse to create list of lootable items
    function doCreateAutoLootList(item, lootlist)
        local loot = {}
        for s = 0, getContainerSize(item.uid)-1 do
            local item = getContainerItem(item.uid, s)
            if isContainer(item.uid) and getContainerSize(item.uid) > 0 then
                local containeritems = doCreateAutoLootList(item, lootlist)
                if #containeritems > 0 then
                    for i = 1, #containeritems do
                        table.insert(loot, containeritems[i])
                    end
                end
            else
                if isInArray(lootlist, getItemNameById(item.itemid)) then
                    table.insert(loot, item)
                end
            end
        end
        return loot
    end
    --- recursive function to loop throught containers inside containers of corpse to create list of lootable items

    --- loot to backpacks
    function getAutoLootItems(list)
        local items = {}
        if #list > 0 then
            for i = 1, #list do
                table.insert(items, string.explode(list[i], ",")[1])
            end
        end
        return items
    end
    --- loot to backpacks

    --- recrusive funtion looping through containes inside containers searching for auto loot item to get attriburte
    function getPlayerItemByIdAndAttributeInContainers(id, attribute, containers)
        for c = 1, #containers do
            local childcontainers = {}
            for s = 0, getContainerSize(containers[c])-1 do
                local citem = getContainerItem(containers[c], s)
                if isContainer(citem.uid) and getContainerSize(citem.uid) > 0 then
                    table.insert(childcontainers, citem.uid)
                else
                    if citem.itemid == id and getItemAttribute(citem.uid, attribute) then
                        return citem.uid
                    end
                end
                if s == getContainerSize(containers[c])-1 and #childcontainers > 0 then
                    local containersreturn = getPlayerItemByIdAndAttributeInContainers(id, attribute, childcontainers)
                    if containersreturn > 0 then
                        return containersreturn
                    end
                end
            end
        end
        return 0
    end
    --- recrusive funtion looping through containes inside containers searching for auto loot item to get attriburte

    --- searching for auto loot item to get attriburte
    function getPlayerItemByIdAndAttribute(cid, id, attribute)
        local slots, containers = {3, 5, 6, 10}, {}
        for i = 1, #slots do
            local slotitem = getPlayerSlotItem(cid, slots[i])
            if slotitem.itemid ~= 0 then
                if isContainer(slotitem.uid) and getContainerSize(slotitem.uid) > 0 then
                    table.insert(containers, slotitem.uid)
                else
                    if slotitem.itemid == id and getItemAttribute(slotitem.uid, attribute) then
                        return slotitem.uid
                    end
                end
            end
        end
        if #containers > 0 then
            return getPlayerItemByIdAndAttributeInContainers(id, attribute, containers)
        end
        return 0
    end

    --- searching for auto loot item to get attriburte
    function doPlayerAutoLoot(cid, item)
        local autolootparchment = getPlayerItemByIdAndAttribute(cid, AUTOLOOTITEMID, "text") -- getPlayerItemById(cid, true, AUTOLOOTITEMID).uid
        if autolootparchment > 0 and getItemAttribute(autolootparchment, 'text') then
            local autolootitems = string.explode(getItemAttribute(autolootparchment, 'text'), "\n")
            local lootableitems = getAutoLootItems(autolootitems)
            if #lootableitems > 0 then
                local loot, playerautoloot = doCreateAutoLootList(item, lootableitems), {{0, {}}, {0, {}}, {0, {}}, {0, {}}}
                if #loot > 0 then
                    for ditem = 1, #loot do
                        local item = loot[ditem]
                        local itemid, itemname, count = item.itemid, getItemAttribute(item.uid, 'name') or getItemNameById(item.itemid), isItemStackable(item.itemid) and item.type or 1
                        local lootitem, remainder = doAutoLootItem(cid, item, autolootitems) -- remove last 2 variables to disable auto stacking in lua -- last variable for looting to backpacks
                   --- send msg of amount looted in case remainder is set, save cap with transformitem function, remove remainder to disable auto stacking in lua
                   if remainder > 0 then
                       if playerautoloot[1][2][itemid] then
                          playerautoloot[1][2][itemid][2] = playerautoloot[1][2][itemid][2]+count-remainder
                      else
                          playerautoloot[1][1] = playerautoloot[1][1]+1
                          playerautoloot[1][2][itemid] = {itemname, count-remainder}
                      end
                   end
                   --- send msg of amount looted in case remainder is set, save cap with transformitem function, remove remainder to disable auto stacking in lua
                   
                        if playerautoloot[lootitem][2][itemid] then
                            playerautoloot[lootitem][2][itemid][2] = playerautoloot[lootitem][2][itemid][2]+(remainder > 0 and (lootitem == 1 and count-remainder or remainder) or count) -- remover remainder part to disable auto stacking in lua
                        else
                            playerautoloot[lootitem][1] = playerautoloot[lootitem][1]+1
                            playerautoloot[lootitem][2][itemid] = {itemname, (remainder > 0 and (lootitem == 1 and count-remainder or remainder) or count)} -- remover remainder part to disable auto stacking in lua
                        end
                    end
                end
                doSendAutoLootMessage(cid, playerautoloot)
            end
        end
    end

    data/creaturescripts/scripts


    Código:

    function onTextEdit(cid, item, newtext)
        if item.itemid == AUTOLOOTITEMID then
            if os.time() < getPlayerStorageValue(cid, "AUTOLOOTD") then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "["..string.upper(AUTOLOOTSYSTEMNAME).."]: " .. (getPlayerStorageValue(cid, "AUTOLOOTD") - os.time() > 0 and "You can edit "..getItemNameById(item.itemid).." only once per "..AUTOLOOTDELAY.." seconds. " .. getPlayerStorageValue(cid, "AUTOLOOTD") - os.time() .. " second"..(getPlayerStorageValue(cid, "AUTOLOOTD") - os.time() == 1 and "" or "s").." left" or "Just wait awhile") .. ".")
                return false
            end
     
            if getItemAttribute(item.uid, 'text') and string.lower(newtext) == getItemAttribute(item.uid, 'text') then
                return false
            end
     
            local newtitems, tablecount, itemtable, notfounditems, bitems, msgs = string.explode(newtext:lower(), "\n"), 0, {}, {}, {}, ""
            if #newtitems > 0 then
                for iitem = 1, #newtitems do
                    local newitc = string.explode(newtitems[iitem], ",")
                    local itemname, citemname = newitc[1] or '', newitc[2] or ''
                    local itemid, citemid = getItemIdByName(itemname, false), getItemIdByName(citemname, false)
                    if itemname ~= '' and not itemtable[itemname] and not isInArray(notfounditems, itemname) and #newitc < 3 then
                        if tablecount == MAXAUTOLOOTITEMS then
                            msgs = msgs..(msgs ~= '' and ', y' or 'Y').."ou can only write "..MAXAUTOLOOTITEMS.." item names that you can auto loot"
                            break
                        end
                        if itemid then
                            if getItemInfo(itemid).weight ~= 0 then
                                if not isItemBackpack(itemid) then
                                    if not isInArray(AUTOLOOTBLOCKEDITEM, itemid) then
                                        itemtable[itemname] = isItemBackpack(citemid) and citemname or ''
                                        tablecount = tablecount+1
                                    else
                                        table.insert(bitems, itemname)
                                    end
                                else
                                    msgs = msgs..(msgs ~= '' and ', y' or 'Y').."ou can't auto loot bags nor backpacks"
                                end
                            else
                                msgs = msgs..(msgs ~= '' and ', y' or 'Y').."ou can't auto loot weightless items"
                            end
                        else
                            table.insert(notfounditems, itemname)
                        end
                    end
                end
            end
     
            local founditemtext, count = "", 0
            if tablecount > 0 then
                for item, backpack in pairs(itemtable) do
                    count = count+1
                    founditemtext = founditemtext..(count == 1 and "" or "\n")..item..(backpack ~= '' and ", "..backpack or '')
                end
            end
     
            if founditemtext ~= '' then
                doItemSetAttribute(item.uid, 'text', founditemtext)
            else
                doItemEraseAttribute(item.uid, 'text')
            end
     
            if #bitems > 0 then
                local bitemtext = ""
                for bitem = 1, #bitems do
                    bitemtext = bitemtext..(bitem > 1 and (bitem == #bitems and " & " or ", ") or "")..bitems[bitem]
                end
                msgs = msgs..(msgs ~= '' and ', t' or 'T').."he following item"..(#bitems == 1 and " is" or "s are").." blocked \" "..bitemtext.." \""
            end
                           
            if #notfounditems > 0 then
                local wrongitemtext = ""
                for nitem = 1, #notfounditems do
                    wrongitemtext = wrongitemtext..(nitem > 1 and (nitem == #notfounditems and " & " or ", ") or "")..notfounditems[nitem]
                end
                msgs = msgs..(msgs ~= '' and ', t' or 'T')..'he following item'..(#notfounditems == 1 and ' doesn\'t' or 's don\'t')..' exist " '..wrongitemtext..' "'
            end
     
            if msgs ~= '' then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "["..string.upper(AUTOLOOTSYSTEMNAME).."]: "..msgs..".")
            end
            setPlayerStorageValue(cid, "AUTOLOOTD", os.time() + AUTOLOOTDELAY)
            return false
        end
        return true
    end

    autolootingkill.lua

    Código:

    function onKill(cid, target)
        if not isMonster(target) or isSummon(target) then
            return true
        end

        local v = getMonsterInfo(getCreatureName(target))
        if v and v.lookCorpse ~= 0 and #v.loot > 0 then
            addEvent(doSetAutoLootCorpseAid, 0, cid, getThingPos(target), v.lookCorpse)
        end
        return true
    end

    login.lua


    Código:

    registerCreatureEvent(cid, "AutoLooting")
    registerCreatureEvent(cid, "AutoLootingKill")

    creaturescripts.xml

    Código:

    <event type="textedit" name="AutoLooting" event="script" value="autolooting.lua"/>
    <event type="kill" name="AutoLootingKill" event="script" value="autolootingkill.lua"/>


    data/actions/scripts

    Código:

    function onUse(cid, item)
        if item.actionid == AUTOLOOTCORPSEAID and isCorpse(item.uid) then
            local corpseowner = getItemAttribute(item.uid, 'corpseowner')
            if (corpseowner and getPlayerByGUID(corpseowner) == cid) or not corpseowner then
                doPlayerAutoLoot(cid, item)
                if AUTOLOOTONLYONCE then --- once corpse is opened it can't be auto looted anymore
                    doItemEraseAttribute(item.uid, 'aid')
                end --- once corpse is opened it can't be auto looted anymore
            end
            return false
        end
        return true
    end

    actions.xml

    Código:

    <action actionid="87078" event="script" value="autolooting.lua"/>


    items.xml

    Código:

    <item id="1951" article="the" name="auto looting parchment">
      <attribute key="weight" value="200" />
      <attribute key="writeable" value="1" />
      <attribute key="maxTextLen" value="620" />
      <attribute key="description" value="Write items you want to auto loot followed by loot backpack, if loot backpack is not written you will loot to anywhere. (e.g., gold coin, yellow backpack)" />
    </item>

    [Pedido] autoloot system Autolo10



    [Pedido] autoloot system YNU5B25
    2 participantes
    http://www.tibiaface.com

    5[Pedido] autoloot system Empty Re: [Pedido] autoloot system Lun Ago 30, 2021 10:11 pm

    akane

    akane
    Miembro
    Miembro
    no sirvió, no recoge el loot pero tampoco me sale ningun error en la consola

    2 participantes

    6[Pedido] autoloot system Empty Re: [Pedido] autoloot system Lun Ago 30, 2021 11:07 pm

    [Admin] God Maya

    [Admin] God Maya
    Administrador
    Administrador
    ya veo el porque porque todo es cid y no player en la funcion pricipal



    [Pedido] autoloot system YNU5B25
    2 participantes
    http://www.tibiaface.com

    Contenido patrocinado


    2 participantes

    Ver el tema anterior Ver el tema siguiente Volver arriba  Mensaje (Página 1 de 1.)

    Permisos de este foro:
    No puedes responder a temas en este foro.

     

    BienvenidosTibiaFace es una comunidad de Open Tibia. Para participar debes estar registrado (click para Regístrate).