Ir para conteúdo
  • Cadastre-se

Posts Recomendados

Em 02/09/2020 em 15:48, Augusto disse:

Lua Script Error: [Main Interface] in a timer event called from: (Unknown scriptfile) data/creaturescripts/scripts/autoloot.lua:146: attempt to call global 'getPlayerTableStorage' (a nil value) stack traceback: [C]: in function 'getPlayerTableStorage' data/creaturescripts/scripts/autoloot.lua:146: in function

Esse erro eu consegui resolver dessa forma.

 

@Belmont

Estou com os seguintes erros.

[Error - CreatureScript Interface]
In a timer event called from:
data/creaturescripts/scripts/PH/autoloot.lua:onKill
Description:
data/creaturescripts/scripts/PH/autoloot.lua:134: attempt to call global 'getContainerItemsInfo' (a nil value)
stack traceback:
        data/creaturescripts/scripts/PH/autoloot.lua:134: in function <data/creaturescripts/scripts/PH/autoloot.lua:120>

[Error - CreatureScript Interface]
In a timer event called from:
data/creaturescripts/scripts/PH/autoloot.lua:onKill
Description:
data/creaturescripts/scripts/PH/autoloot.lua:147: attempt to call global 'countTable' (a nil value)
stack traceback:
        data/creaturescripts/scripts/PH/autoloot.lua:147: in function <data/creaturescripts/scripts/PH/autoloot.lua:144>

Consegui resolver os erros instalando a lib do killua.

o gold diz que recolhe, ele puxa do monstro mas não vai pra nenhuma bag..

os itens que eu adiciono não são pegos.
 

Editado por diarmaint (veja o histórico de edições)
Link para o post
Compartilhar em outros sites
  • Moderador

@Rogex Joyz Talvez esteja faltando fechar alguma coisa nos arquivos xml, tenta verificar se instalou tudo certo.

@diarmaint Coloca esse arquivo na pasta data/lib e ver se resolve: killua's lib.lua

@Augusto Talvez funcione nessa versão, o que está faltando são as funções serem instaladas, baixe esse arquivo e coloque-o na pasta data/lib e veja se resolve o problema: killua's lib.lua

@saiddias Se for TFS acho que não vai funcionar, tenta verificar isso, se vai funcionar

Tópico atualizado! Foi adicionado o arquivo para as Libs do script, tinha esquecido dela kk, sorry

Meu Curso sobre Programação para OTServer

Programando OTServer

 

Peça o seu script! Entre agora mesmo no grupo

Developing

 

Conteúdos:

 

Discord: Belmont#7352

Não esqueça do REP+ :)     

Link para o post
Compartilhar em outros sites

@Belmont fiz tudo correto, substitui a lib que vc postou pela que eu tinha antes.

ainda está como antes, aparece a mensagem que coletou o gold, eu vejo o sendo pego mas ele não vai pra lugar nenhum, e os itens que eu adiciono não aparece mensagem e nem são pegos. :/

Link para o post
Compartilhar em outros sites
  • Moderador
19 minutos atrás, diarmaint disse:

@Belmont fiz tudo correto, substitui a lib que vc postou pela que eu tinha antes.

ainda está como antes, aparece a mensagem que coletou o gold, eu vejo o sendo pego mas ele não vai pra lugar nenhum, e os itens que eu adiciono não aparece mensagem e nem são pegos. :/

O dinheiro não está indo para o banco? O erro ainda continua no terminal?

Meu Curso sobre Programação para OTServer

Programando OTServer

 

Peça o seu script! Entre agora mesmo no grupo

Developing

 

Conteúdos:

 

Discord: Belmont#7352

Não esqueça do REP+ :)     

Link para o post
Compartilhar em outros sites

@Belmont Nenhum erro no terminal. Somente o gold está recolhendo, está indo para o banco.. não sabia, mas de alguma forma está bugando..

Falo com o npc para retirar a quantia, ele me "entrega" não vem para o inventário, e no banco a quantia fica a mesma.

13:07 BankMan: Your balance are 210058 golds.
13:08 BankMan: Please tell me how much gold you would like to withdraw.
13:08 Diarmaint [100]: 10000
13:08 BankMan: Do you want withdraw 10000 golds ?
13:08 Diarmaint [100]: yes
13:08 BankMan: Here you are, 10000 gold. Now your balance account is 210058 golds.

Também não consigo depositar, ele dá a mensagem que depositou, mas o gold não sai do meu inventário.

13:14 Diarmaint [100]: deposit
13:14 BankMan: Please tell me how much gold it is you would like to deposit.
13:14 Diarmaint [100]: 50000
13:14 BankMan: Do you want deposit 50000 golds ?
13:14 Diarmaint [100]: yes
13:14 BankMan: Sucessfull. Now your balance account is 210058 golds.

 

Editado por diarmaint (veja o histórico de edições)
Link para o post
Compartilhar em outros sites
  • Moderador
23 minutos atrás, diarmaint disse:

@Belmont Nenhum erro no terminal. Somente o gold está recolhendo, está indo para o banco.. não sabia, mas de alguma forma está bugando..

Falo com o npc para retirar a quantia, ele me "entrega" não vem para o inventário, e no banco a quantia fica a mesma.


13:07 BankMan: Your balance are 210058 golds.
13:08 BankMan: Please tell me how much gold you would like to withdraw.
13:08 Diarmaint [100]: 10000
13:08 BankMan: Do you want withdraw 10000 golds ?
13:08 Diarmaint [100]: yes
13:08 BankMan: Here you are, 10000 gold. Now your balance account is 210058 golds.

Também não consigo depositar, ele dá a mensagem que depositou, mas o gold não sai do meu inventário.


13:14 Diarmaint [100]: deposit
13:14 BankMan: Please tell me how much gold it is you would like to deposit.
13:14 Diarmaint [100]: 50000
13:14 BankMan: Do you want deposit 50000 golds ?
13:14 Diarmaint [100]: yes
13:14 BankMan: Sucessfull. Now your balance account is 210058 golds.

 

Verifica se no seu config.lua já tem essa função registrada: bankSystem = true, se não tiver adicione. Caso isso não baste, tenta usar esse script do NPC Banker:

 

XML:

Spoiler

<?xml version="1.0" encoding="UTF-8"?>
<npc name="Banker" script="data/npc/scripts/bank.lua" walkinterval="2000" floorchange="0" access="5" level="1" maglevel="1">
    <health now="150" max="150"/>
    <look type="132" head="115" body="0" legs="114" feet="0" addons="3" corpse="2212"/>
    
    <parameters>
        <parameter key="message_greet" value="Welcome |PLAYERNAME|! Here, you can {deposit}, {withdraw} or {transfer} your money from your bank account. I can change your coins too."/>
        <parameter key="message_alreadyfocused" value="You are drunked ? I talk with you."/>
        <parameter key="message_farewell" value="Goodbye. I wanna see your money... oh you again."/>
    </parameters>
</npc>

.Lua:

Spoiler

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
local moneyTo = {}
local playerTo = {}

function onCreatureAppear(cid)            npcHandler:onCreatureAppear(cid)        end
function onCreatureDisappear(cid)        npcHandler:onCreatureDisappear(cid)        end
function onCreatureSay(cid, type, msg)        npcHandler:onCreatureSay(cid, type, msg)    end
function onThink()                npcHandler:onThink()                end

local function isValidMoney(money)
    if isNumber(money) == TRUE and money > 0 and money < 999999999 then
        return TRUE
    end
    return FALSE
end

function creatureSayCallback(cid, type, msg)

    if(not npcHandler:isFocused(cid)) then
        return false
    end

    if msgcontains(msg, 'help') or msgcontains(msg, 'offer') then
        selfSay("You can check the {balance} of your bank account, {deposit} money or {withdraw} it. You can also {transfer} money to other characters, provided that they have a vocation.", cid)
        talkState[cid] = 0
-----------------------------------------------------------------
---------------------------- Balance ----------------------------
-----------------------------------------------------------------
    elseif msgcontains(msg, 'balance') or msgcontains(msg, 'Balance') then
        selfSay('Your account balance is '..getPlayerBalance(cid)..' gold.', cid)
        talkState[cid] = 0
-----------------------------------------------------------------
---------------------------- Help -------------------------------
-----------------------------------------------------------------
    elseif msgcontains(msg, 'basic functions') then
        selfSay('You can check the {balance{ of your bank account, Pdeposit{ money or Pwithdraw{ it. You can also {transfer} money to othercharacters, provided that they have a vocation.', cid)
        talkState[cid] = 0
    elseif msgcontains(msg, 'advanced functions') then
        selfSay('Renting a house has never been this easy. Simply make a bid for an auction. We will check immediately if you haveenough money.', cid)
        talkState[cid] = 0
-----------------------------------------------------------------
---------------------------- Deposit ----------------------------
-----------------------------------------------------------------
    elseif msgcontains(msg, 'deposit all') then
        moneyTo[cid] = getPlayerMoney(cid)
        if moneyTo[cid] < 1 then
            selfSay('You don\'t have any money to deposit in you inventory..', cid)
            talkState[cid] = 0
        else
            selfSay('Would you really like to deposit '..moneyTo[cid]..' gold?', cid)
            talkState[cid] = 2
        end
    elseif msgcontains(msg, 'deposit') then
        selfSay("Please tell me how much gold it is you would like to deposit.", cid)
        talkState[cid] = 1
    elseif talkState[cid] == 1 then
        moneyTo[cid] = tonumber(msg)
        if isValidMoney(moneyTo[cid]) == TRUE then
            selfSay('Would you really like to deposit '..moneyTo[cid]..' gold?', cid)
            talkState[cid] = 2
        else
            selfSay('Is isnt valid amount of gold to deposit.', cid)
            talkState[cid] = 0
        end
    elseif talkState[cid] == 2 then
        if msgcontains(msg, 'yes') then
            if doPlayerDepositMoney(cid, moneyTo[cid], 1) ~= TRUE then
                selfSay('You do not have enough gold.', cid)
            else
                selfSay('Alright, we have added the amount of '..moneyTo[cid]..' gold to your balance. You can withdraw your money anytime you want to. Your account balance is ' .. getPlayerBalance(cid) .. '.', cid)
            end
        elseif msgcontains(msg, 'no') then
            selfSay('As you wish. Is there something else I can do for you?', cid)
        end
        talkState[cid] = 0
-----------------------------------------------------------------
---------------------------- Withdraw ---------------------------
-----------------------------------------------------------------
    elseif msgcontains(msg, 'withdraw') then
        selfSay("Please tell me how much gold you would like to withdraw.", cid)
        talkState[cid] = 6
    elseif talkState[cid] == 6 then
        moneyTo[cid] = tonumber(msg)
        if isValidMoney(moneyTo[cid]) == TRUE then
            selfSay('Are you sure you wish to withdraw '..moneyTo[cid]..' gold from your bank account?', cid)
            talkState[cid] = 7
        else
            selfSay('Is isnt valid amount of gold to withdraw.', cid)
            talkState[cid] = 0
        end
    elseif talkState[cid] == 7 then
        if msgcontains(msg, 'yes') then
            if doPlayerWithdrawMoney(cid, moneyTo[cid]) ~= TRUE then
                selfSay('There is not enough gold on your account. Your account balance is '..getPlayerBalance(cid)..'. Please tell me the amount of gold coins you would like to withdraw.', cid)
            else
                selfSay('Here you are, ' .. moneyTo[cid] .. ' gold. Please let me know if there is something else I can do for you.', cid)
                talkState[cid] = 0
            end
        elseif msgcontains(msg, 'no') then
            selfSay('As you wish. Is there something else I can do for you?', cid)
            talkState[cid] = 0
        end
-----------------------------------------------------------------
---------------------------- Transfer ---------------------------
-----------------------------------------------------------------
    elseif msgcontains(msg, 'transfer') then
        selfSay("Please tell me the amount of gold you would like to transfer.", cid)
        talkState[cid] = 11
    elseif talkState[cid] == 11 then
        moneyTo[cid] = tonumber(msg)
        if isValidMoney(moneyTo[cid]) == TRUE then
            selfSay('Who would you like transfer '..moneyTo[cid]..' gold to?', cid)
            talkState[cid] = 12
        else
            selfSay('Is isnt valid amount of gold to transfer.', cid)
            talkState[cid] = 0
        end
    elseif talkState[cid] == 12 then
        playerTo[cid] = msg

        if getCreatureName(cid) == playerTo[cid] then
            selfSay('Ehm, You want transfer money to yourself? Its impossible!', cid)
            talkState[cid] = 0
            return TRUE
        end

        if playerExists(playerTo[cid]) then
            selfSay('So you would like to transfer ' .. moneyTo[cid] .. ' gold to "' .. playerTo[cid] .. '" ?', cid)
            talkState[cid] = 13
        else
            selfSay('Player with name "' .. playerTo[cid] .. '" doesnt exist.', cid)
            talkState[cid] = 0
        end
    elseif talkState[cid] == 13 then
        if msgcontains(msg, 'yes') then
            if getPlayerBalance(cid) < moneyTo[cid] then
                selfSay('You dont have enought money on your bank account.', cid)
                return TRUE
            end

            if doPlayerTransferMoneyTo(cid, playerTo[cid], moneyTo[cid]) ~= TRUE then
                selfSay('This player does not exist on this world or have no vocation.', cid)
            else
                selfSay('You have transferred ' .. moneyTo[cid] .. ' gold to "' .. playerTo[cid] ..' ".', cid)
                playerTo[cid] = nil
            end
        elseif msgcontains(msg, 'no') then
            selfSay('As you wish. Is there something else I can do for you?', cid)
        end
        talkState[cid] = 0
    end
    return TRUE
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())  

 

Meu Curso sobre Programação para OTServer

Programando OTServer

 

Peça o seu script! Entre agora mesmo no grupo

Developing

 

Conteúdos:

 

Discord: Belmont#7352

Não esqueça do REP+ :)     

Link para o post
Compartilhar em outros sites

@Belmont Adicionei a função bankSystem no config agora o npc funciona corretamente, ao coletar o gold ele vai para o banco e consigo retirar tudo certo.

Mas o essencial ainda não funciona, que é a coleta de itens, não sei aonde está o problema, nenhum erro acontece, apenas não pega os itens.

estou usando o ntohard de teste, pensei que o problema poderia ser os monstros, pois  não dropar o corpo quando morrem e sim uma bag, mas a bag é corpse então não sei aonde está o erro.

Editado por diarmaint (veja o histórico de edições)
Link para o post
Compartilhar em outros sites
  • Moderador
1 hora atrás, diarmaint disse:

@Belmont Adicionei a função bankSystem no config agora o npc funciona corretamente, ao coletar o gold ele vai para o banco e consigo retirar tudo certo.

Mas o essencial ainda não funciona, que é a coleta de itens, não sei aonde está o problema, nenhum erro acontece, apenas não pega os itens.

estou usando o ntohard de teste, pensei que o problema poderia ser os monstros, pois  não dropar o corpo quando morrem e sim uma bag, mas a bag é corpse então não sei aonde está o erro

Vou verificar aqui, eu tenho a base dele também qualquer coisa se eu resolver eu te falo. Você está usando a source que foi disponibilizada junto com a base, ou está usando outra?

Meu Curso sobre Programação para OTServer

Programando OTServer

 

Peça o seu script! Entre agora mesmo no grupo

Developing

 

Conteúdos:

 

Discord: Belmont#7352

Não esqueça do REP+ :)     

Link para o post
Compartilhar em outros sites
Em 06/09/2020 em 06:40, Belmont disse:

@Rogex Joyz Talvez esteja faltando fechar alguma coisa nos arquivos xml, tenta verificar se instalou tudo certo.

@diarmaint Coloca esse arquivo na pasta data/lib e ver se resolve: killua's lib.lua

@Augusto Talvez funcione nessa versão, o que está faltando são as funções serem instaladas, baixe esse arquivo e coloque-o na pasta data/lib e veja se resolve o problema: killua's lib.lua

@saiddias Se for TFS acho que não vai funcionar, tenta verificar isso, se vai funcionar

Tópico atualizado! Foi adicionado o arquivo para as Libs do script, tinha esquecido dela kk, sorry

Tinha dado certo bro, eu tinha achado essas libs pela net, fui mexendo aqui e ali e funfou.

Até adicionei algumas coisas a mais no autoloot kkkk

 

loot.png

 

Somente as msg que não aparecem, tanto quando coleta gold/loot, mas mesmo assim está funcionando normal.

Ainda vou quebrar a cabeça pra ver se faço essas msg funcionar, mais do resto está OK!

Valeu bro!

# Regras Gerais - TibiaKing.com #
Contato: [email protected]
Não respondo dúvidas via MP.


1C2tu.png4Tlqo.png1C2tu.png


 

Link para o post
Compartilhar em outros sites
  • Moderador

@Augusto Que bom que deu certo ;)

Meu Curso sobre Programação para OTServer

Programando OTServer

 

Peça o seu script! Entre agora mesmo no grupo

Developing

 

Conteúdos:

 

Discord: Belmont#7352

Não esqueça do REP+ :)     

Link para o post
Compartilhar em outros sites
  • 5 months later...
Em 30/04/2020 em 16:14, Belmont disse:

E ai pessoal, vi que muitas pessoas tem problemas em instalar, e achar um script de autoloot 100% funcional. Foi ai que decidi postar aqui para vocês, um script totalmente novo e que realmente funciona, pronto para usar e abusar dele kkk. Bom, vamos parar de lero lero e bora ao que interessa.

 

Fixados:

Dinheiro Duplicado;

Coleta itens até mesmo dentro das bag dos monstros;

 

Lembrando que esse script NÃO é de minha autoria, e que já existe no Tk, mas em tópicos diferentes. Como eu uso ele já vou deixar tudo certo para o uso do mesmo.

 

1° Passo - Dentro da pasta data/actions/scripts crie um arquivo chamado autoloot_boost.lua

  Ocultar conteúdo

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getPlayerStorageValue(cid, 45000) >= os.time() then
        doPlayerSendCancel(cid,"Você já está com o BOOST ativado!")
        return true
    end
 
    if doRemoveItem(item.uid) then
        doPlayerSetStorageValue(cid, 45000, os.time() + 3600 * 24)
        doSendMagicEffect(getThingPos(cid),49)
        doPlayerSendTextMessage(cid,MESSAGE_STATUS_WARNING,"Você ativou o Auto Loot BOOST por mais 24 horas. Durante esse tempo os itens coletados serão vendidos automaticamente e o dinheiro será depositado no seu banco.")
    else
        doPlayerSendCancel(cid,"ERROR! Please contact the admnistrator.")
    end
    return true
end

Em data/actions/actions.xml registre o script assim:


<action itemid="ITEMID" event="script" value="autoloot_boost.lua"/>

 

2° Passo - Vá na pasta data/creaturescripts/script e crie dois arquivos, um chamado autoloot.lua e o outro fimautoloot.lua depois, adicione os seguintes códigos:

autoloot.lua

  Ocultar conteúdo

local aloot_boost = {[2406] = 36, [2537] = 4800, [2377] = 480, [2663] = 600, [2472] = 195000, [2398] = 36, [2475] = 7200, [2519] = 6500, [2497] = 10700, [2523] = 180000, [2494] = 325000, [2400] = 144000, [2491] = 6000, [2421] = 325000, [2646] = 260000, [2477] = 7200, [2413] = 84, [2656] = 18000, [2498] = 52000, [2647] = 600, [2534] = 32500, [7402] = 19500, [2466] = 26000, [2465] = 240, [2408] = 120000, [2518] = 1800, [2500] = 3000, [2376] = 30, [2470] = 91000, [2388] = 24, [2645] = 26000, [2434] = 2400, [2463] = 480, [2536] = 11700, [2387] = 240, [2396] = 4800, [2381] = 240, [2528] = 4800, [2409] = 1800, [2414] = 12000, [2427] = 9000, [2407] = 7200, [2458] = 42, [2383] = 960, [2392] = 3600, [2488] = 18000, [2525] = 120, [2423] = 240, [7382] = 13000, [2462] = 1300, [2520] = 39000, [2390] = 180000, [2417] = 72, [2436] = 1200, [5741] = 52000, [2378] = 120, [2487] = 24000, [2476] = 6500, [8891] = 36000, [2459] = 36, [2195] = 52000, [2391] = 7200, [2464] = 120, [8889] = 72000, [2432] = 13000, [2431] = 108000, [2492] = 52000, [2515] = 240, [2430] = 2400, [2393] = 13000, [7419] = 36000, [2522] = 130000, [2514] = 65000}

local function getPlayerStorageZero(cid, storage) -- By Killua
    local sto = getPlayerStorageValue(cid, storage)
    if tonumber(sto) then
        return tonumber(sto) > tonumber(0) and tonumber(sto) or tonumber(0)
    end
    return tonumber(0)
end

local tabela = {}

local function getPlayerList(cid)
    local tab = {}
    if getPlayerStorageValue(cid, 04420021) ~= -1 then
        table.insert(tab, getPlayerStorageValue(cid, 04420021))
    end
    if getPlayerStorageValue(cid, 04420031) ~= -1 then
        table.insert(tab, getPlayerStorageValue(cid, 04420031))
    end
    if getPlayerStorageValue(cid, 04420041) ~= -1 then
        table.insert(tab, getPlayerStorageValue(cid, 04420041))
    end
    if getPlayerStorageValue(cid, 04420051) ~= -1 then
        table.insert(tab, getPlayerStorageValue(cid, 04420051))
    end
    if #tab > 0 then
        return tab
    end
    return {}
end

local function boost(cid)
    return tonumber(getPlayerStorageValue(cid,45000)) >= os.time()
end

local function lootItemsFromContainer(cid, container)
    local description = ""
    if container then
        for index, info in pairs(container) do
            if isContainer(info.uid) then
                local childContainer = getContainerItemsInfo(info.uid)
                local childDescription = lootItemsFromContainer(cid, childContainer)
                description = description .. " " .. childDescription
            elseif isInArray(getPlayerList(cid), info.itemid) then
                if info.quant > 1 then
                    doRemoveItem(info.uid, info.quant)
                    doPlayerAddItem(cid, info.itemid, info.quant)
                    description = description.." "..info.quant.." "..getItemNameById(info.itemid).." +"
                else
                    doRemoveItem(info.uid)
                    if boost(cid) then
                        if aloot_boost[info.itemid] then
                            doPlayerSetBalance(cid,getPlayerBalance(cid) + aloot_boost[info.itemid])
                            description = description.." 1 "..getItemNameById(info.itemid).." ("..aloot_boost[info.itemid].."gps no banco) +"
                        else
                            doPlayerAddItem(cid, info.itemid, 1)
                            description = description.." 1 "..getItemNameById(info.itemid).." +"
                        end
                    else
                        doPlayerAddItem(cid, info.itemid, 1)
                        description = description.." 1 "..getItemNameById(info.itemid).." +"
                    end
                end
            end
        end
    end

    return description
end

local function autoLoot(cid, pos)
    if not isPlayer(cid) then return end
    local check = false
    local str = ""
    local position = {}
    for i = 1, 255 do
        pos.stackpos = i
        if getThingFromPos(pos).uid and getThingFromPos(pos).uid > 0 and isContainer(getThingFromPos(pos).uid) then
            position = pos
            check = true
            break
        end
    end
    if check then
        local corpse = getContainerItemsInfo(getThingFromPos(position).uid)
        str = lootItemsFromContainer(cid, corpse)
    end
    setPlayerTableStorage(cid,822564,{[1] = str, [2] = 0})
end

local function lootGoldFromContainer(cid, container)
    local total = 0
    if container then
        for index, info in pairs(container) do
            if isContainer(info.uid) then
                local childContainer = getContainerItemsInfo(info.uid)
                local childTotal = lootGoldFromContainer(cid, childContainer)
                total = total + childTotal
            elseif isInArray({2148, 2152, 2160}, info.itemid) then
                local multiplie = 1
                if info.itemid == 2148 then
                    multiplie = 1
                elseif info.itemid == 2152 then
                    multiplie = 100
                elseif info.itemid == 2160 then
                    multiplie = 10000
                end
                doRemoveItem(info.uid, info.quant)
                doPlayerSetBalance(cid, getPlayerBalance(cid) + info.quant * multiplie)
                doPlayerSetStorageValue(cid, 04421021, tonumber(getPlayerStorageZero(cid, 04421021)) + tonumber(info.quant) * tonumber(multiplie))
                total = total + info.quant * multiplie
            end
        end
    end

    return total
end

local function autoGold(cid, pos)
    if not isPlayer(cid) then return end
    local check = false
    local total = 0
    local position = {}
    for i = 1, 255 do
        pos.stackpos = i
        if getThingFromPos(pos).uid and getThingFromPos(pos).uid > 0 and isContainer(getThingFromPos(pos).uid) then
            position = pos
            check = true
            break
        end
    end
    if check then
        local corpse = getContainerItemsInfo(getThingFromPos(position).uid)
        total = lootGoldFromContainer(cid, corpse)
    end
    if total > 0 then
        local tab = getPlayerTableStorage(cid,822564)
        tab[2] = total
        setPlayerTableStorage(cid,822564,tab)
    end
end

local function sendMsg(cid)
    if not isPlayer(cid) then return end
    local tab = getPlayerTableStorage(cid,822564)
    if countTable(tab) >= 1 then
        if tab[1] then
            if tab[2] and tab[2] > 0 then
                doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "[Auto Loot System] Coletados: ".. tab[1] .." ".. tab[2] .." gold coins.")
            else
                if type(tab[1]) == "string" and string.len(tab[1]) > 1 then
                    doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "[Auto Loot System] Coletados: "..tab[1])
                end
            end
        elseif not tab[1] then
            if tab[2] then
                doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "[Auto Loot System] Coletados: "..tab[2].." gold coins.")
            end
        end
    end
    doPlayerSetStorageValue(cid,822564,-1)
end

function onKill(cid, target, lastHit)
    if isPlayer(cid) and isMonster(target) then
        if getPlayerStorageValue(cid, 04421001) == 1 and #getPlayerList(cid) > 0 then
            local pos = getCreaturePosition(target)
            addEvent(autoLoot, 500, cid, pos)
        end
        if getPlayerStorageValue(cid, 04421011) == 1 then
            local pos = getCreaturePosition(target)
            addEvent(autoGold, 540, cid, pos)
        end
        if getPlayerStorageValue(cid, 04421001) == 1 or getPlayerStorageValue(cid, 04421011) == 1 then
            addEvent(sendMsg, 560, cid)
        end
    end
    return true
end

fimautoloot.lua

  Mostrar conteúdo oculto

function onLogin(cid)
    if not isPremium(cid) then
        local active_slots = getPlayerStorageValue(cid, 04420011)
        if active_slots >= 1 then
            for i = 1, active_slots do
                doPlayerSetStorageValue(cid, (04420031 + (i * 10)), -1)
                doPlayerSetStorageValue(cid, 04420011, active_slots - 1)
            end
        end
    end
    return true
end

Agora em data/creaturescripts/creaturescripts.xml você vai registrar esses scripts dessa forma:


<event type="kill" name="autoloot" event="script" value="autoloot.lua"/>
<event type="login" name="fimautoloot" event="script" value="fimautoloot.lua"/>

Abra o arquivo login.lua localizado na mesma pasta e adicione este código abaixo de outro registerCreatureEvent


registerCreatureEvent(cid, "autoloot")

 

Depois de instalar tudo, vamos para a pasta data/talkactions/script nela você irá criar um arquivo chamado autoloot.lua e vai adicionar este código:

  Mostrar conteúdo oculto

function ExistItemByName(name) -- by vodka
    local items = io.open("data/items/items.xml", "r"):read("*all")
    local get = items:match('name="' .. name ..'"')
    if get == nil or get == "" then
        return false
    end
    return true
end

local function getPlayerList(cid)
    local tab = {}
    if getPlayerStorageValue(cid, 04420021) ~= -1 then
        table.insert(tab, getPlayerStorageValue(cid, 04420021))
    end
    if getPlayerStorageValue(cid, 04420031) ~= -1 then
        table.insert(tab, getPlayerStorageValue(cid, 04420031))
    end
    if getPlayerStorageValue(cid, 04420041) ~= -1 then
        table.insert(tab, getPlayerStorageValue(cid, 04420041))
    end
    if getPlayerStorageValue(cid, 04420051) ~= -1 then
        table.insert(tab, getPlayerStorageValue(cid, 04420051))
    end
    if #tab > 0 then
        return tab
    end
    return false
end

local function addToList(cid, name)
    local itemid = getItemIdByName(name)
    if getPlayerList(cid) and isInArray(getPlayerList(cid), itemid) then
        return false
    end
    if getPlayerStorageValue(cid, 04420021) == -1 then
        return doPlayerSetStorageValue(cid, 04420021, itemid)
    elseif getPlayerStorageValue(cid, 04420031) == -1 then
        return doPlayerSetStorageValue(cid, 04420031, itemid)
    elseif getPlayerStorageValue(cid, 04420041) == -1 then    
        return doPlayerSetStorageValue(cid, 04420041, itemid)
    elseif getPlayerStorageValue(cid, 04420051) == -1 then
        return doPlayerSetStorageValue(cid, 04420051, itemid)
    end
end

local function removeFromList(cid, name)
    local itemid = getItemIdByName(name)
    if getPlayerStorageValue(cid, 04420021) == itemid then
        return doPlayerSetStorageValue(cid, 04420021, -1)
    elseif getPlayerStorageValue(cid, 04420031) == itemid then
        return doPlayerSetStorageValue(cid, 04420031, -1)
    elseif getPlayerStorageValue(cid, 04420041) == itemid then
        return doPlayerSetStorageValue(cid, 04420041, -1)
    elseif getPlayerStorageValue(cid, 04420051) == itemid then
        return doPlayerSetStorageValue(cid, 04420051, -1)
    end
    return false
end

function onSay(cid, words, param)
    if param == "" then
        local fi = getPlayerStorageValue(cid, 04420021) ~= -1 and getItemNameById(getPlayerStorageValue(cid, 04420021)) or ""
        local se = getPlayerStorageValue(cid, 04420031) ~= -1 and getItemNameById(getPlayerStorageValue(cid, 04420031)) or ""
        local th = not isPremium(cid) and "Não disponível para free account" or getPlayerStorageValue(cid, 04420041) ~= -1 and getItemNameById(getPlayerStorageValue(cid, 04420041)) or ""
        local fo = not isPremium(cid) and "Não disponível para free account" or getPlayerStorageValue(cid, 04420051) ~= -1 and getItemNameById(getPlayerStorageValue(cid, 04420051)) or ""
        local stt = getPlayerStorageValue(cid, 04421011) == 1 and "sim" or "não"
        local str = getPlayerStorageValue(cid, 04421001) == 1 and "sim" or "não"
        doPlayerPopupFYI(cid, "                                                          <--- Informações Do Auto Loot --->\n{Auto-Loot} ---Coletar dinheiro,  Ligado? ("..stt.."). Para ligar ou desligar, digite: !autoloot gold \n{Auto-Loot} ---Coletar itens, Ligado? ("..str.."). Para ligar ou desligar, digite: !autoloot power\n\n{Auto-Loot} --Configuração Dos Slots:\n{Auto-Loot} ---Slot 1: "..fi.."\n{Auto-Loot} ---Slot 2: "..se.."\n{Auto-Loot} ---Slot 3: "..th.."\n{Auto-Loot} ---Slot 4: "..fo.."\n\n{Auto-Loot} ---Para adicionar um novo item no autoloot, digite: !autoloot add, <nome do item>\n{Auto-Loot} ---Para retirar um item do autoloot, digite: !autoloot remove, <nome do item>\n{Auto-Loot} ---Para limpar todos os slots, digite: !autoloot clear\n{Auto-Loot} ---Para informações de quanto você já fez utilizando a coleta de dinheiro, use: !autoloot goldinfo\n\nSe seu autoloot bugar use !autoloot desbug.")
        return true
    end
    
    local t = string.explode(param, ",")
    
    if t[1] == "power" then
        local check = getPlayerStorageValue(cid, 04421001) == -1 and "ligou" or "desligou"
        doPlayerSetStorageValue(cid, 04421001, getPlayerStorageValue(cid, 04421001) == -1 and 1 or -1)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Você "..check.." o auto loot.")
    elseif t[1] == "gold" then
        local check = getPlayerStorageValue(cid, 04421011) == -1 and "ligou" or "desligou"
        doPlayerSetStorageValue(cid, 04421011, getPlayerStorageValue(cid, 04421011) == -1 and 1 or -1)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Você "..check.." a coleta de dinheiro.")
        doPlayerSetStorageValue(cid, 04421021, 0)
    elseif t[1] == "goldinfo" then
        local str = getPlayerStorageValue(cid, 04421011) == -1 and "O sistema de coleta de dinheiro está desligado" or "O sistema já coletou "..getPlayerStorageZero(cid, 04421021).." gold coins"
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, str)
    elseif t[1] == "add" then
        if ExistItemByName(t[2]) then
            local item = getItemIdByName(t[2])
            if isInArray({2160, 2148, 2152, 2157, 9971}, item) then
                return doPlayerSendCancel(cid, "Você não pode adicionar moedas no autoloot. Para coletar dinheiro use !autoloot gold")
            end
            if isPremium(cid) then
                if getPlayerStorageValue(cid, 04420011) < 1 then
                    if addToList(cid, t[2]) then
                        doPlayerSetStorageValue(cid, 04420011, getPlayerStorageValue(cid, 04420011) + 1)
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, t[2].." adicionado à sua lista do auto loot! Para ver sua lista diga !autoloot list")
                    else
                        doPlayerSendCancel(cid, t[2].." já está em sua lista!")
                    end
                else
                    doPlayerSendCancel(cid, "Sua lista já tem 3 itens! Você deve remover algum antes de adicionar outro.")
                end
            else
                if getPlayerStorageValue(cid, 04420011) < 1 then
                    if addToList(cid, t[2]) then
                        doPlayerSetStorageValue(cid, 04420011, getPlayerStorageValue(cid, 04420011) + 1)
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, t[2].." adicionado à sua lista do auto loot! Para ver sua lista diga !autoloot")
                    else
                        doPlayerSendCancel(cid, t[2].." já está em sua lista!")
                    end
                else
                    doPlayerSendCancel(cid, "Sua lista já tem 2 itens! Você deve remover algum antes de adicionar outro.")
                end
            end
        else
            doPlayerSendCancel(cid, "Este item não existe!")
        end
    elseif t[1] == "remove" then
        if ExistItemByName(t[2]) then
            if removeFromList(cid, t[2]) then
                doPlayerSetStorageValue(cid, 04420011, getPlayerStorageValue(cid, 04420011) - 1)
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, t[2].." removido da sua lista do auto loot!")
            else
                doPlayerSendCancel(cid, "Este item não está na sua lista!")
            end
        else
            doPlayerSendCancel(cid, "Este item não existe!")
        end
    elseif t[1] == "clear" then
        if getPlayerStorageValue(cid, 04420011) > -1 then
            doPlayerSetStorageValue(cid, 04420011, -1)
            doPlayerSetStorageValue(cid, 04420021, -1)
            doPlayerSetStorageValue(cid, 04420031, -1)
            doPlayerSetStorageValue(cid, 04420041, -1)
            doPlayerSetStorageValue(cid, 04420051, -1)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Lista limpa!")
        else
            doPlayerSendCancel(cid, "Sua lista ja esta limpa!")
        end
    elseif t[1] == "desbug" or t[1] == "desbugar" then
        doPlayerSetStorageValue(cid, 04420011, -1)
        doPlayerSetStorageValue(cid, 04420021, -1)
        doPlayerSetStorageValue(cid, 04420031, -1)
        doPlayerSetStorageValue(cid, 04420041, -1)
        doPlayerSetStorageValue(cid, 04420051, -1)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Desbugado!")
    elseif t[1] == "list" then
        local fi = getPlayerStorageValue(cid, 04420021) ~= -1 and ""..getItemNameById(getPlayerStorageValue(cid, 04420021)).."\n" or ""
        local se = getPlayerStorageValue(cid, 04420031) ~= -1 and ""..getItemNameById(getPlayerStorageValue(cid, 04420031)).."\n" or ""
        local th = getPlayerStorageValue(cid, 04420041) ~= -1 and ""..getItemNameById(getPlayerStorageValue(cid, 04420041)).."\n" or ""
        local fo = getPlayerStorageValue(cid, 04420051) ~= -1 and ""..getItemNameById(getPlayerStorageValue(cid, 04420051)).."\n" or ""
        doPlayerPopupFYI(cid, "O sistema auto loot está coletando:\n "..fi..""..se..""..th..""..fo)
    end
    if(not checkExhausted(cid, 6667, 5)) then
        return true
    end        
    return true
end

Em data/talkactions/talkcations.xml resgistra o script assim:


<talkaction words="!autoloot" event="script" value="autoloot.lua"/>

 

Vá na pasta lib, e crie um arquivo chamado autoloot, e cole isso dentro:

  Ocultar conteúdo

--[[
    Auto Loot System by Danyel Varejão
]]

AutoLoot = {
    Min_Level = 100, -- Level minimo pra utilizar o auto loot.
    Max_Slots = 5, -- Máximo de slots permitidos.
    Boost_Actived = true,
    
    -- Nao mexa daqui pra baixo caso nao entenda --
    Storage_Boost = 45000,
    Storage_On_Items = 45001,
    Storage_On_Gold = 45002,
    Storages = {
        Count_Gold = 45003,
        Count_Items = 45004,
        Count_Table = 45005,
        Slots = {45006, 45007, 45008, 45009, 45010} -- Storage pra cada slot.
    }
}

AutoLoot_Boost = {
    -- [ID do item] = Valor,
    [2406] = 36,
    [2537] = 4800,
    [2377] = 480,
    [2663] = 600,
    [2472] = 240000,
    [2398] = 36,
    [2475] = 7200,
    [2519] = 6000,
    [2497] = 10800,
    [2523] = 180000,
    [2494] = 108000,
    [2400] = 144000,
    [2491] = 6000,
    [2421] = 108000,
    [2646] = 240000,
    [2477] = 7200,
    [2413] = 84,
    [2656] = 18000,
    [2498] = 48000,
    [2647] = 600,
    [2534] = 30000,
    [7402] = 24000,
    [2466] = 36000,
    [2465] = 240,
    [2408] = 120000,
    [2518] = 1800,
    [2500] = 3000,
    [2376] = 30,
    [2470] = 96000,
    [2388] = 24,
    [2645] = 48000,
    [2434] = 2400,
    [2463] = 480,
    [2536] = 9600,
    [2387] = 240,
    [2396] = 4800,
    [2381] = 240,
    [2528] = 4800,
    [2409] = 1800,
    [2414] = 12000,
    [2427] = 9000,
    [2407] = 7200,
    [2458] = 42,
    [2383] = 960,
    [2392] = 3600,
    [2488] = 18000,
    [2525] = 120,
    [2423] = 240,
    [2462] = 4800,
    [2520] = 48000,
    [2390] = 180000,
    [2417] = 72,
    [2436] = 1200,
    [5741] = 42000,
    [2378] = 120,
    [2487] = 24000,
    [2476] = 6000,
    [8891] = 36000,
    [2459] = 36,
    [2195] = 48000,
    [2391] = 7200,
    [2464] = 120,
    [8889] = 72000,
    [2432] = 12000,
    [2431] = 108000,
    [2492] = 72000,
    [2515] = 240,
    [2430] = 2400,
    [2393] = 12000,
    [7419] = 36000,
    [2522] = 120000,
    [2514] = 180000
}

function AutoLoot.CountTable(table)
    local Count = 0
    if type(table) == "table" then
        for index in pairs(table) do
            Count = Count + 1
        end
        return Count
    end
    return false
end

function AutoLoot.getContainerItemsInfo(ContainerUID)
    local Table = {}
    if ContainerUID and ContainerUID > 0 then
        local Index = 0   
        for i = 0, getContainerSize(ContainerUID) - 1 do
            local item = getContainerItem(ContainerUID, i)
            Index = Index + 1
            Table[Index] = {UID = item.uid, ItemID = item.itemid, Count = item.type}
        end
        return Table
    end
    return false
end

function AutoLoot.String(String)
    local Table = {}
    local x, old, last = 0, 0, 0
    local first, second, final = 0, 0, 0
    if type(String) ~= "string" then
        return Table
    end
    for i = 2, #String - 1 do
        if string.byte(String:sub(i,i)) == string.byte(':') then
            x, second, last = x + 1, i - 1, i + 2
            for t = last, #String - 1 do
                if string.byte(String:sub(t,t)) == string.byte(',') then
                    first = x == 1 and 2 or old
                    old, final = t + 2, t - 1
                    local Index = String:sub(first, second)
                    local Var = String:sub(last, final)
                    Table[tonumber(Index) or tostring(Index)] = tonumber(Var) or tostring(Var)
                    break
                end
            end
        end
    end
    return Table
end

function AutoLoot.TranslateString(Table)
    local String = ""
    if type(Table) ~= "table" then
        return String
    end
    for i, last in pairs(Table) do
        String = String..i..": ".. last ..", "
    end
    String = "a"..String.."a"
    return tostring(String)
end

function AutoLoot.getPlayerStorageZero(cid, key)
    return getPlayerStorageValue(cid, key) > 0 and getPlayerStorageValue(cid, key) or 0
end

function AutoLoot.getStorageZero(key)
    return getGlobalStorageValue(key) > 0 and getGlobalStorageValue(key) or 0
end

function AutoLoot.setPlayerTableStorage(cid, key, value)
    return doPlayerSetStorageValue(cid, key, AutoLoot.TranslateString(value))
end

function AutoLoot.setGlobalTableStorage(key, value)
    return setGlobalStorageValue(key, AutoLoot.TranslateString(value))
end

function AutoLoot.getPlayerTableStorage(cid, key)
    return AutoLoot.String(getPlayerStorageValue(cid, key))
end

function AutoLoot.getGlobalTableStorage(key)
    return AutoLoot.String(getGlobalStorageValue(key))
end

function AutoLoot.getPlayerList(cid)
    local Table = {}
    for i = 1, #AutoLoot.Storages.Slots do
        if getPlayerStorageValue(cid, AutoLoot.Storages.Slots) ~= -1 then
            table.insert(Table, getPlayerStorageValue(cid, AutoLoot.Storages.Slots))
        end
    end
    return Table
end

function AutoLoot.ExistItemByName(name)
    local Items = io.open("data/items/items.xml", "r"):read("*all")
    local GetITEM = Items:match('name="' .. name ..'"')
    if GetITEM == nil or GetITEM == "" then
        return false
    end
    return true
end

function AutoLoot.addToList(cid, name)
    local ItemID = getItemIdByName(name)
    if AutoLoot.getPlayerList(cid) and isInArray(AutoLoot.getPlayerList(cid), ItemID) then
        return false
    end
    for i = 1, #AutoLoot.Storages.Slots do
        if getPlayerStorageValue(cid, AutoLoot.Storages.Slots) == -1 then
            doPlayerSetStorageValue(cid, AutoLoot.Storages.Slots, ItemID)
            return true
        end
    end
end

function AutoLoot.removeFromList(cid, name)
    local ItemID = getItemIdByName(name)
    for i = 1, #AutoLoot.Storages.Slots do
        if getPlayerStorageValue(cid, AutoLoot.Storages.Slots) == ItemID then
            doPlayerSetStorageValue(cid, AutoLoot.Storages.Slots, -1)
            return true
        end
    end
    return false
end

function AutoLoot.Boost(cid)
    return tonumber(getPlayerStorageValue(cid, AutoLoot.Storage_Boost)) >= os.time()
end

function AutoLoot.Items(cid, position)
    if not isPlayer(cid) then
        return true
    end
    local Check, String, Position = false, "", {}
    for i = 1, 255 do
        position.stackpos = i
        if getThingFromPos(position).uid and getThingFromPos(position).uid > 0 and isContainer(getThingFromPos(position).uid) then
            Position = position
            Check = true
            break
        end
    end
    if Check then
        local CorpseUID = AutoLoot.getContainerItemsInfo(getThingFromPos(Position).uid)        
        if CorpseUID then
            for Index, Item in pairs(CorpseUID) do
                if Index < AutoLoot.CountTable(CorpseUID) then
                    if Item.UID and Item.ItemID then
                        if isContainer(Item.UID) then
                            local Bag = AutoLoot.getContainerItemsInfo(Item.UID)
                            for i = 1, AutoLoot.CountTable(Bag) do
                                if isInArray(AutoLoot.getPlayerList(cid), Bag.ItemID) then
                                    if Bag.Count > 1 then
                                        if Bag.uid and Bag.uid > 0 then
                                            doRemoveItem(Bag.uid, Bag.Count)
                                        end
                                        doPlayerAddItem(cid, Bag.ItemID, Bag.Count)
                                        String = String.." ".. Bag.Count .." ".. getItemNameById(Bag.ItemID) .." +"
                                    else
                                        if Bag.uid and Bag.uid > 0 then
                                            doRemoveItem(Bag.uid)
                                        end
                                        if AutoLoot.Boost_Actived and AutoLoot.Boost(cid) then
                                            if AutoLoot_Boost[Bag.ItemID] then
                                                doPlayerSetBalance(cid, getPlayerBalance(cid) + AutoLoot_Boost[Bag.ItemID])
                                                String = String.." 1 ".. getItemNameById(Bag.ItemID) .." (".. AutoLoot_Boost[Bag.ItemID] .."gp no banco) +"
                                            else
                                                doPlayerAddItem(cid, Bag.ItemID, 1)
                                                String = String.." 1 ".. getItemNameById(Bag.ItemID) .." +"
                                            end
                                        else
                                            doPlayerAddItem(cid, Bag.ItemID, 1)
                                            String = String.." 1 ".. getItemNameById(Bag.ItemID) .." +"
                                        end
                                    end
                                end
                            end
                        end
                    end
                end
                if isInArray(AutoLoot.getPlayerList(cid), Item.ItemID) then
                    if Item.Count > 1 then
                        if Item.UID and Item.UID > 0 then
                            doRemoveItem(Item.UID, Item.Count)
                        end
                        doPlayerAddItem(cid, Item.ItemID, Item.Count)
                        String = String.." ".. Item.Count .." ".. getItemNameById(Item.ItemID) .." +"
                    else
                        if Item.UID and Item.UID > 0 then
                            doRemoveItem(Item.UID)
                        end
                        if AutoLoot.Boost_Actived and AutoLoot.Boost(cid) then
                            if AutoLoot_Boost[Item.ItemID] then
                                doPlayerSetBalance(cid,getPlayerBalance(cid) + AutoLoot_Boost[Item.ItemID])
                                String = String.." 1 "..getItemNameById(Item.ItemID).." ("..AutoLoot_Boost[Item.ItemID].."gps no banco) +"
                            else
                                doPlayerAddItem(cid, Item.ItemID, 1)
                                String = String.." 1 "..getItemNameById(Item.ItemID).." +"
                            end
                        else
                            doPlayerAddItem(cid, Item.ItemID, 1)
                            String = String.." 1 "..getItemNameById(Item.ItemID).." +"
                        end
                    end
                end
            end
        end
    end
    AutoLoot.setPlayerTableStorage(cid, AutoLoot.Storages.Count_Table, {[1] = String, [2] = 0})
end

function AutoLoot.Gold(cid, position)
    if not isPlayer(cid) then
        return true
    end
    local Check = false
    local Total_Gold = 0
    local Position = {}
    for i = 1, 255 do
        position.stackpos = i
        if getThingFromPos(position).uid and getThingFromPos(position).uid > 0 and isContainer(getThingFromPos(position).uid) then
            Position = position
            Check = true
            break
        end
    end
    if Check then
        local CorpseUID = AutoLoot.getContainerItemsInfo(getThingFromPos(Position).uid)
        if CorpseUID then
            for Index, Item in pairs(CorpseUID) do
                if Item.UID and Item.ItemID then
                    if Index < AutoLoot.CountTable(CorpseUID) then
                        if isContainer(Item.UID) then
                            local Bag = AutoLoot.getContainerItemsInfo(Item.UID)
                            for i = 1, AutoLoot.CountTable(Bag) do
                                if isInArray({2148, 2152, 2160}, Bag.ItemID) then
                                    local Multiplier = 1
                                    if Bag.ItemID == 2148 then
                                        Multiplier = 1
                                    elseif Bag.ItemID == 2152 then
                                        Multiplier = 100
                                    elseif Bag.ItemID == 2160 then
                                        Multiplier = 10000
                                    end
                                    if Bag.uid and Bag.uid > 0 then
                                        doRemoveItem(Bag.uid, Bag.Count)
                                    end
                                    doPlayerSetBalance(cid, getPlayerBalance(cid) + tonumber(Bag.Count) * Multiplier)
                                    Total_Gold = Total_Gold + Bag.Count * Multiplier
                                    doPlayerSetStorageValue(cid, AutoLoot.Storages.Count_Gold, tonumber(AutoLoot.getPlayerStorageZero(cid, AutoLoot.Storages.Count_Gold)) + tonumber(Item.Count) * tonumber(Multiplier))
                                end
                            end
                        end
                    end
                    if isInArray({2148, 2152, 2160}, Item.ItemID) then
                        local Multiplier = 1
                        if Item.ItemID == 2148 then
                            Multiplier = 1
                        elseif Item.ItemID == 2152 then
                            Multiplier = 100
                        elseif Item.ItemID == 2160 then
                            Multiplier = 10000
                        end
                        if Item.UID and Item.UID > 0 then
                            doRemoveItem(Item.UID, Item.Count)
                        end
                        doPlayerSetBalance(cid, getPlayerBalance(cid) + Item.Count * Multiplier)
                        doPlayerSetStorageValue(cid, AutoLoot.Storages.Count_Gold, tonumber(AutoLoot.getPlayerStorageZero(cid, AutoLoot.Storages.Count_Gold)) + tonumber(Item.Count) * tonumber(Multiplier))
                        Total_Gold = Total_Gold + Item.Count * Multiplier
                    end
                end
            end
        end
    end
    if Total_Gold > 0 then
        Total_Gold = Total_Gold - (Total_Gold * 0.2)
        Total_Gold = math.ceil(Total_Gold)
        doPlayerSetBalance(cid, getPlayerBalance(cid) + Total_Gold)
        local Table = AutoLoot.getPlayerTableStorage(cid, AutoLoot.Storages.Count_Table)
        Table[2] = Total_Gold
        AutoLoot.setPlayerTableStorage(cid, AutoLoot.Storages.Count_Table, Table)
    end
end

function AutoLoot.Message(cid)
    if not isPlayer(cid) then
        return true
    end
    local Table = AutoLoot.getPlayerTableStorage(cid, AutoLoot.Storages.Count_Table)
    if AutoLoot.CountTable(Table) >= 1 then
        if Table[1] then
            if Table[2] and Table[2] > 0 then
                doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "[Auto Loot System] Coletados: ".. Table[1] .." ".. Table[2] .." gold coins.")
            else
                if type(Table[1]) == "string" and string.len(Table[1]) > 1 then
                    doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "[Auto Loot System] Coletados: "..Table[1])
                end
            end
        elseif not Table[1] then
            if Table[2] then
                doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "[Auto Loot System] Coletados: "..Table[2].." gold coins.")
            end
        end
    end
    doPlayerSetStorageValue(cid, AutoLoot.Storages.Count_Table, -1)
end

 

Ainda na pasta lib crie um arquivo .lua e coloque esse script dentro, ou faça o download do mesmo logo abaixo:

  Mostrar conteúdo oculto

-- lib and functions by Vitor Bertolucci (Killua)

function warnPlayersWithStorage(storage, value, class, message) -- By Killua
    if not value then value = 1 end
    if not class then class = MESSAGE_SATUS_CONSOLE_WARNING end
    if not storage or not message then return end
    if #getPlayersOnline() == 0 then
        return
    end
    for _, pid in pairs(getPlayersOnline()) do
        if getPlayerStorageValue(pid, storage) == value then
            doPlayerSendTextMessage(pid, class, message)
        end
    if getPlayerAccess(pid) >= 4 then    
        doPlayerSendTextMessage(pid, class, "Message to those with storage "..storage..message) -- Gms will always receive the messages
    end
    end
end

function getPlayerStorageZero(cid, storage) -- By Killua
    local sto = getPlayerStorageValue(cid, storage)
    return sto > 0 and sto or 0
end

function getStorageZero(storage) -- By Killua
    local sto = getGlobalStorageValue(storage)
    return sto > 0 and sto or 0
end

function countTable(table) -- By Killua
    local y = 0
    if type(table) == "table" then
        for _ in pairs(table) do
            y = y + 1
        end
        return y
    end
    return false
end

function getPlayersInArea(frompos, topos) -- By Killua
    local players_ = {}
    local count = 1
    for _, pid in pairs(getPlayersOnline()) do
        if isInArea(getCreaturePosition(pid), frompos, topos) then
            players_[count] = pid
            count = count + 1
        end
    end
    return countTable(players_) > 0 and players_ or false
end

function getGuildNameById(gid) -- By Killua
    local query = db.getResult("SELECT `name` FROM `guilds` WHERE `id` = '"..gid.."'")
    if query:getID() == -1 then
        return ""
    end
    local name = query:getDataString("name")
    query:free()
    return name
end

function getContainerItemsInfo(containerUid) -- By Killua
    local table = {}
    if containerUid and containerUid > 0 then
        local a = 0   
        for i = 0, getContainerSize(containerUid) - 1 do
            local item = getContainerItem(containerUid,i)
            a = a + 1
            table[a] = {uid = item.uid, itemid = item.itemid, quant = item.type}
        end
        return table
    end
    return false
end

function getTableEqualValues(table) -- By Killua
    local ck = {}
    local eq = {}
    if type(table) == "table" then
          if countTable(table) and countTable(table) > 0 then
               for i = 1, countTable(table) do
                 if not isInArray(ck, table) then
                    ck = table
                else
                    eq = table
                end
            end
            return countTable(eq) > 0 and eq or 0
        end
    end
    return false
end

function killuaGetItemLevel(uid) -- By Killua
    local name = getItemName(uid)
    local pos = 0
    for i = 1, #name do
        if string.byte(name:sub(i,i)) == string.byte('+') then
            pos = i + 1
            break
        end
    end
    return tonumber(name:sub(pos,pos))
end

k_table_storage_lib = {
    filtrateString = function(str) -- By Killua
        local tb, x, old, last = {}, 0, 0, 0
        local first, second, final = 0, 0, 0
        if type(str) ~= "string" then
            return tb
        end
        for i = 2, #str-1 do
            if string.byte(str:sub(i,i)) == string.byte(':') then
                x, second, last = x+1, i-1, i+2
                for t = last,#str-1 do
                    if string.byte(str:sub(t,t)) == string.byte(',') then
                        first = x == 1 and 2 or old
                        old, final = t+2, t-1
                        local index, var = str:sub(first,second), str:sub(last,final)
                        tb[tonumber(index) or tostring(index)] = tonumber(var) or tostring(var)
                        break
                    end
                end
            end
        end
        return tb
    end,

    translateIntoString = function(tb) -- By Killua
        local str = ""
        if type(tb) ~= "table" then
            return str
        end
        for i, t in pairs(tb) do
            str = str..i..": "..t..", "
        end
        str = "a"..str.."a"
        return tostring(str)
    end
}

function setPlayerTableStorage(cid, key, value) -- By Killua
    return doPlayerSetStorageValue(cid, key, k_table_storage_lib.translateIntoString(value))
end

function getPlayerTableStorage(cid, key) -- By Killua
    return k_table_storage_lib.filtrateString(getPlayerStorageValue(cid, key))
end

function setGlobalTableStorage(key, value) -- By Killua
    return setGlobalStorageValue(key, k_table_storage_lib.translateIntoString(value))
end

function getGlobalTableStorage(key) -- By Killua
    return k_table_storage_lib.filtrateString(getGlobalStorageValue(key))
end

function printTable(table, includeIndices,prnt) -- By Killua
    if includeIndices == nil then includeIndices = true end
    if prnt == nil then prnt = true end
    if type(table) ~= "table" then
        error("Argument must be a table")
        return
    end
    local str, c = "{", ""
    for v, b in pairs(table) do
        if type(b) == "table" then
            str = includeIndices and str..c.."["..v.."]".." = "..printTable(b,true,false) or str..c..printTable(b,false,false)
        else
            str = includeIndices and str..c.."["..v.."]".." = "..b or str..c..b
        end
        c = ", "
    end
    str = str.."}"
    if prnt then print(str) end
    return str
 end
 
function checkString(str) -- By Killua
    local check = true
    for i = 1, #str do
        local letra = string.byte(str:sub(i,i))
        if letra >= string.byte('a') and letra <= string.byte('z') or letra >= string.byte('A') and letra <= string.byte('Z') or letra >= string.byte('0') and letra <= string.byte('9') then
            check = true
        else
            check = false
            break
        end
    end
    return check
end

function isArmor(itemid) -- By Killua
    return getItemInfo(itemid).armor > 0
end

function isWeapon(uid) -- By Killua
    return getItemWeaponType(uid) ~= 0
end

function isShield(uid) -- By Killua
    return getItemWeaponType(uid) == 5
end

function isSword(uid) -- By Killua
    return getItemWeaponType(uid) == 1
end

function isClub(uid) -- By Killua
    return getItemWeaponType(uid) == 2
end

function isAxe(uid) -- By Killua
    return getItemWeaponType(uid) == 3
end

function isBow(uid) -- By Killua
    return getItemWeaponType(uid) == 4
end

function isWand(uid) -- By Killua
    return getItemWeaponType(uid) == 7
end

 

Download:

killua's lib.lua 6 kB · 4 downloads

 

Isso é tudo pessoal!

 

Informações:

Este sistema funciona através de Premium Account, junto com ele vem o sistema de Autoloot Booster, que consiste em vender automaticamente os itens coletados. Foi testado em um servidor de Tibia 8.60 utilizando OTX 2.

 

Créditos:

@lordzetros

@KOLISAO

@Dwarfer

 

Opa, sistema muito bom!

Uma dúvida, teria como adicionar para Free poder usar apenas 2 slots, e VIP Storage 55555 usar 5 Slots?

Link para o post
Compartilhar em outros sites
  • 1 year later...
  • 10 months later...
  • Lion featured this tópico

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

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

×   Seu conteúdo anterior foi restaurado.   Limpar o editor

×   Não é possível colar imagens diretamente. Carregar ou inserir imagens do URL.

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.


  • Conteúdo Similar

    • Por amoxicilina
      Olá Kings, venho aqui trazer uma TalkAction pra você comprar premium account, sei que pode ser algo meio inútil por existir a store.
      Então vamos script:
       
       
    • Por danielzin021
      alguém sabe como implementa isso no serv e se tem como?
    • Por Maniaco
      Salve TibiaKing!!! TFS 0.4 . 8.60
       
      Estou implementando o Sistema do @WooX de Cave Exlusiva

      Link:
       
      Porem estou com um problema seguindo o tutorial completo dele acabo tendo um retorno de erro na Distro! E ja que o mesmo nao entra no forum deis de 14/01! Venho solicitar ajuda de vocês!
      Caso alguem tenha o Discord Dele Favor me Passe  
      Vamos lá!
      Erro:
       
      Script :
       
      Lib
       
       
      Print Rme:
       
       
      Lembrando que nao esta funcionando em geral, Acrédito que eu tenha pulado algo ou deixado passar despercebido!
      Espero que alguem consiga me ajudar vlw!
    • Por FeeTads
      salve rapaziada, do TK, esses tempos eu tava a procura de um autoloot bom e eficiente, e como vocês devem saber, o autoloot usado nos scripts .lua são bem "pesados"
      o @Naze fez um excelentíssimo trabalho e disponibilizou um script de autoloot na source, porém como a vida é dificil, ele tem alguns bugs de função e um deles é no 
      "remove autoloot" que quando o player digita "!autoloot remove, nome-do-item" nada acontece, eu decidi mexer e vim disponibilizar arrumado pra vcs.
      LEMBRANDO QUE 100% DOS CRÉDITOS SÃO AO @Naze porém se vc procurar no tópico dele ainda vai estar bugado, então resolvi deixar aqui certinho pra ajudar quem precisar.


      Link do tópico do naze: https://tibiaking.com/forums/topic/101086-otimizado-autoloot-in-sources-for-otx2-ou-menor/
       

      caso alguém ja utilize esse autoloot e esteja com o problema de remover items do autoloot
      só ir em player.cpp e trocar

      isso:
       
      void Player::removeAutoLoot(uint16_t id) { if(checkAutoLoot(id)) { return; } AutoLoot.remove(id); }
      por isso:
      void Player::removeAutoLoot(uint16_t id) { if(!checkAutoLoot(id)) return; for(std::list<uint16_t>::iterator it = AutoLoot.begin(); it != AutoLoot.end(); ++it) { if((*it) == id) { AutoLoot.erase(it); break; } } }
      todos os créditos ao Naze, não sei se alguém mais fez esse código, mas como peguei do link citado acima que é post dele deixo aqui o autoloot 100% funcional direto nas sources
    • Por WooX
      Trade Offline V2.0

      Esse sistema me foi pedido a alguns meses atrás e hoje tirei um tempinho pra trazer aqui.
      O sistema consiste em permitir que jogadores negociem sem contato direto entre comprador e vendedor.
      Mas como assim?
      O vendedor pode criar um anuncio de venda informando item, valores ou até mesmo items que ele queira em troca, após feito o anuncio todas essas informações ficam armazenadas no banco de dados do servidor, permitindo assim serem exibidas em uma página no site para interessados, junto de todas informações fornecidas pelo vendedor é exibido um comando para que os interessados possam adquirir a oferta exibida na página.
       
      Sobre o sistema

       
      O sistema foi testado apenas em OTX2, mas provavelmente também funcione em TFS 0.4
       
      Versão para TFS 1.x adaptada pelo @luanluciano93
       
      Como mencionado acima, o sistema funciona de forma semelhante ao Market System das versões atuais porem sem exibição gráfica das ofertas in-game, para isso o sistema vai acompanhado de uma página para o Gesior AAC. Este sistema existe no fórum há um bom tempo e já é familiar pra muitos jogadores, essa versão trás consigo algumas melhorias e diferenças que irei listar abaixo.
       
      Sistema
      Agora é possivel vender um item exigindo outro item em troca ao invés de dinheiro. Containers com um conjunto de items dentro agora podem ser anunciados. Agora o sistema verifica as cargas e durações dos items antes de criar uma oferta. Novo parâmetro adicionado para verificar informações de ofertas in-game. Agora todo valor recebido vai diretamente para o banco do vendedor. Página
      A depender da quantidade de ofertas existentes no servidor, a página agora irá separa-las por páginas. Agora além do valor é exibido também imagem da moeda a depender do valor da oferta. Agora é possivel ver as características tanto dos items ofertados como dos items exigidos pelo vendedor. Adicionado filtros para exibir somente ofertas de items vip, containers ou trocas. Adicionado barras de pesquisas para filtrar as ofertas por items ou nome do jogador.  
      Algumas imagens
       
      Instalação

      Antes de mais nada é necessário citar os requisitos necessários para o funcionamento correto do sistema, ele utiliza de algumas funções que não estão no script principal e portanto é necessário a instalação de uma lib extra, também é necessário instalar as funções doItemSetDuration e getItemDurationTime na source do servidor, ambos os links se encontram abaixo.
       
      Todos os arquivos necessários para a instalação estão anexados no tópico, irei apenas dizer onde instalar e como deve ser configurado.
       
      Primeiramente importe o arquivo schema.sql no banco de dados, ou se preferir pode executar as queries a seguir.
      CREATE TABLE IF NOT EXISTS `trade_off_offers` ( `id` int(11) NOT NULL auto_increment, `player_id` int(11) NOT NULL, `type` int(1) NOT NULL DEFAULT '0', `item_id` int(11), `item_count` int(11) NOT NULL DEFAULT '1', `item_charges` int(11) NULL, `item_duration` int(11) NULL, `item_name` varchar(255), `item_trade` tinyint(1) NOT NULL DEFAULT '0', `cost` bigint(20) UNSIGNED NOT NULL, `cost_count` int(11) NOT NULL DEFAULT '1', `date` bigint(20), PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1; CREATE TABLE IF NOT EXISTS `trade_off_container_items` ( `offer_id` int(11) NOT NULL, `item_id` int(11), `item_charges` int(11) NULL, `item_duration` int(11) NULL, `count` int(11) DEFAULT '1' ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1; ALTER TABLE `trade_off_container_items` ADD KEY `offer_id` (`offer_id`); ALTER TABLE `trade_off_container_items` ADD CONSTRAINT `offer_id_fk` FOREIGN KEY (`offer_id`) REFERENCES `trade_off_offers`(`id`) ON DELETE CASCADE;  
      Configuração no arquivo tradeoff.lua: 
      -- Trade Offline 2.0 by WooX -- local config = { priceLimit = 2000000000, -- 2kkk offerLimit = 3, offerLimitStor = 86420, infoOnPopUp = true, infoMsgType = MESSAGE_STATUS_CONSOLE_BLUE, errorMsgType = MESSAGE_STATUS_CONSOLE_RED, successMsgType = MESSAGE_INFO_DESCR, helpMsg = "Enter the parameters (add, remove, active, buy, info).", goldItems = {2148, 2152, 2160}, itemsVIP = {4540, 4545, 4560}, } priceLimit: define o valor máximo de uma oferta. offerLimit: define o valor máximo de ofertas que um jogador pode adicionar. offerLimitStor: storage que irá armazenar quantas ofertas ativas o jogador possui. infoOnPopUp: pode ser definido como true ou false, se definido como falso irá enviar os detalhes da oferta no default ao invés de como é mostrado nas imagens acima. infoMsgType: define como será exibido uma mensagem de informação ao jogador (não recomendo mexer a menos que saiba o que está fazendo). errorMsgType: define como será exibido uma mensagem de erro ao jogador (não recomendo mexer a menos que saiba o que está fazendo). successMsgType: define como será exibido uma mensagem de ação sucedida ao jogador (não recomendo mexer a menos que saiba o que está fazendo). helpMsg: mensagem que será enviada para o jogador caso ele erre os parâmetros do comando. goldItems: nesta tabela deve ser preenchido todos os IDs de moedas no servidor como gold coins, platinum coins, etc. itemsVIP: nesta tabela deve ser preenchido os IDs dos items vips existentes no servidor.  
      Agora para a instalação da página, no arquivo mysql_db.php deve ser preenchido os dados para conexão no banco de dados do servidor.
      /** * Host do banco de dados * @var string */ private static $DB_HOST = 'localhost'; /** * Usuario de conexao ao banco de dados * @var string */ private static $DB_USER = 'root'; /** * Senha de conexao ao banco de dados * @var string */ private static $DB_PASS = 'SUA_SENHA'; /** * Nome do banco de dados * @var string */ private static $DB_NAME = 'NOME_BANCO'; Após feito isso, o arquivo paginationClass.php em conjunto do arquivo mysql_db.php devem ser adicionados no seguinte diretório do Gesior AAC.
      classes/
      Finalizado isto, basta jogar o arquivo tradeoff.php dentro do diretório informado abaixo e o sistema estará pronto para uso.
      pages/
       
      Avisos

       
      Eu escrevi somente o sistema, não sou o autor da página para o Gesior AAC portanto não estarei dando suporte em relação a página que não seja sobre a instalação da mesma no Gesior AAC 2012, e embora esteja funcional, eu não recomendo o uso da página devido a falta do uso de cache para leitura do items.xml. Foram mais de 600 linhas de código sem contar funções extras e alterações na source, além de muitas horas de testes para garantir que tudo estava funcionando corretamente, tudo que peço em troca é que não removam os créditos no arquivo quando forem usar.  
      Créditos

      @MatheusDuarte pela página do Gesior AAC.
      schema.sql tradeoff.lua tradeoff.php mysql_db.php paginationClass.php
×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo