Ir para conteúdo
  • Cadastre-se

(Resolvido)Autoloot TFS 1.3


Ir para solução Resolvido por Dwarfer,

Posts Recomendados

  • Solução

@Yinz Como você não postou o código por completo, tive que supor que se tratava de um autoloot que eu vi por aí certa vez. Tente sempre deixar o código completo pra facilitar o trabalho, ajudar outras pessoas, além de se obter uma solução mais rapidamente pra você também.  Espero que minha suposição esteja correta.

Bem, eu não tive como testar o código, pois estava sem acesso ao meu computador.

 

Em data/lib, crie um arquivo.lua chamado AutoLootRemove.lua (ou qualquer nome de sua preferência) e cole isto dentro:

 

Spoiler

function Player:sendAutoLootModalRemove()
    local list = self:getAutoLootList()
    local window = ModalWindow(84000, "Currently items in the list", "Choose an item to remove from list:")
    window:addButton(2, "Erase all")
    window:addButton(3, "Exit") 
    window:addButton(1, "Remove")
    for index, it in spairs(list) do
        local itemName = ItemType(it):getName()
        window:addChoice(index, itemName)
    end
    window:setDefaultEnterButton(1)
    window:setDefaultEscapeButton(3)
    window:sendToPlayer(self)
end

function Player:sendAutoLootModalInfo(msg, button_text)
    local textWindow = ModalWindow(84001, "Information", msg)
    textWindow:addButton(1, button_text)
    textWindow:setDefaultEnterButton(1)
    textWindow:setDefaultEscapeButton(1)
    textWindow:sendToPlayer(self)
    return true
end

function spairs(t, order)
    local keys = {}
    for k in pairs(t) do keys[#keys+1] = k end
    if order then
        table.sort(keys, function(a,b) return order(t, a, b) end)
    else
        table.sort(keys)
    end
    local i = 0
    return function()
        i = i + 1
        if keys[i] then
            return keys[i], t[keys[i]]
        end
    end
end 

 

 

No global.lua, adicione a linha (ou troque para o nome que você escolheu):

dofile('data/lib/AutoLootRemove.lua')

Em talkactions/scripts, crie um arquivo.lua e cole isto dentro:

 

Spoiler

function onSay(player, words, param)
    local playerList = player:getAutoLootList()
    if not playerList then
        player:sendCancelMessage("Your auto loot items list is empty.")
        return false
    end
    player:sendAutoLootModalRemove()
    return false
end

 

 

No talkactions.xml, adicione a tag conforme desejar.

Ex.: 

<talkaction words="!autolootremove" script="NOMEDOSEUARQUIVO.lua"/>

 

Em seguida, em data/creaturescripts/scripts crie um arquivo.lua e cole isto dentro:

 

Spoiler

function onModalWindow(player, modalWindowId, buttonId, choiceId)
    if modalWindowId == 84000 then
        local playerList = player:getAutoLootList()
        if buttonId == 1 then
            local itemId = playerList[choiceId]
            player:removeAutoLootItem(itemId)
            player:sendAutoLootModalInfo("You have removed '" .. ItemType(itemId):getName() .. "' from your list.", "Ok")
        elseif buttonId == 2 then
            for _, itemListed in pairs(playerList) do
                player:removeAutoLootItem(itemListed)
            end
            player:sendAutoLootModalInfo("You have removed all auto looted items from your list.", "Ok")
        end
        return false
    elseif modalWindowId == 84001 then
        if buttonId == 1 then
            local playerList = player:getAutoLootList()
            if playerList then
                player:sendAutoLootModalRemove()
            end
        end
        return false
    end
    if not (modalWindowId == 84000 or modalWindowId == 84001) then
        return false
    end
    return false
end

function onLogin(player)
    player:registerEvent("RmvAutoLootModal")
    return true
end

 

 

No creaturescripts.xml, adicione as linhas:

<event type="modalwindow" name="RmvAutoLootModal" script="NOMEDOARQUIVO.lua"/>
<event type="login" name="RmvAutoLootLogin" script="NOMEDOARQUIVO.lua"/>

Qualquer problema, é só retornar.

Contato:

 

Link para o post
Compartilhar em outros sites
  • Respostas 10
  • Created
  • Última resposta

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

@Yinz Como você não postou o código por completo, tive que supor que se tratava de um autoloot que eu vi por aí certa vez. Tente sempre deixar o código completo pra facilitar o trabalho, ajudar outras pessoas, além de se obter uma solução mais rapidamente pra você também.  Espero que minha suposição esteja correta. Bem, eu não tive como testar o código, pois estava sem acesso ao meu computador.   Em data/lib, crie um arquivo.lua chamado AutoLootRemove.lua (ou qualquer nome de sua

Olá, eu tenho um autoloot e estou tendo dificuldades pra adapta-lo pra modal window. Eu não quero nem adaptar a parte de adicionar, pois acho que fica mais demorado, queria só a parte de remover, com os autoloots listados e o player ia selecionando e clicando no botão de remover, e se der adicionar um outro botão que limpe todo o autoloot.   ja tentei de diversas formas, inclusive puxando pela db mas não tive sucesso. local query = db.storeQuery("SELECT `autoloot_list` FROM pl

12 horas atrás, Dwarfer disse:

@Yinz Como você não postou o código por completo, tive que supor que se tratava de um autoloot que eu vi por aí certa vez. Tente sempre deixar o código completo pra facilitar o trabalho, ajudar outras pessoas, além de se obter uma solução mais rapidamente pra você também.  Espero que minha suposição esteja correta.

Bem, eu não tive como testar o código, pois estava sem acesso ao meu computador.

 

Em data/lib, crie um arquivo.lua chamado AutoLootRemove.lua (ou qualquer nome de sua preferência) e cole isto dentro:

 

  Mostrar conteúdo oculto


function Player:sendAutoLootModalRemove()
    local list = self:getAutoLootList()
    local window = ModalWindow(84000, "Currently items in the list", "Choose an item to remove from list:")
    window:addButton(2, "Erase all")
    window:addButton(3, "Exit") 
    window:addButton(1, "Remove")
    for index, it in spairs(list) do
        local itemName = ItemType(it):getName()
        window:addChoice(index, itemName)
    end
    window:setDefaultEnterButton(1)
    window:setDefaultEscapeButton(3)
    window:sendToPlayer(self)
end

function Player:sendAutoLootModalInfo(msg, button_text)
    local textWindow = ModalWindow(84001, "Information", msg)
    textWindow:addButton(1, button_text)
    textWindow:setDefaultEnterButton(1)
    textWindow:setDefaultEscapeButton(1)
    textWindow:sendToPlayer(self)
    return true
end

function spairs(t, order)
    local keys = {}
    for k in pairs(t) do keys[#keys+1] = k end
    if order then
        table.sort(keys, function(a,b) return order(t, a, b) end)
    else
        table.sort(keys)
    end
    local i = 0
    return function()
        i = i + 1
        if keys[i] then
            return keys[i], t[keys[i]]
        end
    end
end 

 

 

No global.lua, adicione a linha (ou troque para o nome que você escolheu):


dofile('data/lib/AutoLootRemove.lua')

Em talkactions/scripts, crie um arquivo.lua e cole isto dentro:

 

  Mostrar conteúdo oculto


function onSay(player, words, param)
    local playerList = player:getAutoLootList()
    if not playerList then
        player:sendCancelMessage("Your auto loot items list is empty.")
        return false
    end
    player:sendAutoLootModalRemove()
    return false
end

 

 

No talkactions.xml, adicione a tag conforme desejar.

Ex.: 


<talkaction words="!autolootremove" script="NOMEDOSEUARQUIVO.lua"/>

 

Em seguida, em data/creaturescripts/scripts crie um arquivo.lua e cole isto dentro:

 

  Mostrar conteúdo oculto


function onModalWindow(player, modalWindowId, buttonId, choiceId)
    if modalWindowId == 84000 then
        local playerList = player:getAutoLootList()
        if buttonId == 1 then
            local itemId = playerList[choiceId]
            player:removeAutoLootItem(itemId)
            player:sendAutoLootModalInfo("You have removed '" .. ItemType(itemId):getName() .. "' from your list.", "Ok")
        elseif buttonId == 2 then
            for _, itemListed in pairs(playerList) do
                player:removeAutoLootItem(itemListed)
            end
            player:sendAutoLootModalInfo("You have removed all auto looted items from your list.", "Ok")
        end
        return false
    elseif modalWindowId == 84001 then
        if buttonId == 1 then
            local playerList = player:getAutoLootList()
            if playerList then
                player:sendAutoLootModalRemove()
            end
        end
        return false
    end
    if not (modalWindowId == 84000 or modalWindowId == 84001) then
        return false
    end
    return false
end

function onLogin(player)
    player:registerEvent("RmvAutoLootModal")
    return true
end

 

 

No creaturescripts.xml, adicione as linhas:


<event type="modalwindow" name="RmvAutoLootModal" script="NOMEDOARQUIVO.lua"/>
<event type="login" name="RmvAutoLootLogin" script="NOMEDOARQUIVO.lua"/>

Qualquer problema, é só retornar.

 

Só quero te agradecer, obrigado pelo teu gesto e tua humildade. Funcionou 100%

Link para o post
Compartilhar em outros sites
  • 5 months later...
Em 23/05/2019 em 05:06, Yinz disse:

Só quero te agradecer, obrigado pelo teu gesto e tua humildade. Funcionou 100%

 

Diz pra gente como ficou o código correto pode ajudar mais gente assim como eu que estou tendo problema com autoloot!

Link para o post
Compartilhar em outros sites
  • 1 month later...

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.

  • Estatísticas dos Fóruns

    96842
    Tópicos
    519598
    Posts



×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo