Majesty 1,755 #1 Posted January 20, 2020 [TFS 1.3] Autoloot + Modal Window Citar Nome: [TFS 1.3] Autoloot + Modal Window Versão: [10.x+] // Servidor testado: (Github) Tipo do script: Sistema Créditos: Psychonaut (Autoloot), Marson (Modal) Obs1: No repositório o que foi removido está em vermelho e o que foi modificado está em verde. Então, para adicionar de novo modifica o que está em verde e coloca o que está em vermelho. Obs2: depois de adicionar o sistema, compile as sources e obtenha um novo executável. config.lua: https://github.com/opentibiabr/otservbr-global/commit/85f92ff99bc9363883a7c84091efc48b494ca13b#diff-715dc4700595a0c608dcb61f0e437029 data/actions/actions.xml: https://github.com/opentibiabr/otservbr-global/commit/85f92ff99bc9363883a7c84091efc48b494ca13b#diff-08d87e96e83a46d598e49b250e9ac2cc data/actions/scripts/autoloot.lua: https://github.com/opentibiabr/otservbr-global/commit/85f92ff99bc9363883a7c84091efc48b494ca13b#diff-d33b40849e3f0a075d38074f63553457 data/creaturescripts/creaturescripts.xml: https://github.com/opentibiabr/otservbr-global/commit/85f92ff99bc9363883a7c84091efc48b494ca13b#diff-4c306ba94776b9951042cbcb85c22d85 data/creaturescripts/scripts/autoloot.lua: https://github.com/opentibiabr/otservbr-global/commit/85f92ff99bc9363883a7c84091efc48b494ca13b#diff-cde0f994987b35024e44b97ee64b2687 data/events/scripts/monster.lua: https://github.com/opentibiabr/otservbr-global/commit/85f92ff99bc9363883a7c84091efc48b494ca13b#diff-a8804537e2fefee9ffb6c45718196a22 data/globalevents/globalevents.xml: https://github.com/opentibiabr/otservbr-global/commit/85f92ff99bc9363883a7c84091efc48b494ca13b#diff-d304a3f083f6b671923c15dc5193e9cc data/globalevents/scripts/autoloot.lua: https://github.com/opentibiabr/otservbr-global/commit/85f92ff99bc9363883a7c84091efc48b494ca13b#diff-baec93e54bfb0609a05128a62feec8fd data/lib/core/container.lua: https://github.com/opentibiabr/otservbr-global/commit/85f92ff99bc9363883a7c84091efc48b494ca13b#diff-5a1fc9d20f4fb2827841dac873998c16 data/talkactions/scripts/player/add_autoloot.lua: Spoiler function onSay(player, words, param) local monsterType = MonsterType(param) if not monsterType then player:sendCancelMessage("Can't find monster.") return false end player:registerEvent('autoloot') local title = "Autoloot Helper!" local message = "Loots of "..string.gsub(" "..string.lower(param), "%W%l", string.upper):sub(2)..":" local lootBlockList = monsterType:getLoot() table.sort(lootBlockList, function(a, b) return ItemType(a.itemId):getName() < ItemType(b.itemId):getName() end) lootBlockListm[getPlayerGUID(player)] = lootBlockList lootBlockListn[getPlayerGUID(player)] = param local window = ModalWindow(1001, title, message) local check, sum = {}, 1 for _, loot in pairs(lootBlockList) do local status = '' if player:getAutoLootItem(lootBlockList[sum].itemId) then status = '*' end if not table.contains(check, ItemType(lootBlockList[sum].itemId):getName()) then table.insert(check, ItemType(lootBlockList[sum].itemId):getName()) local resultId = db.storeQuery('SELECT `cont_id` FROM `player_autoloot_persist` WHERE `player_guid` = ' .. getPlayerGUID(player) .. ' AND `item_id` = ' .. lootBlockList[sum].itemId .. '') if resultId then local bp_id = result.getNumber(resultId, 'cont_id') end local backvinculo if result.getNumber(resultId, 'cont_id') and result.getNumber(resultId, 'cont_id') > 0 then backvinculo = '| '..ItemType(result.getNumber(resultId, 'cont_id')):getName()..'' else backvinculo = '' end window:addChoice(sum, "".. string.gsub(" "..status..""..ItemType(lootBlockList[sum].itemId):getName(), "%W%l", string.upper):sub(2, 21) .." | "..lootBlockList[sum].maxCount.." | "..(lootBlockList[sum].chance/1000).."% "..string.gsub(" "..string.lower(backvinculo), "%W%l", string.upper):sub(2).."") end sum = sum + 1 end window:addButton(105, "Backpack") window:setDefaultEnterButton(103, "Add") window:addButton(100, "Confirm") if autolootBP == 1 then window:addButton(102, "Remove") end window:addButton(103, "Add") window:sendToPlayer(player) return false end data/talkactions/scripts/player/autoloot.lua: Spoiler function onSay(player, words, param) local lootlist, sum = player:getAutoLootList(), 1 if lootlist then player:registerEvent('autoloot') local title = "Autoloot Helper!" local message = "You are currently looting the following items:" local window = ModalWindow(1000, title, message) table.sort(lootlist, function(a, b) return ItemType(a):getName() < ItemType(b):getName() end) for _, item in ipairs(lootlist) do local resultId = db.storeQuery('SELECT `cont_id` FROM `player_autoloot_persist` WHERE `player_guid` = ' .. getPlayerGUID(player) .. ' AND `item_id` = ' .. ItemType(item):getId() .. '') if resultId then local bp_id = result.getNumber(resultId, 'cont_id') end local backvinculo if result.getNumber(resultId, 'cont_id') and result.getNumber(resultId, 'cont_id') > 0 then backvinculo = '| '..ItemType(result.getNumber(resultId, 'cont_id')):getName()..'' else backvinculo = '' end window:addChoice(sum, "".. string.gsub(" "..(ItemType(item)):getName(), "%W%l", string.upper):sub(2, 21) .." "..string.gsub(" "..string.lower(backvinculo), "%W%l", string.upper):sub(2).."") sum = sum + 1 end window:addButton(106, "Backpack") window:addButton(100, "Confirm") window:addButton(102, "Remove") if autolootBP == 1 then window:setDefaultEnterButton(106, "Backpack") end window:sendToPlayer(player) return true else player:sendCancelMessage("The list is empty.") return false end end data/talkactions/talkactions.xml: Spoiler <talkaction words="!autoloot" separator=" " script="player/autoloot.lua"/> <talkaction words="!add" separator=" " script="player/add_autoloot.lua" /> schema.sql: https://github.com/opentibiabr/otservbr-global/commit/85f92ff99bc9363883a7c84091efc48b494ca13b#diff-a61f9a230da5ff6e814afa5e8ded2ed9 src/configmanager.cpp: https://github.com/opentibiabr/otservbr-global/commit/85f92ff99bc9363883a7c84091efc48b494ca13b#diff-058018eb65de10f7dc4b177b57e662d3 src/configmanager.h: https://github.com/opentibiabr/otservbr-global/commit/85f92ff99bc9363883a7c84091efc48b494ca13b#diff-6df5d8dfbf829d832803f8fad5657ac4 src/iologindata.cpp: https://github.com/opentibiabr/otservbr-global/commit/85f92ff99bc9363883a7c84091efc48b494ca13b#diff-3233c1fe16f68e9acfbc9bbd8103ea95 src/luascript.cpp: https://github.com/opentibiabr/otservbr-global/commit/85f92ff99bc9363883a7c84091efc48b494ca13b#diff-52cc0839e1c346634d8dad954bb7b30e src/luascript.h: https://github.com/opentibiabr/otservbr-global/commit/85f92ff99bc9363883a7c84091efc48b494ca13b#diff-10885124f22fc1d3d004c767608f4ab8 src/player.cpp: https://github.com/opentibiabr/otservbr-global/commit/85f92ff99bc9363883a7c84091efc48b494ca13b#diff-dc52f162280289dd2d4d97d82658362d src/player.h: https://github.com/opentibiabr/otservbr-global/commit/85f92ff99bc9363883a7c84091efc48b494ca13b#diff-ccacfa92fac3e0aaea61cad84dd77e01 Como usar: Spoiler !add nome_do_monstro - para adicionar loots desejados na lista !autoloot - visualizar e editar loots da lista Exemplo: !add Demon !autoloot 2 Elver Maguh and carltonsa reacted to this Share this post Link to post