Postado Julho 2, 2017 7 anos Este é um post popular. ~~~~~ * Auto Loot System 100% * ~~~~~ TFS 0.4 / TFS 0.3.7 Fala galerinha do Tibiaking, então, várias pessoas estão tendo problema com o sistema de autoloot, aqui vai um sistema que eu editei para melhorar o uso do mesmo. Sem muita enrolação vamos ao que interessa. 1° - Acesse a pasta data/lib e crie um arquivo chamado Auto_Loot.lua, coloque isso dentro do arquivo: Spoiler --[[ 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[i]) ~= -1 then table.insert(Table, getPlayerStorageValue(cid, AutoLoot.Storages.Slots[i])) 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[i]) == -1 then doPlayerSetStorageValue(cid, AutoLoot.Storages.Slots[i], 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[i]) == ItemID then doPlayerSetStorageValue(cid, AutoLoot.Storages.Slots[i], -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[i].ItemID) then if Bag[i].Count > 1 then doRemoveItem(Bag[i].uid, Bag[i].Count) doPlayerAddItem(cid, Bag[i].ItemID, Bag[i].Count) String = String.." ".. Bag[i].Count .." ".. getItemNameById(Bag[i].ItemID) .." +" else doRemoveItem(Bag[i].uid) if AutoLoot.Boost_Actived and AutoLoot.Boost(cid) then if AutoLoot_Boost[Bag[i].ItemID] then doPlayerSetBalance(cid, getPlayerBalance(cid) + AutoLoot_Boost[Bag[i].ItemID]) String = String.." 1 ".. getItemNameById(Bag[i].ItemID) .." (".. AutoLoot_Boost[Bag[i].ItemID] .."gp no banco) +" else doPlayerAddItem(cid, Bag[i].ItemID, 1) String = String.." 1 ".. getItemNameById(Bag[i].ItemID) .." +" end else doPlayerAddItem(cid, Bag[i].ItemID, 1) String = String.." 1 ".. getItemNameById(Bag[i].ItemID) .." +" end end end end end end end if isInArray(AutoLoot.getPlayerList(cid), Item.ItemID) then if Item.Count > 1 then doRemoveItem(Item.UID, Item.Count) doPlayerAddItem(cid, Item.ItemID, Item.Count) String = String.." ".. Item.Count .." ".. getItemNameById(Item.ItemID) .." +" else doRemoveItem(Item.UID) 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[i].ItemID) then local Multiplier = 1 if Bag[i].ItemID == 2148 then Multiplier = 1 elseif Bag[i].ItemID == 2152 then Multiplier = 100 elseif Bag[i].ItemID == 2160 then Multiplier = 10000 end doRemoveItem(Bag[i].uid, Bag[i].Count) doPlayerSetBalance(cid, getPlayerBalance(cid) + tonumber(Bag[i].Count) * Multiplier) Total_Gold = Total_Gold + Bag[i].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 doRemoveItem(Item.UID, Item.Count) 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 2° - Abra a pasta data/actions/scripts e crie um arquivo chamado Auto_Loot_Boost.lua, dentro dele adicione: Spoiler --[[ Auto Loot System by Danyel Varejão ]] function onUse(cid, item, fromPosition, itemEx, toPosition) if AutoLoot.Boost(cid) then doPlayerSendCancel(cid, "Você já está com o BOOST ativado!") return true end if doRemoveItem(item.uid) then doPlayerSetStorageValue(cid, AutoLoot.Storage_Boost, 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.") end return true end 3° - Abra a pasta data/creaturescripts/scripts e crie um arquivo chamado Auto_Loot.lua, dentro dele adicione: Spoiler --[[ Auto Loot System by Danyel Varejão Created in 02/07/2017 ]] function onLogin(cid) registerCreatureEvent(cid, "Auto_Loot_Login") registerCreatureEvent(cid, "Auto_Loot_Kill") return true end function onKill(cid, target, lastHit) if isPlayer(cid) and isMonster(target) then if getPlayerStorageValue(cid, AutoLoot.Storage_On_Items) == 1 and #AutoLoot.getPlayerList(cid) > 0 then addEvent(AutoLoot.Items, 500, cid, getCreaturePosition(target)) end if getPlayerStorageValue(cid, AutoLoot.Storage_On_Gold) == 1 then addEvent(AutoLoot.Gold, 500, cid, getCreaturePosition(target)) end if getPlayerStorageValue(cid, AutoLoot.Storage_On_Items) == 1 or getPlayerStorageValue(cid, AutoLoot.Storage_On_Gold) == 1 then addEvent(AutoLoot.Message, 500, cid) end end return true end 4° - Abra a pasta data/talkactions/scripts e crie um arquivo chamado Auto_Loot.lua, dentro dele adicione: Spoiler function onSay(cid, words, param) if param == "" then local String = "" local Slot_Count = 1 for i = 1, #AutoLoot.Storages.Slots do if getPlayerStorageValue(cid, AutoLoot.Storages.Slots[i]) ~= -1 then String = String.."{Auto-Loot} --- Slot "..Slot_Count..": "..getItemNameById(getPlayerStorageValue(cid, AutoLoot.Storages.Slots[i])).."\n" else String = String.."{Auto-Loot} --- Slot "..Slot_Count..": Empty\n" end Slot_Count = Slot_Count + 1 end local Gold_Status = getPlayerStorageValue(cid, AutoLoot.Storage_On_Gold) == 1 and "on" or "off" local Items_Status = getPlayerStorageValue(cid, AutoLoot.Storage_On_Items) == 1 and "on" or "off" doPlayerPopupFYI(cid, [[ {Auto-Loot} --- Coletar dinheiro: ]].. Gold_Status ..[[. Para ligar/desligar: !autoloot gold {Auto-Loot} --- Coletar itens únicos: ]].. Items_Status ..[[. Para ligar/desligar: !autoloot power {Auto-Loot} --- Configuração dos slots: ]].. String ..[[ {Auto-Loot} --- Para adicionar um novo item aos slots: !autoloot add, <nome do item> {Auto-Loot} --- Para retirar um item dos slots: !autoloot remove, <nome do item> {Auto-Loot} --- Para limpar todos os slots utilize: !autoloot clear {Auto-Loot} --- Para informações de quanto você já fez utilizando a coleta de dinheiro, use: !autoloot goldinfo {Auto-Loot} --- Se seu autoloot bugar use !autoloot desbug ]]) return true end local CommandParam = string.explode(param, ",") if getPlayerLevel(cid) >= AutoLoot.Min_Level then if CommandParam[1] == "power" then local get_Items = getPlayerStorageValue(cid, AutoLoot.Storage_On_Items) == -1 and "ligou" or "desligou" doPlayerSetStorageValue(cid, AutoLoot.Storage_On_Items, getPlayerStorageValue(cid, AutoLoot.Storage_On_Items) == -1 and 1 or -1) doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Você "..get_Items.." o auto loot.") elseif CommandParam[1] == "gold" then local get_Gold = getPlayerStorageValue(cid, AutoLoot.Storage_On_Gold) == -1 and "ligou" or "desligou" doPlayerSetStorageValue(cid, AutoLoot.Storage_On_Gold, getPlayerStorageValue(cid, AutoLoot.Storage_On_Gold) == -1 and 1 or -1) doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Você "..get_Gold.." a coleta de dinheiro.") doPlayerSetStorageValue(cid, AutoLoot.Storages.Count_Gold, 0) elseif CommandParam[1] == "goldinfo" then local Check_Gold_Info = getPlayerStorageValue(cid, AutoLoot.Storage_On_Gold) == -1 and "O sistema de coleta de dinheiro está desligado" or "O sistema já coletou "..AutoLoot.getPlayerStorageZero(cid, AutoLoot.Storages.Count_Gold).." gold coins" doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, Check_Gold_Info) elseif CommandParam[1] == "add" then if CommandParam[2] ~= nil and CommandParam[2] ~= "" and AutoLoot.ExistItemByName(CommandParam[2]) then local Item = getItemIdByName(CommandParam[2]) if isInArray({2160, 2148, 2152}, Item) then return doPlayerSendCancel(cid, "Você não pode adicionar moedas no autoloot. Para coletar dinheiro use !autoloot gold") end if getPlayerStorageValue(cid, AutoLoot.Storages.Count_Items) < (AutoLoot.Max_Slots - 1) then if AutoLoot.addToList(cid, CommandParam[2]) then doPlayerSetStorageValue(cid, AutoLoot.Storages.Count_Items, getPlayerStorageValue(cid, AutoLoot.Storages.Count_Items) + 1) doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, CommandParam[2].." adicionado à sua lista do auto loot! Para ver sua lista diga !autoloot list") else doPlayerSendCancel(cid, CommandParam[2].." já está em sua lista!") end else doPlayerSendCancel(cid, "Sua lista já tem ".. AutoLoot.Max_Slots .." itens! Você deve remover algum antes de adicionar outro.") end else doPlayerSendCancel(cid, "Este item não existe!") end elseif CommandParam[1] == "remove" then if CommandParam[2] ~= nil and CommandParam[2] ~= "" and AutoLoot.ExistItemByName(CommandParam[2]) then if AutoLoot.removeFromList(cid, CommandParam[2]) then doPlayerSetStorageValue(cid, AutoLoot.Storages.Count_Items, getPlayerStorageValue(cid, AutoLoot.Storages.Count_Items) - 1) doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, CommandParam[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 CommandParam[1] == "clear" then if getPlayerStorageValue(cid, AutoLoot.Storages.Count_Items) > -1 then doPlayerSetStorageValue(cid, AutoLoot.Storages.Count_Items, -1) doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Lista limpa!") for i = 1, #AutoLoot.Storages.Slots do doPlayerSetStorageValue(cid, AutoLoot.Storages.Slots[i], -1) end else doPlayerSendCancel(cid, "Sua lista ja esta limpa!") end elseif CommandParam[1] == "desbug" or CommandParam[1] == "desbugar" then doPlayerSetStorageValue(cid, AutoLoot.Storages.Count_Items, -1) doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Desbugado!") for i = 1, #AutoLoot.Storages.Slots do doPlayerSetStorageValue(cid, AutoLoot.Storages.Slots[i], -1) end elseif CommandParam[1] == "list" then local String = "" local Slot_Count = 1 for i = 1, #AutoLoot.Storages.Slots do if getPlayerStorageValue(cid, AutoLoot.Storages.Slots[i]) ~= -1 then String = String.."Slot "..Slot_Count..": "..getItemNameById(getPlayerStorageValue(cid, AutoLoot.Storages.Slots[i])).."\n" else String = String.."Slot "..Slot_Count..": Empty\n" end Slot_Count = Slot_Count + 1 end doPlayerPopupFYI(cid, [[ ---------{Auto-Loot}--------- O sistema auto loot está coletando: ]].. String ..[[ ]]) end else doPlayerSendCancel(cid, "Você não é level maior que "..AutoLoot.Min_Level.." para utilizar este comando.") end return true end 5° - Em data/actions/actions.xml adicione a seguinte tag: <!-- Auto Loot --> <action itemid="7443" event="script" value="Auto_Loot_Boost.lua"/> Altere o numero 7443 caso queira mudar o id do item do seu auto loot boost. 6° - Em data/creaturescripts/creaturescripts.xml adicione a seguinte tag: <!-- Auto Loot --> <event type="login" name="Auto_Loot_Login" event="script" value="Auto_Loot.lua"/> <event type="kill" name="Auto_Loot_Kill" event="script" value="Auto_Loot.lua"/> 7° - Em data/talkactions/talkactions.xml adicione a seguinte tag: <!-- Auto Loot --> <talkaction access="0-4" words="/autoloot;!autoloot" event="script" value="Auto_Loot.lua"/> Créditos 50% Killua(Vitor Bertolucci) 50% Danyel Varejão Editado Janeiro 14, 2018 7 anos por Danyel Varejao (veja o histórico de edições)
Postado Julho 3, 2017 7 anos Parabéns, seu tópico de conteúdo foi aprovado! Muito obrigado pela sua contribuição, nós do Tibia King agradecemos. Seu conteúdo com certeza ajudará à muitos outros, você recebeu +1 REP. Spoiler Congratulations, your content has been approved! Thank you for your contribution, we of Tibia King we are grateful. Your content will help many other users, you received +1 REP.
Postado Julho 3, 2017 7 anos Sem duvida o melhor System de Auto Loot Danyel, parabens por atualizar o script e deixa-lo funcional, vai ajudar muita gente! REP+!
Postado Julho 3, 2017 7 anos Você adicionar o arquivo Auto_Loot.lua em data/lib? Qual versão do seu TFS?
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.