Alguém por acaso pode me ajudar caso tenha experiencia .. tenho um sistema de autoloot que coloquei no servidor e inicialmente parecia ta funcionando bem.. coletava os gold, vai direto para o banco e tals..
Fui testar a função de !autoloot golden legs, ao usar este comando buga tudo, e na distro aparece um erro enorme.
Servidor é 8.6 com a distro 0.4
Erro:
Spoiler
[18:24:38.624] [Error - TalkAction Interface]
[18:24:38.629] local cid = 268451737
[18:24:38.630] local words = "!autoloot"
[18:24:38.632] local param = "golden legs"
[18:24:38.634] local channel = 65534
[18:24:38.636] domodlib('Loot_func')
[18:24:38.638] local param, slots = param:lower(), isPremium(cid) and info.Max_Slots.premium or info.Max_Slots.free
[18:24:38.645] if not param or param == "" then
[18:24:38.648] ShowItemsTabble(cid) return true
[18:24:38.651] elseif tonumber(param) then
[18:24:38.653] doPlayerSendCancel(cid, "enter commands: !autoloot item name [+] !autoloot clean [+] !autoloot money [+] !autoloot on/off") return true
[18:24:38.663] elseif isInArray({"clean","limpar", "clear"}, param) then
[18:24:38.666] if existsAutoloot(cid) then doCleanAutoloot(cid) end
[18:24:38.671] doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,"[Auto Loot] Your list has been cleaned.") return true
[18:24:38.677] elseif isInArray({"start","stop","on","off"}, param) then
[18:24:38.680] setPlayerStorageValue(cid, info.Storages[1], getPlayerStorageValue(cid, info.Storages[1]) <= 0 and 1 or 0)
[18:24:38.687] doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,"Auto Loot "..(getPlayerStorageValue(cid, info.Storages[1]) > 0 and "Stopped" or "Started")..".") return true
[18:24:38.696] elseif isInArray({"warn","aviso"}, param) then
[18:24:38.699] setPlayerStorageValue(cid, info.Storages[3], getPlayerStorageValue(cid, info.Storages[3]) <= 0 and 1 or 0)
[18:24:38.707] doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,"Auto Loot Backpack Warn "..(getPlayerStorageValue(cid, info.Storages[3]) > 0 and "disabled" or "Activated")..".") return true
[18:24:38.719] elseif isInArray({"mensagem","message","mensagen","msg"}, param) then
[18:24:38.724] setPlayerStorageValue(cid, info.Storages[6], getPlayerStorageValue(cid, info.Storages[6]) <= 0 and 1 or 0)
[18:24:38.730] doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,"Auto Loot Message "..(getPlayerStorageValue(cid, info.Storages[6]) > 0 and "disabled" or "Activated")..".") return true
[18:24:38.738] elseif isInArray({"cor","color","type"}, param) then
[18:24:38.742] setPlayerStorageValue(cid, info.Storages[5], getPlayerColorLootMessage(cid) == #Color_Loot and 0 or getPlayerColorLootMessage(cid)+1)
[18:24:38.748] doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,"Auto Loot Message Color Changed to "..Color_Loot[getPlayerColorLootMessage(cid)][2]..".") return true
[18:24:38.755] elseif isInArray({"money","gold","gps","dinheiro"}, param) then
[18:24:38.759] setPlayerStorageValue(cid, info.Storages[2], getPlayerStorageValue(cid, info.Storages[2]) <= 0 and 1 or 0)
[18:24:38.764] doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,"[Autoloot] Colteda de gold "..(getPlayerStorageValue(cid, info.Storages[2]) > 0 and "Activated" or "disabled").." Para ativar o deposito direto no bank, ligue o !autoloot deposit.") return true
[18:24:38.776] elseif isInArray({"deposito","bank","gbank","deposit","autodeposit"}, param) then
[18:24:38.782] setPlayerStorageValue(cid, info.Storages[4], getPlayerStorageValue(cid, info.Storages[4]) <= 0 and 1 or 0)
[18:24:38.787] doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,"[Auto Loot] Automatic Gold Bank "..(getPlayerStorageValue(cid, info.Storages[4]) > 0 and "Activated" or "disabled")..".") return true
[18:24:38.795] end
[18:24:38.796] local item = ExistItemByName(tostring(param))
[18:24:38.800] if exhaustion.get(cid, 101) then
[18:24:38.802] doPlayerSendCancel(cid, 'Espere 10 seconds Para usar o comando novamente.')
[18:24:38.805] return false
[18:24:38.807] end
[18:24:38.808] exhaustion.set(cid, 101, 10)
[18:24:38.811] if not item then
[18:24:38.813] doPlayerSendCancel(cid, "This item does not exist.") return true
[18:24:38.816] end
[18:24:38.817] local item = getItemIdByName(tostring(param))
[18:24:38.820] local var = isInTable(cid, item)
[18:24:38.822] if isInArray(info.Money_ids, item) then
[18:24:38.824] doPlayerSendTextMessage(cid, MESSAGE_FIRST, "Enter !autoloot money to add money in your list!") return true
[18:24:38.830] elseif isInArray(info.BlockItemsList, item) then
[18:24:38.833] doPlayerSendCancel(cid, "You can not add this item in the list!") return true
[18:24:38.835] elseif not var and #getItensFromAutoloot(cid) >= slots then
[18:24:38.839] doPlayerSendCancel(cid, "max "..slots.." from auto loot") return true
[18:24:38.842] elseif getPlayerStorageValue(cid, info.Storages[7]) - os.time() > 0 then
[18:24:38.847] doPlayerSendCancel(cid, "wait a second to use this command again") return true
[18:24:38.850] end
[18:24:38.851] if not var then
[18:24:38.853] doAddItemFromAutoloot(cid, item)
[18:24:38.855] else
[18:24:38.856] doremoveItemFromAutoloot(cid, item)
[18:24:38.858] end
[18:24:38.860] setPlayerStorageValue(cid, info.Storages[7], os.time()+info.Talkaction_delay)
[18:24:38.864] doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,not var and "you added the item "..param.." in the list" or "you removed the item "..param.." from the list, please wait 5 seconds to save the directory.")
[18:24:38.872] return true
[18:24:38.873] Description:
[18:24:38.875] [string "info = {..."]:60: attempt to index global 'newFile' (a nil value)
info = {
directory = "data/logs/autoloot",
Warn_Bp_Slots = 5, -- quando tiver 5 ou menos slots na BP vai avisar o jogador
Talkaction_delay = 5, -- em segundos // delay para remover e adicionar item
BlockMonsters = {},
BlockItemsList = {2123,2515},
Money_ids = {2148, 2152, 2160}, -- id das moedas do ot
Max_Slots = {free = 3, premium = 3},
Storages = {988801, 988802, 988803, 988804, 988805, 988806, 988807}
}
function getPlayerColorLootMessage(cid)
return getPlayerStorageValue(cid, info.Storages[5]) <= 0 and 0 or getPlayerStorageValue(cid, info.Storages[5])
end
function isInTable(cid, item)
for _,i in pairs(getItensFromAutoloot(cid)) do
if tonumber(i) == tonumber(item) then
return true
end
end
return false
end
function doremoveItemFromAutoloot(cid, itemid)
local file, fileContent = io.open(info.directory.."/"..getCreatureName(cid)..".txt", 'r'),{}
for line in file:lines() do
if line ~= "" and tonumber(line) ~= tonumber(itemid) then
fileContent[#fileContent + 1] = line
end
end
io.close(file)
file = io.open(info.directory.."/"..getCreatureName(cid)..".txt", 'w')
for index, value in ipairs(fileContent) do
file:write(value..'\n')
end
io.close(file)
end
function doAddItemFromAutoloot(cid, itemid)
if not existsAutoloot(cid) then
doCreateLootUserName(cid, itemid) return true
end
local file = io.open(info.directory.."/"..getCreatureName(cid)..".txt", "a+")
file:write('\n'..itemid)
file:close()
end
function existsAutoloot(cid)
local f = io.open(info.directory.."/"..getCreatureName(cid)..".txt", "rb")
if f then f:close() end
return f ~= nil
end
function doCreateLootUserName(cid, itemid)
newFile = io.open(info.directory.."/"..getCreatureName(cid)..".txt", "w+" )
newFile:write(itemid)
newFile:close()
end
function getItensFromAutoloot(cid)
if not existsAutoloot(cid) then return {} end
lines = {}
for line in io.lines(info.directory.."/"..getCreatureName(cid)..".txt") do
if line ~= "" then
lines[#lines + 1] = tonumber(line)
end
end
return lines
end
function doCleanAutoloot(cid)
return os.remove(info.directory.."/"..getCreatureName(cid)..".txt")
end
function ShowItemsTabble(cid)
local auto_list = getItensFromAutoloot(cid)
local n,str = 0,"[+] Auto Loot Commands [+]\n\n!autoloot item name --> Para adicionar ou Remover item da lista.\n!autoloot money --> Para coletar Gold automaticamente.\n!autoloot clear --> Para Zerar sua lista.\n!autoloot on/off --> Para habilitar ou desativar a coleta de itens no sistema.\n!autoloot message --> Para ativar ou desativar a mensagem de coletar itens.\n!autoloot color --> Mudar cor da mensagem in Auto Loot Collect.\n!autoloot warn --> Para ativar ou desativar o aviso de mensagem de "..info.Warn_Bp_Slots.." ou menos slots na Backpack.\n!autoloot deposit --> Para habilitar ou desativar o depósito automático em dinheiro no banco.\n\n[+] Auto Loot Info [+]\n\nSystem: "..(getPlayerStorageValue(cid, info.Storages[1]) <= 0 and "Activated" or "Disabled")..".\nGold Collecting: "..(getPlayerStorageValue(cid, info.Storages[2]) > 0 and "Activated" or "Disabled")..".\nMessage: "..(getPlayerStorageValue(cid, info.Storages[6]) <= 0 and "Activated" or "Disabled")..".\nColor Message: "..Color_Loot[getPlayerColorLootMessage(cid)][2]..".\nWarn Backpack: "..(getPlayerStorageValue(cid, info.Storages[3]) <= 0 and "Activated" or "Disabled")..".\nAutomatic Gold Deposit: "..(getPlayerStorageValue(cid, info.Storages[4]) > 0 and "Activated" or "Disabled")..".\nTotal Bank Balance: ["..getPlayerBalance(cid).."]\nMaximum Slots: ["..#auto_list.."/"..(isPremium(cid) and info.Max_Slots.premium or info.Max_Slots.free).."]\n\n[+] Auto Loot Slots [+]\n\n"
if #auto_list > 0 then
for i = 1, #auto_list do
n = n + 1
str = str.."Slot "..n.." - "..getItemNameById(auto_list[i]).."\n"
end
end
return doPlayerPopupFYI(cid, str)
end
function getContainerItems(container, array, haveCap)
array = array or {}
haveCap = haveCap or false
if not isContainer(container.uid) or getContainerSize(container.uid) == 0 then
array[#array +1] = container
else
local size = getContainerSize(container.uid)
haveCap = (getContainerCap(container.uid) -size) > 0
for slot = 0, (size -1) do
local item = getContainerItem(container.uid, slot)
if item.itemid > 1 then
getContainerItems(item, array, haveCap)
end
end
end
return #array >= 1 and array, haveCap
end
function getContainerItemsById(container, itemid)
local founds = {}
local items = not container.uid and container or getContainerItems(container)
for index, item in pairs(items) do
if item.itemid == itemid then
founds[#founds +1] = item
end
end
return #founds >= 1 and founds
end
function AutomaticDeposit(cid, item, n)
local deposit = item == tonumber(2160) and (n*10000) or tonumber(item) == 2152 and (n*100) or (n)
return doPlayerDepositMoney(cid, deposit)
end
function getAllContainerFree(container) -- by vodka
local containers,soma = {},0
for i = 0, getContainerSize(container)-1 do
local item = getContainerItem(container, i)
if isContainer(item.uid) then
table.insert(containers, item.uid)
end
end
for _, check in pairs(containers) do
soma = soma + getContainerSlotsFree(check)
end
return (soma + getContainerSlotsFree(container))
end
function getContainerSlotsFree(container) -- by vodka
return getContainerCap(container)-getContainerSize(container)
end
function doPlayerAddItemStackable(cid, itemid, count)
local container = getPlayerSlotItem(cid, CONST_SLOT_BACKPACK)
if container.itemid > 1 then
local items = getContainerItemsById(container, itemid)
if not items then
return doPlayerAddItem(cid, itemid, count)
else
local piles = #items
for index, item in pairs(items) do
if item.type < 100 then
local sum = item.type + count
local result = doTransformItem(item.uid, itemid, sum)
if sum <= 100 then
return result
else
return doPlayerAddItem(cid, itemid, sum - 100)
end
else
piles = piles - 1
if piles == 0 then
return doPlayerAddItem(cid, itemid, count)
end
end
end
end
end
return false
end
function corpseRetireItems(cid, pos)
local check, slots = false, 0
for i = 0, 255 do
pos.stackpos = i
if getThingFromPos(pos).uid > 0 and isContainer(getThingFromPos(pos).uid) then
corpse = getThingFromPos(pos)
check = true
break
end
end
if check == true then
local str, id_list = "", getItensFromAutoloot(cid)
for _, item in pairs(getContainerItems(corpse)) do
local id = item.itemid
if #id_list > 0 and isInArray(id_list, id) or getPlayerStorageValue(cid, info.Storages[2]) > 0 and isInArray(info.Money_ids, id) then
local amount = isItemStackable(id) and item.type or 1
local total_cap = getItemWeightById(id, amount)
if getPlayerSlotItem(cid, 3).itemid ~= 0 then
slots = getAllContainerFree(getPlayerSlotItem(cid, 3).uid)
end
if slots > 0 and getPlayerFreeCap(cid) >= total_cap then
str = str.." " .. getItemInfoLoot(id, amount)
if isItemStackable(id) then
doPlayerAddItemStackable(cid, id, amount)
if isInArray(info.Money_ids, id) and getPlayerStorageValue(cid, info.Storages[4]) > 0 then
AutomaticDeposit(cid, id, amount)
end
else
doPlayerAddItem(cid, id)
end
doRemoveItem(item.uid)
end
end
end
if str ~= "" and getPlayerStorageValue(cid, info.Storages[6]) <= 0 then
doPlayerSendTextMessage(cid, Color_Loot[getPlayerColorLootMessage(cid)][1],"[Auto Loot Collect]:"..string.sub(str, 1, -2)..".")
end
if getPlayerStorageValue(cid, info.Storages[3]) <= 0 and slots > 0 and slots <= info.Warn_Bp_Slots then
doPlayerSendTextMessage(cid,18, "[Auto Loot Warn] You only have "..slots.." slots free in your backpack!")
end
end
end
function ExistItemByName(name) -- by vodka
local items = io.open("data/items/items.xml", "r"):read("*all")
local get = items:lower():match('name="' .. name:lower() ..'"')
if get == nil or get == "" then
return false
end
return true
end
function getItemInfoLoot(id, amount)
local info = getItemInfo(id)
return isItemStackable(id) and amount.." "..(amount > 1 and info.plural or info.name).."," or info.article.." " .. info.name ..","
end
]]></config>
<event type="login" name="LootLogin" event="script"><![CDATA[
domodlib('Loot_func')
function onLogin(cid)
registerCreatureEvent(cid, "LootEventKIll")
if isPremium(cid) and getPlayerStorageValue(cid, 853608) <= 0 then
setPlayerStorageValue(cid, 853608, 1)
elseif getPlayerStorageValue(cid, 853608) > 0 and not isPremium(cid) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "[Auto Loot] You premium is Over, Start a new list!")
setPlayerStorageValue(cid, 853608, -1)
doCleanAutoloot(cid)
end
return true
end]]></event>
<event type="kill" name="LootEventKIll" event="script"><![CDATA[
domodlib('Loot_func')
function onKill(cid, target, lastHit)
if isPlayer(cid) and getPlayerStorageValue(cid, info.Storages[1]) <= 0 and isMonster(target) and not isInArray(info.BlockMonsters, getCreatureName(target):lower()) then
addEvent(corpseRetireItems, 0, cid ,getThingPos(target))
end
return true
end]]></event>
<talkaction words="!autoloot;/autoloot" event="buffer"><![CDATA[
domodlib('Loot_func')
local param, slots = param:lower(), isPremium(cid) and info.Max_Slots.premium or info.Max_Slots.free
if not param or param == "" then
ShowItemsTabble(cid) return true
elseif tonumber(param) then
doPlayerSendCancel(cid, "enter commands: !autoloot item name [+] !autoloot clean [+] !autoloot money [+] !autoloot on/off") return true
elseif isInArray({"clean","limpar", "clear"}, param) then
if existsAutoloot(cid) then doCleanAutoloot(cid) end
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,"[Auto Loot] Your list has been cleaned.") return true
elseif isInArray({"start","stop","on","off"}, param) then
setPlayerStorageValue(cid, info.Storages[1], getPlayerStorageValue(cid, info.Storages[1]) <= 0 and 1 or 0)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,"Auto Loot "..(getPlayerStorageValue(cid, info.Storages[1]) > 0 and "Stopped" or "Started")..".") return true
elseif isInArray({"warn","aviso"}, param) then
setPlayerStorageValue(cid, info.Storages[3], getPlayerStorageValue(cid, info.Storages[3]) <= 0 and 1 or 0)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,"Auto Loot Backpack Warn "..(getPlayerStorageValue(cid, info.Storages[3]) > 0 and "disabled" or "Activated")..".") return true
elseif isInArray({"mensagem","message","mensagen","msg"}, param) then
setPlayerStorageValue(cid, info.Storages[6], getPlayerStorageValue(cid, info.Storages[6]) <= 0 and 1 or 0)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,"Auto Loot Message "..(getPlayerStorageValue(cid, info.Storages[6]) > 0 and "disabled" or "Activated")..".") return true
elseif isInArray({"cor","color","type"}, param) then
setPlayerStorageValue(cid, info.Storages[5], getPlayerColorLootMessage(cid) == #Color_Loot and 0 or getPlayerColorLootMessage(cid)+1)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,"Auto Loot Message Color Changed to "..Color_Loot[getPlayerColorLootMessage(cid)][2]..".") return true
elseif isInArray({"money","gold","gps","dinheiro"}, param) then
setPlayerStorageValue(cid, info.Storages[2], getPlayerStorageValue(cid, info.Storages[2]) <= 0 and 1 or 0)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,"[Autoloot] Colteda de gold "..(getPlayerStorageValue(cid, info.Storages[2]) > 0 and "Activated" or "disabled").." Para ativar o deposito direto no bank, ligue o !autoloot deposit.") return true
elseif isInArray({"deposito","bank","gbank","deposit","autodeposit"}, param) then
setPlayerStorageValue(cid, info.Storages[4], getPlayerStorageValue(cid, info.Storages[4]) <= 0 and 1 or 0)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,"[Auto Loot] Automatic Gold Bank "..(getPlayerStorageValue(cid, info.Storages[4]) > 0 and "Activated" or "disabled")..".") return true
end
local item = ExistItemByName(tostring(param))
if exhaustion.get(cid, 101) then
doPlayerSendCancel(cid, 'Espere 10 seconds Para usar o comando novamente.')
return false
end
exhaustion.set(cid, 101, 10)
if not item then
doPlayerSendCancel(cid, "This item does not exist.") return true
end
local item = getItemIdByName(tostring(param))
local var = isInTable(cid, item)
if isInArray(info.Money_ids, item) then
doPlayerSendTextMessage(cid, MESSAGE_FIRST, "Enter !autoloot money to add money in your list!") return true
elseif isInArray(info.BlockItemsList, item) then
doPlayerSendCancel(cid, "You can not add this item in the list!") return true
elseif not var and #getItensFromAutoloot(cid) >= slots then
doPlayerSendCancel(cid, "max "..slots.." from auto loot") return true
elseif getPlayerStorageValue(cid, info.Storages[7]) - os.time() > 0 then
doPlayerSendCancel(cid, "wait a second to use this command again") return true
end
if not var then
doAddItemFromAutoloot(cid, item)
else
doremoveItemFromAutoloot(cid, item)
end
setPlayerStorageValue(cid, info.Storages[7], os.time()+info.Talkaction_delay)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,not var and "you added the item "..param.." in the list" or "you removed the item "..param.." from the list, please wait 5 seconds to save the directory.")
return true]]></talkaction>
</mod>
Pergunta
brendoonh 14
Boa tarde!
Alguém por acaso pode me ajudar caso tenha experiencia .. tenho um sistema de autoloot que coloquei no servidor e inicialmente parecia ta funcionando bem.. coletava os gold, vai direto para o banco e tals..
Fui testar a função de !autoloot golden legs, ao usar este comando buga tudo, e na distro aparece um erro enorme.
Servidor é 8.6 com a distro 0.4
Erro:
[18:24:38.624] [Error - TalkAction Interface]
[18:24:38.629] local cid = 268451737
[18:24:38.630] local words = "!autoloot"
[18:24:38.632] local param = "golden legs"
[18:24:38.634] local channel = 65534
[18:24:38.636] domodlib('Loot_func')
[18:24:38.638] local param, slots = param:lower(), isPremium(cid) and info.Max_Slots.premium or info.Max_Slots.free
[18:24:38.645] if not param or param == "" then
[18:24:38.648] ShowItemsTabble(cid) return true
[18:24:38.651] elseif tonumber(param) then
[18:24:38.653] doPlayerSendCancel(cid, "enter commands: !autoloot item name [+] !autoloot clean [+] !autoloot money [+] !autoloot on/off") return true
[18:24:38.663] elseif isInArray({"clean","limpar", "clear"}, param) then
[18:24:38.666] if existsAutoloot(cid) then doCleanAutoloot(cid) end
[18:24:38.671] doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,"[Auto Loot] Your list has been cleaned.") return true
[18:24:38.677] elseif isInArray({"start","stop","on","off"}, param) then
[18:24:38.680] setPlayerStorageValue(cid, info.Storages[1], getPlayerStorageValue(cid, info.Storages[1]) <= 0 and 1 or 0)
[18:24:38.687] doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,"Auto Loot "..(getPlayerStorageValue(cid, info.Storages[1]) > 0 and "Stopped" or "Started")..".") return true
[18:24:38.696] elseif isInArray({"warn","aviso"}, param) then
[18:24:38.699] setPlayerStorageValue(cid, info.Storages[3], getPlayerStorageValue(cid, info.Storages[3]) <= 0 and 1 or 0)
[18:24:38.707] doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,"Auto Loot Backpack Warn "..(getPlayerStorageValue(cid, info.Storages[3]) > 0 and "disabled" or "Activated")..".") return true
[18:24:38.719] elseif isInArray({"mensagem","message","mensagen","msg"}, param) then
[18:24:38.724] setPlayerStorageValue(cid, info.Storages[6], getPlayerStorageValue(cid, info.Storages[6]) <= 0 and 1 or 0)
[18:24:38.730] doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,"Auto Loot Message "..(getPlayerStorageValue(cid, info.Storages[6]) > 0 and "disabled" or "Activated")..".") return true
[18:24:38.738] elseif isInArray({"cor","color","type"}, param) then
[18:24:38.742] setPlayerStorageValue(cid, info.Storages[5], getPlayerColorLootMessage(cid) == #Color_Loot and 0 or getPlayerColorLootMessage(cid)+1)
[18:24:38.748] doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,"Auto Loot Message Color Changed to "..Color_Loot[getPlayerColorLootMessage(cid)][2]..".") return true
[18:24:38.755] elseif isInArray({"money","gold","gps","dinheiro"}, param) then
[18:24:38.759] setPlayerStorageValue(cid, info.Storages[2], getPlayerStorageValue(cid, info.Storages[2]) <= 0 and 1 or 0)
[18:24:38.764] doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,"[Autoloot] Colteda de gold "..(getPlayerStorageValue(cid, info.Storages[2]) > 0 and "Activated" or "disabled").." Para ativar o deposito direto no bank, ligue o !autoloot deposit.") return true
[18:24:38.776] elseif isInArray({"deposito","bank","gbank","deposit","autodeposit"}, param) then
[18:24:38.782] setPlayerStorageValue(cid, info.Storages[4], getPlayerStorageValue(cid, info.Storages[4]) <= 0 and 1 or 0)
[18:24:38.787] doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,"[Auto Loot] Automatic Gold Bank "..(getPlayerStorageValue(cid, info.Storages[4]) > 0 and "Activated" or "disabled")..".") return true
[18:24:38.795] end
[18:24:38.796] local item = ExistItemByName(tostring(param))
[18:24:38.800] if exhaustion.get(cid, 101) then
[18:24:38.802] doPlayerSendCancel(cid, 'Espere 10 seconds Para usar o comando novamente.')
[18:24:38.805] return false
[18:24:38.807] end
[18:24:38.808] exhaustion.set(cid, 101, 10)
[18:24:38.811] if not item then
[18:24:38.813] doPlayerSendCancel(cid, "This item does not exist.") return true
[18:24:38.816] end
[18:24:38.817] local item = getItemIdByName(tostring(param))
[18:24:38.820] local var = isInTable(cid, item)
[18:24:38.822] if isInArray(info.Money_ids, item) then
[18:24:38.824] doPlayerSendTextMessage(cid, MESSAGE_FIRST, "Enter !autoloot money to add money in your list!") return true
[18:24:38.830] elseif isInArray(info.BlockItemsList, item) then
[18:24:38.833] doPlayerSendCancel(cid, "You can not add this item in the list!") return true
[18:24:38.835] elseif not var and #getItensFromAutoloot(cid) >= slots then
[18:24:38.839] doPlayerSendCancel(cid, "max "..slots.." from auto loot") return true
[18:24:38.842] elseif getPlayerStorageValue(cid, info.Storages[7]) - os.time() > 0 then
[18:24:38.847] doPlayerSendCancel(cid, "wait a second to use this command again") return true
[18:24:38.850] end
[18:24:38.851] if not var then
[18:24:38.853] doAddItemFromAutoloot(cid, item)
[18:24:38.855] else
[18:24:38.856] doremoveItemFromAutoloot(cid, item)
[18:24:38.858] end
[18:24:38.860] setPlayerStorageValue(cid, info.Storages[7], os.time()+info.Talkaction_delay)
[18:24:38.864] doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,not var and "you added the item "..param.." in the list" or "you removed the item "..param.." from the list, please wait 5 seconds to save the directory.")
[18:24:38.872] return true
[18:24:38.873] Description:
[18:24:38.875] [string "info = {..."]:60: attempt to index global 'newFile' (a nil value)
MOD DO AUTOLOOT:
<?xml version="1.0" encoding="ISO-8859-1"?>
<mod name="Perfect Auto Loot" version="1.0" author="Vodkart" contact="none.com" enabled="yes">
<config name="Loot_func"><![CDATA[
info = {
directory = "data/logs/autoloot",
Warn_Bp_Slots = 5, -- quando tiver 5 ou menos slots na BP vai avisar o jogador
Talkaction_delay = 5, -- em segundos // delay para remover e adicionar item
BlockMonsters = {},
BlockItemsList = {2123,2515},
Money_ids = {2148, 2152, 2160}, -- id das moedas do ot
Max_Slots = {free = 3, premium = 3},
Storages = {988801, 988802, 988803, 988804, 988805, 988806, 988807}
}
Color_Loot = {
[0] = {MESSAGE_EVENT_ORANGE, "Orange"},
[1] = {MESSAGE_STATUS_CONSOLE_BLUE, "Blue"},
[2] = {MESSAGE_INFO_DESCR, "Green"},
[3] = {MESSAGE_STATUS_CONSOLE_RED, "Red"},
[4] = {MESSAGE_STATUS_SMALL, "White"}
}
function getPlayerColorLootMessage(cid)
return getPlayerStorageValue(cid, info.Storages[5]) <= 0 and 0 or getPlayerStorageValue(cid, info.Storages[5])
end
function isInTable(cid, item)
for _,i in pairs(getItensFromAutoloot(cid)) do
if tonumber(i) == tonumber(item) then
return true
end
end
return false
end
function doremoveItemFromAutoloot(cid, itemid)
local file, fileContent = io.open(info.directory.."/"..getCreatureName(cid)..".txt", 'r'),{}
for line in file:lines() do
if line ~= "" and tonumber(line) ~= tonumber(itemid) then
fileContent[#fileContent + 1] = line
end
end
io.close(file)
file = io.open(info.directory.."/"..getCreatureName(cid)..".txt", 'w')
for index, value in ipairs(fileContent) do
file:write(value..'\n')
end
io.close(file)
end
function doAddItemFromAutoloot(cid, itemid)
if not existsAutoloot(cid) then
doCreateLootUserName(cid, itemid) return true
end
local file = io.open(info.directory.."/"..getCreatureName(cid)..".txt", "a+")
file:write('\n'..itemid)
file:close()
end
function existsAutoloot(cid)
local f = io.open(info.directory.."/"..getCreatureName(cid)..".txt", "rb")
if f then f:close() end
return f ~= nil
end
function doCreateLootUserName(cid, itemid)
newFile = io.open(info.directory.."/"..getCreatureName(cid)..".txt", "w+" )
newFile:write(itemid)
newFile:close()
end
function getItensFromAutoloot(cid)
if not existsAutoloot(cid) then return {} end
lines = {}
for line in io.lines(info.directory.."/"..getCreatureName(cid)..".txt") do
if line ~= "" then
lines[#lines + 1] = tonumber(line)
end
end
return lines
end
function doCleanAutoloot(cid)
return os.remove(info.directory.."/"..getCreatureName(cid)..".txt")
end
function ShowItemsTabble(cid)
local auto_list = getItensFromAutoloot(cid)
local n,str = 0,"[+] Auto Loot Commands [+]\n\n!autoloot item name --> Para adicionar ou Remover item da lista.\n!autoloot money --> Para coletar Gold automaticamente.\n!autoloot clear --> Para Zerar sua lista.\n!autoloot on/off --> Para habilitar ou desativar a coleta de itens no sistema.\n!autoloot message --> Para ativar ou desativar a mensagem de coletar itens.\n!autoloot color --> Mudar cor da mensagem in Auto Loot Collect.\n!autoloot warn --> Para ativar ou desativar o aviso de mensagem de "..info.Warn_Bp_Slots.." ou menos slots na Backpack.\n!autoloot deposit --> Para habilitar ou desativar o depósito automático em dinheiro no banco.\n\n[+] Auto Loot Info [+]\n\nSystem: "..(getPlayerStorageValue(cid, info.Storages[1]) <= 0 and "Activated" or "Disabled")..".\nGold Collecting: "..(getPlayerStorageValue(cid, info.Storages[2]) > 0 and "Activated" or "Disabled")..".\nMessage: "..(getPlayerStorageValue(cid, info.Storages[6]) <= 0 and "Activated" or "Disabled")..".\nColor Message: "..Color_Loot[getPlayerColorLootMessage(cid)][2]..".\nWarn Backpack: "..(getPlayerStorageValue(cid, info.Storages[3]) <= 0 and "Activated" or "Disabled")..".\nAutomatic Gold Deposit: "..(getPlayerStorageValue(cid, info.Storages[4]) > 0 and "Activated" or "Disabled")..".\nTotal Bank Balance: ["..getPlayerBalance(cid).."]\nMaximum Slots: ["..#auto_list.."/"..(isPremium(cid) and info.Max_Slots.premium or info.Max_Slots.free).."]\n\n[+] Auto Loot Slots [+]\n\n"
if #auto_list > 0 then
for i = 1, #auto_list do
n = n + 1
str = str.."Slot "..n.." - "..getItemNameById(auto_list[i]).."\n"
end
end
return doPlayerPopupFYI(cid, str)
end
function getContainerItems(container, array, haveCap)
array = array or {}
haveCap = haveCap or false
if not isContainer(container.uid) or getContainerSize(container.uid) == 0 then
array[#array +1] = container
else
local size = getContainerSize(container.uid)
haveCap = (getContainerCap(container.uid) -size) > 0
for slot = 0, (size -1) do
local item = getContainerItem(container.uid, slot)
if item.itemid > 1 then
getContainerItems(item, array, haveCap)
end
end
end
return #array >= 1 and array, haveCap
end
function getContainerItemsById(container, itemid)
local founds = {}
local items = not container.uid and container or getContainerItems(container)
for index, item in pairs(items) do
if item.itemid == itemid then
founds[#founds +1] = item
end
end
return #founds >= 1 and founds
end
function AutomaticDeposit(cid, item, n)
local deposit = item == tonumber(2160) and (n*10000) or tonumber(item) == 2152 and (n*100) or (n)
return doPlayerDepositMoney(cid, deposit)
end
function getAllContainerFree(container) -- by vodka
local containers,soma = {},0
for i = 0, getContainerSize(container)-1 do
local item = getContainerItem(container, i)
if isContainer(item.uid) then
table.insert(containers, item.uid)
end
end
for _, check in pairs(containers) do
soma = soma + getContainerSlotsFree(check)
end
return (soma + getContainerSlotsFree(container))
end
function getContainerSlotsFree(container) -- by vodka
return getContainerCap(container)-getContainerSize(container)
end
function doPlayerAddItemStackable(cid, itemid, count)
local container = getPlayerSlotItem(cid, CONST_SLOT_BACKPACK)
if container.itemid > 1 then
local items = getContainerItemsById(container, itemid)
if not items then
return doPlayerAddItem(cid, itemid, count)
else
local piles = #items
for index, item in pairs(items) do
if item.type < 100 then
local sum = item.type + count
local result = doTransformItem(item.uid, itemid, sum)
if sum <= 100 then
return result
else
return doPlayerAddItem(cid, itemid, sum - 100)
end
else
piles = piles - 1
if piles == 0 then
return doPlayerAddItem(cid, itemid, count)
end
end
end
end
end
return false
end
function corpseRetireItems(cid, pos)
local check, slots = false, 0
for i = 0, 255 do
pos.stackpos = i
if getThingFromPos(pos).uid > 0 and isContainer(getThingFromPos(pos).uid) then
corpse = getThingFromPos(pos)
check = true
break
end
end
if check == true then
local str, id_list = "", getItensFromAutoloot(cid)
for _, item in pairs(getContainerItems(corpse)) do
local id = item.itemid
if #id_list > 0 and isInArray(id_list, id) or getPlayerStorageValue(cid, info.Storages[2]) > 0 and isInArray(info.Money_ids, id) then
local amount = isItemStackable(id) and item.type or 1
local total_cap = getItemWeightById(id, amount)
if getPlayerSlotItem(cid, 3).itemid ~= 0 then
slots = getAllContainerFree(getPlayerSlotItem(cid, 3).uid)
end
if slots > 0 and getPlayerFreeCap(cid) >= total_cap then
str = str.." " .. getItemInfoLoot(id, amount)
if isItemStackable(id) then
doPlayerAddItemStackable(cid, id, amount)
if isInArray(info.Money_ids, id) and getPlayerStorageValue(cid, info.Storages[4]) > 0 then
AutomaticDeposit(cid, id, amount)
end
else
doPlayerAddItem(cid, id)
end
doRemoveItem(item.uid)
end
end
end
if str ~= "" and getPlayerStorageValue(cid, info.Storages[6]) <= 0 then
doPlayerSendTextMessage(cid, Color_Loot[getPlayerColorLootMessage(cid)][1],"[Auto Loot Collect]:"..string.sub(str, 1, -2)..".")
end
if getPlayerStorageValue(cid, info.Storages[3]) <= 0 and slots > 0 and slots <= info.Warn_Bp_Slots then
doPlayerSendTextMessage(cid,18, "[Auto Loot Warn] You only have "..slots.." slots free in your backpack!")
end
end
end
function ExistItemByName(name) -- by vodka
local items = io.open("data/items/items.xml", "r"):read("*all")
local get = items:lower():match('name="' .. name:lower() ..'"')
if get == nil or get == "" then
return false
end
return true
end
function getItemInfoLoot(id, amount)
local info = getItemInfo(id)
return isItemStackable(id) and amount.." "..(amount > 1 and info.plural or info.name).."," or info.article.." " .. info.name ..","
end
]]></config>
<event type="login" name="LootLogin" event="script"><![CDATA[
domodlib('Loot_func')
function onLogin(cid)
registerCreatureEvent(cid, "LootEventKIll")
if isPremium(cid) and getPlayerStorageValue(cid, 853608) <= 0 then
setPlayerStorageValue(cid, 853608, 1)
elseif getPlayerStorageValue(cid, 853608) > 0 and not isPremium(cid) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "[Auto Loot] You premium is Over, Start a new list!")
setPlayerStorageValue(cid, 853608, -1)
doCleanAutoloot(cid)
end
return true
end]]></event>
<event type="kill" name="LootEventKIll" event="script"><![CDATA[
domodlib('Loot_func')
function onKill(cid, target, lastHit)
if isPlayer(cid) and getPlayerStorageValue(cid, info.Storages[1]) <= 0 and isMonster(target) and not isInArray(info.BlockMonsters, getCreatureName(target):lower()) then
addEvent(corpseRetireItems, 0, cid ,getThingPos(target))
end
return true
end]]></event>
<talkaction words="!autoloot;/autoloot" event="buffer"><![CDATA[
domodlib('Loot_func')
local param, slots = param:lower(), isPremium(cid) and info.Max_Slots.premium or info.Max_Slots.free
if not param or param == "" then
ShowItemsTabble(cid) return true
elseif tonumber(param) then
doPlayerSendCancel(cid, "enter commands: !autoloot item name [+] !autoloot clean [+] !autoloot money [+] !autoloot on/off") return true
elseif isInArray({"clean","limpar", "clear"}, param) then
if existsAutoloot(cid) then doCleanAutoloot(cid) end
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,"[Auto Loot] Your list has been cleaned.") return true
elseif isInArray({"start","stop","on","off"}, param) then
setPlayerStorageValue(cid, info.Storages[1], getPlayerStorageValue(cid, info.Storages[1]) <= 0 and 1 or 0)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,"Auto Loot "..(getPlayerStorageValue(cid, info.Storages[1]) > 0 and "Stopped" or "Started")..".") return true
elseif isInArray({"warn","aviso"}, param) then
setPlayerStorageValue(cid, info.Storages[3], getPlayerStorageValue(cid, info.Storages[3]) <= 0 and 1 or 0)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,"Auto Loot Backpack Warn "..(getPlayerStorageValue(cid, info.Storages[3]) > 0 and "disabled" or "Activated")..".") return true
elseif isInArray({"mensagem","message","mensagen","msg"}, param) then
setPlayerStorageValue(cid, info.Storages[6], getPlayerStorageValue(cid, info.Storages[6]) <= 0 and 1 or 0)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,"Auto Loot Message "..(getPlayerStorageValue(cid, info.Storages[6]) > 0 and "disabled" or "Activated")..".") return true
elseif isInArray({"cor","color","type"}, param) then
setPlayerStorageValue(cid, info.Storages[5], getPlayerColorLootMessage(cid) == #Color_Loot and 0 or getPlayerColorLootMessage(cid)+1)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,"Auto Loot Message Color Changed to "..Color_Loot[getPlayerColorLootMessage(cid)][2]..".") return true
elseif isInArray({"money","gold","gps","dinheiro"}, param) then
setPlayerStorageValue(cid, info.Storages[2], getPlayerStorageValue(cid, info.Storages[2]) <= 0 and 1 or 0)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,"[Autoloot] Colteda de gold "..(getPlayerStorageValue(cid, info.Storages[2]) > 0 and "Activated" or "disabled").." Para ativar o deposito direto no bank, ligue o !autoloot deposit.") return true
elseif isInArray({"deposito","bank","gbank","deposit","autodeposit"}, param) then
setPlayerStorageValue(cid, info.Storages[4], getPlayerStorageValue(cid, info.Storages[4]) <= 0 and 1 or 0)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,"[Auto Loot] Automatic Gold Bank "..(getPlayerStorageValue(cid, info.Storages[4]) > 0 and "Activated" or "disabled")..".") return true
end
local item = ExistItemByName(tostring(param))
if exhaustion.get(cid, 101) then
doPlayerSendCancel(cid, 'Espere 10 seconds Para usar o comando novamente.')
return false
end
exhaustion.set(cid, 101, 10)
if not item then
doPlayerSendCancel(cid, "This item does not exist.") return true
end
local item = getItemIdByName(tostring(param))
local var = isInTable(cid, item)
if isInArray(info.Money_ids, item) then
doPlayerSendTextMessage(cid, MESSAGE_FIRST, "Enter !autoloot money to add money in your list!") return true
elseif isInArray(info.BlockItemsList, item) then
doPlayerSendCancel(cid, "You can not add this item in the list!") return true
elseif not var and #getItensFromAutoloot(cid) >= slots then
doPlayerSendCancel(cid, "max "..slots.." from auto loot") return true
elseif getPlayerStorageValue(cid, info.Storages[7]) - os.time() > 0 then
doPlayerSendCancel(cid, "wait a second to use this command again") return true
end
if not var then
doAddItemFromAutoloot(cid, item)
else
doremoveItemFromAutoloot(cid, item)
end
setPlayerStorageValue(cid, info.Storages[7], os.time()+info.Talkaction_delay)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,not var and "you added the item "..param.." in the list" or "you removed the item "..param.." from the list, please wait 5 seconds to save the directory.")
return true]]></talkaction>
</mod>
Link para o comentário
Compartilhar em outros sites
0 respostass a esta questão
Posts Recomendados