Ir para conteúdo
  • 0

Adicionar limite


brendoonh

Pergunta

Bom dia...

 

O @Vodk fez uma atualização no sistema de autoloot dele...

Porem, eu queria adicionar uma função, e nao sei como faz...

 

1. Adicionar uma função que colocaria um limite de slot, (poderia adicionar no maximo 3 itens no autoloot)

 

2. Um item que ao clicar nele, adicionaria 2 slot no autoloot, assim sendo possivel adicionar 5 itens!

3. Eu estava notando um autoloto de um outro server, que aparece no server log quando mata o bixo o quanto de gold ele coletou e nesse que o Vodk fez nao aparece teria como adicionar isso tb?

30hpxjm.jpg

OBS:: A prioridade maior é no primeiro pedido, os demais se não tiver como não tem problema.. Agradeço desde já.. REP+ pra quem tiver a boa vontade de ajudar!

 

Mod do autoloot:

 

<?xml version="1.0" encoding="ISO-8859-1"?>

<mod name="Loot System" version="1.0" author="Vodkart And Mkalo" contact="xtibia.com" enabled="yes">
<config name="Loot_func"><![CDATA[
info = {
OnlyPremium = true,
AutomaticDeposit = true,
BlockMonsters = {},
BlockItemsList = {10020,5919,5809,5804,5015}
}
function setPlayerStorageTable(cid, storage, tab)
local tabstr = "&"
for i,x in pairs(tab) do
tabstr = tabstr .. i .. "," .. x .. ";"
end
setPlayerStorageValue(cid, storage, tabstr:sub(1, #tabstr-1))
end
function getPlayerStorageTable(cid, storage)
local tabstr = getPlayerStorageValue(cid, storage)
local tab = {}
if type(tabstr) ~= "string" then
return {}
end
if tabstr:sub(1,1) ~= "&" then
return {}
end
local tabstr = tabstr:sub(2, #tabstr)
local a = string.explode(tabstr, ";")
for i,x in pairs(a) do
local b = string.explode(x, ",")
tab[tonumber(b[1]) or b[1]] = tonumber(b[2]) or b[2]
end
return tab
end
function isInTable(cid, item)
for _,i in pairs(getPlayerStorageTable(cid, 27000))do
if tonumber(i) == tonumber(item) then
return true
end
end
return false
end
function addItemTable(cid, item)
local x = {}
for i = 1,#getPlayerStorageTable(cid, 27000) do
table.insert(x,getPlayerStorageTable(cid, 27000))
end
if x ~= 0 then
table.insert(x,tonumber(item))
setPlayerStorageTable(cid, 27000, x)
else
setPlayerStorageTable(cid, 27000, {item})
end
end
function removeItemTable(cid, item)
local x = {}
for i = 1,#getPlayerStorageTable(cid, 27000) do
table.insert(x,getPlayerStorageTable(cid, 27000))
end
for i,v in ipairs(x) do
if tonumber(v) == tonumber(item) then
table.remove(x,i)
end
end
return setPlayerStorageTable(cid, 27000, x)
end
function ShowItemsTabble(cid)
local str,n = "-- Lista de Loot --\n\n",0
for i = 1,#getPlayerStorageTable(cid, 27000) do
n = n + 1
str = str..""..n.." - "..getItemNameById(getPlayerStorageTable(cid, 27000)).."\n"
end
return doShowTextDialog(cid, 2529, str)
end
function getContainerItems(containeruid)
local items = {}
local containers = {}
if type(getContainerSize(containeruid)) ~= "number" then
return false
end
for slot = 0, getContainerSize(containeruid)-1 do
local item = getContainerItem(containeruid, slot)
if item.itemid == 0 then
break
end
if isContainer(item.uid) then
table.insert(containers, item.uid)
end
table.insert(items, item)
end
if #containers > 0 then
for i,x in ipairs(getContainerItems(containers[1])) do
table.insert(items, x)
end
table.remove(containers, 1)
end
return items
end
function getItemsInContainerById(container, itemid) -- Function By Kydrai
local items = {}
if isContainer(container) and getContainerSize(container) > 0 then
for slot=0, (getContainerSize(container)-1) do
local item = getContainerItem(container, slot)
if isContainer(item.uid) then
local itemsbag = getItemsInContainerById(item.uid, itemid)
for i=0, #itemsbag do
table.insert(items, itemsbag)
end
else
if itemid == item.itemid then
table.insert(items, item.uid)
end
end
end
end
return items
end
function doPlayerAddItemStacking(cid, itemid, quant) -- by mkalo
local item = getItemsInContainerById(getPlayerSlotItem(cid, 3).uid, itemid)
local piles = 0
if #item > 0 then
for i,x in pairs(item) do
if getThing(x).type < 100 then
local it = getThing(x)
doTransformItem(it.uid, itemid, it.type+quant)
if it.type+quant > 100 then
doPlayerAddItem(cid, itemid, it.type+quant-100)
end
else
piles = piles+1
end
end
else
return doPlayerAddItem(cid, itemid, quant)
end
if piles == #item then
doPlayerAddItem(cid, itemid, quant)
end
end
function AutomaticDeposit(cid,item,n)
local deposit = item == tonumber(2160) and (n*10000) or tonumber(item) == 2152 and (n*100) or (n*1)
return doPlayerDepositMoney(cid, deposit)
end
function corpseRetireItems(cid, pos)
local check = false
for i = 0, 255 do
pos.stackpos = i
tile = getTileThingByPos(pos)
if tile.uid > 0 and isCorpse(tile.uid) then
check = true break
end
end
if check == true then
local items = getContainerItems(tile.uid)
for i,x in pairs(items) do
if isInArray(getPlayerStorageTable(cid, 27000), tonumber(x.itemid)) then
if isItemStackable(x.itemid) then
doPlayerAddItemStacking(cid, x.itemid, x.type)
if info.AutomaticDeposit == true and isInArray({"2148","2152","2160"},tonumber(x.itemid)) then
AutomaticDeposit(cid,x.itemid,x.type)
end
else
doPlayerAddItem(cid, x.itemid)
end
doRemoveItem(x.uid)
end
end
end
end
]]></config>
<event type="login" name="LootLogin" event="script"><![CDATA[
function onLogin(cid)
registerCreatureEvent(cid, "MonsterAttack")
return true
end]]></event>
<event type="death" name="LootEventDeath" event="script"><![CDATA[
domodlib('Loot_func')
function onDeath(cid, corpse, deathList)
local killer,pos = deathList[1],getCreaturePosition(cid)
addEvent(corpseRetireItems,1,killer,pos)
return true
end]]></event>
<event type="combat" name="MonsterAttack" event="script"><![CDATA[
domodlib('Loot_func')
if isPlayer(cid) and isMonster(target) and not isInArray(info.BlockMonsters,string.lower(getCreatureName(target))) then
registerCreatureEvent(target, "LootEventDeath")
end
return true]]></event>
<talkaction words="!autoloot;/autoloot" event="buffer"><![CDATA[
domodlib('Loot_func')
local t = string.explode(string.lower(param), ",")
if info.OnlyPremium == true and not isPremium(cid) then
doPlayerSendCancel(cid, "you must be a premium account.") return true
elseif not t[1] then
ShowItemsTabble(cid) return true
elseif tonumber(t[1]) or tonumber(t[2]) then
doPlayerSendCancel(cid, "enter !autoloot add,name or !autoloot remove,name") return true
elseif isInArray({"add","remove"}, tostring(t[1])) then
local func,check = tostring(t[1]) == "add" and addItemTable or removeItemTable, tostring(t[1]) == "add" and true or false
local item = getItemIdByName(tostring(t[2]), false)
if not item then
doPlayerSendCancel(cid, "O item nao existe") return true
elseif check == true and isInArray(info.BlockItemsList, item) then
doPlayerSendCancel(cid, "Esse item nao é permitido a ser adicionado.") return true
elseif isInTable(cid, item) == check then
doPlayerSendCancel(cid, "This Item "..(check == true and "already" or "is not").." in your list.") return true
end
func(cid, item)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,check == true and "Voce adicionou o item "..t[2].." a sua lista" or "Voce removeu o item "..t[2].." from the list") return true
end
return true]]></talkaction>
</mod>

 

Link para o comentário
Compartilhar em outros sites

7 respostass a esta questão

Posts Recomendados

  • 0

Não tive esse problema com os slots infinitos, qualquer coisa faz uma talkaction teste e printa o storage 32149

print(getPlayerStorageValue(cid, 32149))

 

Vai aparecer no console quantos slots o player tem.

 

E o negocio que voce falou das msgs:

<?xml version="1.0" encoding="ISO-8859-1"?>
<mod name="Loot System" version="1.0" author="Vodkart And Mkalo" contact="xtibia.com" enabled="yes">
<config name="Loot_func"><![CDATA[

info = {
OnlyPremium = false,
AutomaticDeposit = true,
BlockMonsters = {},
BlockItemsList = {10020,5919,5809,5804,5015},
maxSlotsStorage = 32149,
defaultMaxSlot = 3, -- deixe false pra desabilitar
itemAddValue = 2, -- vai adicionar 2 slots ao usar o item
coinnames = {"gold coin", "platinum coin", "crystal coin"},
}

function setPlayerStorageTable(cid, storage, tab)
local tabstr = "&"
for i,x in pairs(tab) do
tabstr = tabstr .. i .. "," .. x .. ";"
end
setPlayerStorageValue(cid, storage, tabstr:sub(1, #tabstr-1))
end
function getPlayerStorageTable(cid, storage)
local tabstr = getPlayerStorageValue(cid, storage)
local tab = {}
if type(tabstr) ~= "string" then
return {}
end
if tabstr:sub(1,1) ~= "&" then
return {}
end
local tabstr = tabstr:sub(2, #tabstr)
local a = string.explode(tabstr, ";")
for i,x in pairs(a) do
local b = string.explode(x, ",")
tab[tonumber(b[1]) or b[1]] = tonumber(b[2]) or b[2]
end
return tab
end

function isInTable(cid, item)
for _,i in pairs(getPlayerStorageTable(cid, 27000))do
if tonumber(i) == tonumber(item) then
return true
end
end
return false
end
function addItemTable(cid, item)
local x = {}
for i = 1,#getPlayerStorageTable(cid, 27000) do
table.insert(x,getPlayerStorageTable(cid, 27000)[i])
end
if x ~= 0 then
table.insert(x,tonumber(item))
setPlayerStorageTable(cid, 27000, x)
else
setPlayerStorageTable(cid, 27000, {item})
end
end
function removeItemTable(cid, item)
local x = {}
for i = 1,#getPlayerStorageTable(cid, 27000) do
table.insert(x,getPlayerStorageTable(cid, 27000)[i])
end
for i,v in ipairs(x) do
if tonumber(v) == tonumber(item) then
table.remove(x,i)
end
end
return setPlayerStorageTable(cid, 27000, x)
end
function ShowItemsTabble(cid)
local str,n = "-- Lista de Loot --\n\n",0
for i = 1,#getPlayerStorageTable(cid, 27000) do
n = n + 1
str = str..""..n.." - "..getItemNameById(getPlayerStorageTable(cid, 27000)[i]).."\n"
end
return doShowTextDialog(cid, 2529, str)
end
function getContainerItems(containeruid)
local items = {}
local containers = {}
if type(getContainerSize(containeruid)) ~= "number" then
return false
end
for slot = 0, getContainerSize(containeruid)-1 do
local item = getContainerItem(containeruid, slot)
if item.itemid == 0 then
break
end
if isContainer(item.uid) then
table.insert(containers, item.uid)
end
table.insert(items, item)
end
if #containers > 0 then
for i,x in ipairs(getContainerItems(containers[1])) do
table.insert(items, x)
end
table.remove(containers, 1)
end
return items
end
function getItemsInContainerById(container, itemid) -- Function By Kydrai
local items = {}
if isContainer(container) and getContainerSize(container) > 0 then
for slot=0, (getContainerSize(container)-1) do
local item = getContainerItem(container, slot)
if isContainer(item.uid) then
local itemsbag = getItemsInContainerById(item.uid, itemid)
for i=0, #itemsbag do
table.insert(items, itemsbag[i])
end
else
if itemid == item.itemid then
table.insert(items, item.uid)
end
end
end
end
return items
end
function doPlayerAddItemStacking(cid, itemid, quant) -- by mkalo
local item = getItemsInContainerById(getPlayerSlotItem(cid, 3).uid, itemid)
local piles = 0
if #item > 0 then
for i,x in pairs(item) do
if getThing(x).type < 100 then
local it = getThing(x)
doTransformItem(it.uid, itemid, it.type+quant)
if it.type+quant > 100 then
doPlayerAddItem(cid, itemid, it.type+quant-100)
end
else
piles = piles+1
end
end
else
return doPlayerAddItem(cid, itemid, quant)
end
if piles == #item then
doPlayerAddItem(cid, itemid, quant)
end
end
function AutomaticDeposit(cid,item,n)
local deposit = item == tonumber(2160) and (n*10000) or tonumber(item) == 2152 and (n*100) or (n*1)
doPlayerSendTextMessage(cid, 23, "{AUTO-LOOT} Collected " .. deposit .. " gold coins sent to your bank account.")
return doPlayerDepositMoney(cid, deposit)
end
function corpseRetireItems(cid, pos)
local check = false
for i = 0, 255 do
pos.stackpos = i
tile = getTileThingByPos(pos)
if tile.uid > 0 and isCorpse(tile.uid) then
check = true break
end
end
if check == true then
local items = getContainerItems(tile.uid)
for i,x in pairs(items) do
if isInArray(getPlayerStorageTable(cid, 27000), tonumber(x.itemid)) then
if isItemStackable(x.itemid) then
doPlayerAddItemStacking(cid, x.itemid, x.type)
if info.AutomaticDeposit == true and isInArray({"2148","2152","2160"},tonumber(x.itemid)) then
AutomaticDeposit(cid,x.itemid,x.type)
end
else
doPlayerAddItem(cid, x.itemid)
end
doRemoveItem(x.uid)
end
end
end
end
]]></config>
<event type="login" name="LootLogin" event="script"><![CDATA[
function onLogin(cid)
registerCreatureEvent(cid, "MonsterAttack")
return true
end]]></event>
<event type="death" name="LootEventDeath" event="script"><![CDATA[
domodlib('Loot_func')
function onDeath(cid, corpse, deathList)
local killer,pos = deathList[1],getCreaturePosition(cid)
addEvent(corpseRetireItems,1,killer,pos)
return true
end]]></event>
<event type="combat" name="MonsterAttack" event="script"><![CDATA[
domodlib('Loot_func')
if isPlayer(cid) and isMonster(target) and not isInArray(info.BlockMonsters,string.lower(getCreatureName(target))) then
registerCreatureEvent(target, "LootEventDeath")
end
return true]]></event>
<talkaction words="!autoloot;/autoloot" event="buffer"><![CDATA[
domodlib('Loot_func')
if info.defaultMaxSlot and getPlayerStorageValue(cid, info.maxSlotsStorage) <= 0 then
	setPlayerStorageValue(cid, info.maxSlotsStorage, info.defaultMaxSlot)
end
local t = string.explode(string.lower(param), ",")
local stt = getPlayerStorageTable(cid, 27000)
for i = 1, #info.coinnames do
	local p = table.find(stt, getItemIdByName(info.coinnames[i], false))
	if p then
		table.remove(stt, p)
	end
end
if info.OnlyPremium == true and not isPremium(cid) then
doPlayerSendCancel(cid, "you must be a premium account.") return true
elseif not t[1] then
ShowItemsTabble(cid) return true
elseif t[1] == "clear" then
setPlayerStorageTable(cid, 27000, {})
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Voce removeu todos os items da lista") return true
elseif tonumber(t[1]) or tonumber(t[2]) then
doPlayerSendCancel(cid, "enter !autoloot add,name or !autoloot remove,name") return true
elseif isInArray({"add","remove"}, tostring(t[1])) then
local func,check = tostring(t[1]) == "add" and addItemTable or removeItemTable, tostring(t[1]) == "add" and true or false
local item = getItemIdByName(tostring(t[2]), false)
if t[2] ~= "gold" and not item then
doPlayerSendCancel(cid, "O item nao existe") return true
elseif t[2] ~= "gold" and check == true and isInArray(info.BlockItemsList, item) then
doPlayerSendCancel(cid, "Esse item nao é permitido a ser adicionado.") return true
elseif t[2] ~= "gold" and isInTable(cid, item) == check then
doPlayerSendCancel(cid, "This Item "..(check == true and "already" or "is not").." in your list.") return true
elseif t[2] ~= "gold" and check and info.defaultMaxSlot and #stt >= getPlayerStorageValue(cid, info.maxSlotsStorage) and not table.find(info.coinnames, t[2]) then
doPlayerSendCancel(cid, "You cannot add more than " .. getPlayerStorageValue(cid, info.maxSlotsStorage) .. " items in your list.") return true
end
if t[2] ~= "gold" then
func(cid, item)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,check == true and "Voce adicionou o item "..t[2].." a sua lista" or "Voce removeu o item "..t[2].." from the list") return true
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,check == true and  "Voce ativou a coleta de gold automatica." or "Voce desativou a coleta de gold automatica.")
for i = 1, #info.coinnames do
local item = getItemIdByName(info.coinnames[i], false)
if not item then
error("shit happened. check coin names")
else
if isInTable(cid, item) ~= check then
func(cid, item)
--doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,check == true and "Voce adicionou o item "..info.coinnames[i].." a sua lista" or "Voce removeu o item "..info.coinnames[i].." from the list")
end
end
end
end
end
return true]]></talkaction>
<action itemid="5889" event="buffer"><![CDATA[
	domodlib('Loot_func')
	local s = doPlayerRemoveItem(cid,item.itemid,1)
	if s then
		setPlayerStorageValue(cid, info.maxSlotsStorage, getPlayerStorageValue(cid, info.maxSlotsStorage)+info.itemAddValue)
		doSendAnimatedText(getPlayerPosition(cid), "Boosted" , COLOR_RED)
		doSendMagicEffect(getPlayerPosition(cid), 26)
	else
		doPlayerSendCancel(cid, "Pick up the item first.")
	end
	return true
]]></action>

</mod>

Link para o comentário
Compartilhar em outros sites

  • 0

Substitui por isso, tem os tres pedidos ai, o item que da mais storage voce muda o id la em baixo no final do mod.

<?xml version="1.0" encoding="ISO-8859-1"?>
<mod name="Loot System" version="1.0" author="Vodkart And Mkalo" contact="xtibia.com" enabled="yes">
<config name="Loot_func"><![CDATA[

info = {
OnlyPremium = false,
AutomaticDeposit = true,
BlockMonsters = {},
BlockItemsList = {10020,5919,5809,5804,5015},
maxSlotsStorage = 32149,
defaultMaxSlot = 3, -- deixe false pra desabilitar
itemAddValue = 2, -- vai adicionar 2 slots ao usar o item
}

function setPlayerStorageTable(cid, storage, tab)
local tabstr = "&"
for i,x in pairs(tab) do
tabstr = tabstr .. i .. "," .. x .. ";"
end
setPlayerStorageValue(cid, storage, tabstr:sub(1, #tabstr-1))
end
function getPlayerStorageTable(cid, storage)
local tabstr = getPlayerStorageValue(cid, storage)
local tab = {}
if type(tabstr) ~= "string" then
return {}
end
if tabstr:sub(1,1) ~= "&" then
return {}
end
local tabstr = tabstr:sub(2, #tabstr)
local a = string.explode(tabstr, ";")
for i,x in pairs(a) do
local b = string.explode(x, ",")
tab[tonumber(b[1]) or b[1]] = tonumber(b[2]) or b[2]
end
return tab
end

function isInTable(cid, item)
for _,i in pairs(getPlayerStorageTable(cid, 27000))do
if tonumber(i) == tonumber(item) then
return true
end
end
return false
end
function addItemTable(cid, item)
local x = {}
for i = 1,#getPlayerStorageTable(cid, 27000) do
table.insert(x,getPlayerStorageTable(cid, 27000)[i])
end
if x ~= 0 then
table.insert(x,tonumber(item))
setPlayerStorageTable(cid, 27000, x)
else
setPlayerStorageTable(cid, 27000, {item})
end
end
function removeItemTable(cid, item)
local x = {}
for i = 1,#getPlayerStorageTable(cid, 27000) do
table.insert(x,getPlayerStorageTable(cid, 27000)[i])
end
for i,v in ipairs(x) do
if tonumber(v) == tonumber(item) then
table.remove(x,i)
end
end
return setPlayerStorageTable(cid, 27000, x)
end
function ShowItemsTabble(cid)
local str,n = "-- Lista de Loot --\n\n",0
for i = 1,#getPlayerStorageTable(cid, 27000) do
n = n + 1
str = str..""..n.." - "..getItemNameById(getPlayerStorageTable(cid, 27000)[i]).."\n"
end
return doShowTextDialog(cid, 2529, str)
end
function getContainerItems(containeruid)
local items = {}
local containers = {}
if type(getContainerSize(containeruid)) ~= "number" then
return false
end
for slot = 0, getContainerSize(containeruid)-1 do
local item = getContainerItem(containeruid, slot)
if item.itemid == 0 then
break
end
if isContainer(item.uid) then
table.insert(containers, item.uid)
end
table.insert(items, item)
end
if #containers > 0 then
for i,x in ipairs(getContainerItems(containers[1])) do
table.insert(items, x)
end
table.remove(containers, 1)
end
return items
end
function getItemsInContainerById(container, itemid) -- Function By Kydrai
local items = {}
if isContainer(container) and getContainerSize(container) > 0 then
for slot=0, (getContainerSize(container)-1) do
local item = getContainerItem(container, slot)
if isContainer(item.uid) then
local itemsbag = getItemsInContainerById(item.uid, itemid)
for i=0, #itemsbag do
table.insert(items, itemsbag[i])
end
else
if itemid == item.itemid then
table.insert(items, item.uid)
end
end
end
end
return items
end
function doPlayerAddItemStacking(cid, itemid, quant) -- by mkalo
local item = getItemsInContainerById(getPlayerSlotItem(cid, 3).uid, itemid)
local piles = 0
if #item > 0 then
for i,x in pairs(item) do
if getThing(x).type < 100 then
local it = getThing(x)
doTransformItem(it.uid, itemid, it.type+quant)
if it.type+quant > 100 then
doPlayerAddItem(cid, itemid, it.type+quant-100)
end
else
piles = piles+1
end
end
else
return doPlayerAddItem(cid, itemid, quant)
end
if piles == #item then
doPlayerAddItem(cid, itemid, quant)
end
end
function AutomaticDeposit(cid,item,n)
local deposit = item == tonumber(2160) and (n*10000) or tonumber(item) == 2152 and (n*100) or (n*1)
doPlayerSendTextMessage(cid, 23, "{AUTO-LOOT} Collected " .. deposit .. " gold coins sent to your bank account.")
return doPlayerDepositMoney(cid, deposit)
end
function corpseRetireItems(cid, pos)
local check = false
for i = 0, 255 do
pos.stackpos = i
tile = getTileThingByPos(pos)
if tile.uid > 0 and isCorpse(tile.uid) then
check = true break
end
end
if check == true then
local items = getContainerItems(tile.uid)
for i,x in pairs(items) do
if isInArray(getPlayerStorageTable(cid, 27000), tonumber(x.itemid)) then
if isItemStackable(x.itemid) then
doPlayerAddItemStacking(cid, x.itemid, x.type)
if info.AutomaticDeposit == true and isInArray({"2148","2152","2160"},tonumber(x.itemid)) then
AutomaticDeposit(cid,x.itemid,x.type)
end
else
doPlayerAddItem(cid, x.itemid)
end
doRemoveItem(x.uid)
end
end
end
end
]]></config>
<event type="login" name="LootLogin" event="script"><![CDATA[
function onLogin(cid)
registerCreatureEvent(cid, "MonsterAttack")
return true
end]]></event>
<event type="death" name="LootEventDeath" event="script"><![CDATA[
domodlib('Loot_func')
function onDeath(cid, corpse, deathList)
local killer,pos = deathList[1],getCreaturePosition(cid)
addEvent(corpseRetireItems,1,killer,pos)
return true
end]]></event>
<event type="combat" name="MonsterAttack" event="script"><![CDATA[
domodlib('Loot_func')
if isPlayer(cid) and isMonster(target) and not isInArray(info.BlockMonsters,string.lower(getCreatureName(target))) then
registerCreatureEvent(target, "LootEventDeath")
end
return true]]></event>
<talkaction words="!autoloot;/autoloot" event="buffer"><![CDATA[
domodlib('Loot_func')
if info.defaultMaxSlot and getPlayerStorageValue(cid, info.maxSlotsStorage) <= 0 then
	setPlayerStorageValue(cid, info.maxSlotsStorage, info.defaultMaxSlot)
end
local t = string.explode(string.lower(param), ",")
if info.OnlyPremium == true and not isPremium(cid) then
doPlayerSendCancel(cid, "you must be a premium account.") return true
elseif not t[1] then
ShowItemsTabble(cid) return true
elseif tonumber(t[1]) or tonumber(t[2]) then
doPlayerSendCancel(cid, "enter !autoloot add,name or !autoloot remove,name") return true
elseif isInArray({"add","remove"}, tostring(t[1])) then
local func,check = tostring(t[1]) == "add" and addItemTable or removeItemTable, tostring(t[1]) == "add" and true or false
local item = getItemIdByName(tostring(t[2]), false)
if not item then
doPlayerSendCancel(cid, "O item nao existe") return true
elseif check == true and isInArray(info.BlockItemsList, item) then
doPlayerSendCancel(cid, "Esse item nao é permitido a ser adicionado.") return true
elseif isInTable(cid, item) == check then
doPlayerSendCancel(cid, "This Item "..(check == true and "already" or "is not").." in your list.") return true
elseif check and info.defaultMaxSlot and #getPlayerStorageTable(cid, 27000) >= getPlayerStorageValue(cid, info.maxSlotsStorage) then
doPlayerSendCancel(cid, "You cannot add more than " .. getPlayerStorageValue(cid, info.maxSlotsStorage) .. " items in your list.") return true
end
func(cid, item)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,check == true and "Voce adicionou o item "..t[2].." a sua lista" or "Voce removeu o item "..t[2].." from the list") return true
end
return true]]></talkaction>
<action itemid="5889" event="buffer"><![CDATA[
	domodlib('Loot_func')
	local s = doPlayerRemoveItem(cid,item.itemid,1)
	if s then
		setPlayerStorageValue(cid, info.maxSlotsStorage, getPlayerStorageValue(cid, info.maxSlotsStorage)+info.itemAddValue)
	else
		doPlayerSendCancel(cid, "Pick up the item first.")
	end
	return true
]]></action>

</mod>

Link para o comentário
Compartilhar em outros sites

  • 0

 

Substitui por isso, tem os tres pedidos ai, o item que da mais storage voce muda o id la em baixo no final do mod.

<?xml version="1.0" encoding="ISO-8859-1"?>
<mod name="Loot System" version="1.0" author="Vodkart And Mkalo" contact="xtibia.com" enabled="yes">
<config name="Loot_func"><![CDATA[

info = {
OnlyPremium = false,
AutomaticDeposit = true,
BlockMonsters = {},
BlockItemsList = {10020,5919,5809,5804,5015},
maxSlotsStorage = 32149,
defaultMaxSlot = 3, -- deixe false pra desabilitar
itemAddValue = 2, -- vai adicionar 2 slots ao usar o item
}

function setPlayerStorageTable(cid, storage, tab)
local tabstr = "&"
for i,x in pairs(tab) do
tabstr = tabstr .. i .. "," .. x .. ";"
end
setPlayerStorageValue(cid, storage, tabstr:sub(1, #tabstr-1))
end
function getPlayerStorageTable(cid, storage)
local tabstr = getPlayerStorageValue(cid, storage)
local tab = {}
if type(tabstr) ~= "string" then
return {}
end
if tabstr:sub(1,1) ~= "&" then
return {}
end
local tabstr = tabstr:sub(2, #tabstr)
local a = string.explode(tabstr, ";")
for i,x in pairs(a) do
local b = string.explode(x, ",")
tab[tonumber(b[1]) or b[1]] = tonumber(b[2]) or b[2]
end
return tab
end

function isInTable(cid, item)
for _,i in pairs(getPlayerStorageTable(cid, 27000))do
if tonumber(i) == tonumber(item) then
return true
end
end
return false
end
function addItemTable(cid, item)
local x = {}
for i = 1,#getPlayerStorageTable(cid, 27000) do
table.insert(x,getPlayerStorageTable(cid, 27000)[i])
end
if x ~= 0 then
table.insert(x,tonumber(item))
setPlayerStorageTable(cid, 27000, x)
else
setPlayerStorageTable(cid, 27000, {item})
end
end
function removeItemTable(cid, item)
local x = {}
for i = 1,#getPlayerStorageTable(cid, 27000) do
table.insert(x,getPlayerStorageTable(cid, 27000)[i])
end
for i,v in ipairs(x) do
if tonumber(v) == tonumber(item) then
table.remove(x,i)
end
end
return setPlayerStorageTable(cid, 27000, x)
end
function ShowItemsTabble(cid)
local str,n = "-- Lista de Loot --\n\n",0
for i = 1,#getPlayerStorageTable(cid, 27000) do
n = n + 1
str = str..""..n.." - "..getItemNameById(getPlayerStorageTable(cid, 27000)[i]).."\n"
end
return doShowTextDialog(cid, 2529, str)
end
function getContainerItems(containeruid)
local items = {}
local containers = {}
if type(getContainerSize(containeruid)) ~= "number" then
return false
end
for slot = 0, getContainerSize(containeruid)-1 do
local item = getContainerItem(containeruid, slot)
if item.itemid == 0 then
break
end
if isContainer(item.uid) then
table.insert(containers, item.uid)
end
table.insert(items, item)
end
if #containers > 0 then
for i,x in ipairs(getContainerItems(containers[1])) do
table.insert(items, x)
end
table.remove(containers, 1)
end
return items
end
function getItemsInContainerById(container, itemid) -- Function By Kydrai
local items = {}
if isContainer(container) and getContainerSize(container) > 0 then
for slot=0, (getContainerSize(container)-1) do
local item = getContainerItem(container, slot)
if isContainer(item.uid) then
local itemsbag = getItemsInContainerById(item.uid, itemid)
for i=0, #itemsbag do
table.insert(items, itemsbag[i])
end
else
if itemid == item.itemid then
table.insert(items, item.uid)
end
end
end
end
return items
end
function doPlayerAddItemStacking(cid, itemid, quant) -- by mkalo
local item = getItemsInContainerById(getPlayerSlotItem(cid, 3).uid, itemid)
local piles = 0
if #item > 0 then
for i,x in pairs(item) do
if getThing(x).type < 100 then
local it = getThing(x)
doTransformItem(it.uid, itemid, it.type+quant)
if it.type+quant > 100 then
doPlayerAddItem(cid, itemid, it.type+quant-100)
end
else
piles = piles+1
end
end
else
return doPlayerAddItem(cid, itemid, quant)
end
if piles == #item then
doPlayerAddItem(cid, itemid, quant)
end
end
function AutomaticDeposit(cid,item,n)
local deposit = item == tonumber(2160) and (n*10000) or tonumber(item) == 2152 and (n*100) or (n*1)
doPlayerSendTextMessage(cid, 23, "{AUTO-LOOT} Collected " .. deposit .. " gold coins sent to your bank account.")
return doPlayerDepositMoney(cid, deposit)
end
function corpseRetireItems(cid, pos)
local check = false
for i = 0, 255 do
pos.stackpos = i
tile = getTileThingByPos(pos)
if tile.uid > 0 and isCorpse(tile.uid) then
check = true break
end
end
if check == true then
local items = getContainerItems(tile.uid)
for i,x in pairs(items) do
if isInArray(getPlayerStorageTable(cid, 27000), tonumber(x.itemid)) then
if isItemStackable(x.itemid) then
doPlayerAddItemStacking(cid, x.itemid, x.type)
if info.AutomaticDeposit == true and isInArray({"2148","2152","2160"},tonumber(x.itemid)) then
AutomaticDeposit(cid,x.itemid,x.type)
end
else
doPlayerAddItem(cid, x.itemid)
end
doRemoveItem(x.uid)
end
end
end
end
]]></config>
<event type="login" name="LootLogin" event="script"><![CDATA[
function onLogin(cid)
registerCreatureEvent(cid, "MonsterAttack")
return true
end]]></event>
<event type="death" name="LootEventDeath" event="script"><![CDATA[
domodlib('Loot_func')
function onDeath(cid, corpse, deathList)
local killer,pos = deathList[1],getCreaturePosition(cid)
addEvent(corpseRetireItems,1,killer,pos)
return true
end]]></event>
<event type="combat" name="MonsterAttack" event="script"><![CDATA[
domodlib('Loot_func')
if isPlayer(cid) and isMonster(target) and not isInArray(info.BlockMonsters,string.lower(getCreatureName(target))) then
registerCreatureEvent(target, "LootEventDeath")
end
return true]]></event>
<talkaction words="!autoloot;/autoloot" event="buffer"><![CDATA[
domodlib('Loot_func')
if info.defaultMaxSlot and getPlayerStorageValue(cid, info.maxSlotsStorage) <= 0 then
	setPlayerStorageValue(cid, info.maxSlotsStorage, info.defaultMaxSlot)
end
local t = string.explode(string.lower(param), ",")
if info.OnlyPremium == true and not isPremium(cid) then
doPlayerSendCancel(cid, "you must be a premium account.") return true
elseif not t[1] then
ShowItemsTabble(cid) return true
elseif tonumber(t[1]) or tonumber(t[2]) then
doPlayerSendCancel(cid, "enter !autoloot add,name or !autoloot remove,name") return true
elseif isInArray({"add","remove"}, tostring(t[1])) then
local func,check = tostring(t[1]) == "add" and addItemTable or removeItemTable, tostring(t[1]) == "add" and true or false
local item = getItemIdByName(tostring(t[2]), false)
if not item then
doPlayerSendCancel(cid, "O item nao existe") return true
elseif check == true and isInArray(info.BlockItemsList, item) then
doPlayerSendCancel(cid, "Esse item nao é permitido a ser adicionado.") return true
elseif isInTable(cid, item) == check then
doPlayerSendCancel(cid, "This Item "..(check == true and "already" or "is not").." in your list.") return true
elseif check and info.defaultMaxSlot and #getPlayerStorageTable(cid, 27000) >= getPlayerStorageValue(cid, info.maxSlotsStorage) then
doPlayerSendCancel(cid, "You cannot add more than " .. getPlayerStorageValue(cid, info.maxSlotsStorage) .. " items in your list.") return true
end
func(cid, item)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,check == true and "Voce adicionou o item "..t[2].." a sua lista" or "Voce removeu o item "..t[2].." from the list") return true
end
return true]]></talkaction>
<action itemid="5889" event="buffer"><![CDATA[
	domodlib('Loot_func')
	local s = doPlayerRemoveItem(cid,item.itemid,1)
	if s then
		setPlayerStorageValue(cid, info.maxSlotsStorage, getPlayerStorageValue(cid, info.maxSlotsStorage)+info.itemAddValue)
	else
		doPlayerSendCancel(cid, "Pick up the item first.")
	end
	return true
]]></action>

</mod>

Tudo funcionando perfeitamente, só dei um vacilo te peço desculpa..

Na parte do gold a mensagem aparece como eu mencionei encima, porem pra adicionar conta como 1 slot. Teria como aplicar um comando extra? Por exemplo, !autoloot gold para ativar/desativar esse nao ocuparia um slot.

 

E na hora de ativar o item foi perfeito tambem... Será q teria como por um efeito e uma mini mensagem? por exemplo: Boosted e um efeito /z 26.

 

E tem um comando que remove 1 item né? !autoloot remove,nome do item

Teria como colocar 1 comando que limpa o autoloot todo de uma vez? ex: !autoloot clear

 

Tirando essa falta de atenção na hora do pedido o seu trabalho está perfeito, obrigado !!! REP+++

Link para o comentário
Compartilhar em outros sites

  • 0
Tudo funcionando perfeitamente, só dei um vacilo te peço desculpa.. Na parte do gold a mensagem aparece como eu mencionei encima, porem pra adicionar conta como 1 slot. Teria como aplicar um comando extra? Por exemplo, !autoloot gold para ativar/desativar esse nao ocuparia um slot. E na hora de ativar o item foi perfeito tambem... Será q teria como por um efeito e uma mini mensagem? por exemplo: Boosted e um efeito /z 26. E tem um comando que remove 1 item né? !autoloot remove,nome do item Teria como colocar 1 comando que limpa o autoloot todo de uma vez? ex: !autoloot clear Tirando essa falta de atenção na hora do pedido o seu trabalho está perfeito, obrigado !!! REP+++
<?xml version="1.0" encoding="ISO-8859-1"?>
<mod name="Loot System" version="1.0" author="Vodkart And Mkalo" contact="xtibia.com" enabled="yes">
<config name="Loot_func"><![CDATA[

info = {
OnlyPremium = false,
AutomaticDeposit = true,
BlockMonsters = {},
BlockItemsList = {10020,5919,5809,5804,5015},
maxSlotsStorage = 32149,
defaultMaxSlot = 3, -- deixe false pra desabilitar
itemAddValue = 2, -- vai adicionar 2 slots ao usar o item
coinnames = {"gold coin", "platinum coin", "crystal coin"},
}

function setPlayerStorageTable(cid, storage, tab)
local tabstr = "&"
for i,x in pairs(tab) do
tabstr = tabstr .. i .. "," .. x .. ";"
end
setPlayerStorageValue(cid, storage, tabstr:sub(1, #tabstr-1))
end
function getPlayerStorageTable(cid, storage)
local tabstr = getPlayerStorageValue(cid, storage)
local tab = {}
if type(tabstr) ~= "string" then
return {}
end
if tabstr:sub(1,1) ~= "&" then
return {}
end
local tabstr = tabstr:sub(2, #tabstr)
local a = string.explode(tabstr, ";")
for i,x in pairs(a) do
local b = string.explode(x, ",")
tab[tonumber(b[1]) or b[1]] = tonumber(b[2]) or b[2]
end
return tab
end

function isInTable(cid, item)
for _,i in pairs(getPlayerStorageTable(cid, 27000))do
if tonumber(i) == tonumber(item) then
return true
end
end
return false
end
function addItemTable(cid, item)
local x = {}
for i = 1,#getPlayerStorageTable(cid, 27000) do
table.insert(x,getPlayerStorageTable(cid, 27000)[i])
end
if x ~= 0 then
table.insert(x,tonumber(item))
setPlayerStorageTable(cid, 27000, x)
else
setPlayerStorageTable(cid, 27000, {item})
end
end
function removeItemTable(cid, item)
local x = {}
for i = 1,#getPlayerStorageTable(cid, 27000) do
table.insert(x,getPlayerStorageTable(cid, 27000)[i])
end
for i,v in ipairs(x) do
if tonumber(v) == tonumber(item) then
table.remove(x,i)
end
end
return setPlayerStorageTable(cid, 27000, x)
end
function ShowItemsTabble(cid)
local str,n = "-- Lista de Loot --\n\n",0
for i = 1,#getPlayerStorageTable(cid, 27000) do
n = n + 1
str = str..""..n.." - "..getItemNameById(getPlayerStorageTable(cid, 27000)[i]).."\n"
end
return doShowTextDialog(cid, 2529, str)
end
function getContainerItems(containeruid)
local items = {}
local containers = {}
if type(getContainerSize(containeruid)) ~= "number" then
return false
end
for slot = 0, getContainerSize(containeruid)-1 do
local item = getContainerItem(containeruid, slot)
if item.itemid == 0 then
break
end
if isContainer(item.uid) then
table.insert(containers, item.uid)
end
table.insert(items, item)
end
if #containers > 0 then
for i,x in ipairs(getContainerItems(containers[1])) do
table.insert(items, x)
end
table.remove(containers, 1)
end
return items
end
function getItemsInContainerById(container, itemid) -- Function By Kydrai
local items = {}
if isContainer(container) and getContainerSize(container) > 0 then
for slot=0, (getContainerSize(container)-1) do
local item = getContainerItem(container, slot)
if isContainer(item.uid) then
local itemsbag = getItemsInContainerById(item.uid, itemid)
for i=0, #itemsbag do
table.insert(items, itemsbag[i])
end
else
if itemid == item.itemid then
table.insert(items, item.uid)
end
end
end
end
return items
end
function doPlayerAddItemStacking(cid, itemid, quant) -- by mkalo
local item = getItemsInContainerById(getPlayerSlotItem(cid, 3).uid, itemid)
local piles = 0
if #item > 0 then
for i,x in pairs(item) do
if getThing(x).type < 100 then
local it = getThing(x)
doTransformItem(it.uid, itemid, it.type+quant)
if it.type+quant > 100 then
doPlayerAddItem(cid, itemid, it.type+quant-100)
end
else
piles = piles+1
end
end
else
return doPlayerAddItem(cid, itemid, quant)
end
if piles == #item then
doPlayerAddItem(cid, itemid, quant)
end
end
function AutomaticDeposit(cid,item,n)
local deposit = item == tonumber(2160) and (n*10000) or tonumber(item) == 2152 and (n*100) or (n*1)
doPlayerSendTextMessage(cid, 23, "{AUTO-LOOT} Collected " .. deposit .. " gold coins sent to your bank account.")
return doPlayerDepositMoney(cid, deposit)
end
function corpseRetireItems(cid, pos)
local check = false
for i = 0, 255 do
pos.stackpos = i
tile = getTileThingByPos(pos)
if tile.uid > 0 and isCorpse(tile.uid) then
check = true break
end
end
if check == true then
local items = getContainerItems(tile.uid)
for i,x in pairs(items) do
if isInArray(getPlayerStorageTable(cid, 27000), tonumber(x.itemid)) then
if isItemStackable(x.itemid) then
doPlayerAddItemStacking(cid, x.itemid, x.type)
if info.AutomaticDeposit == true and isInArray({"2148","2152","2160"},tonumber(x.itemid)) then
AutomaticDeposit(cid,x.itemid,x.type)
end
else
doPlayerAddItem(cid, x.itemid)
end
doRemoveItem(x.uid)
end
end
end
end
]]></config>
<event type="login" name="LootLogin" event="script"><![CDATA[
function onLogin(cid)
registerCreatureEvent(cid, "MonsterAttack")
return true
end]]></event>
<event type="death" name="LootEventDeath" event="script"><![CDATA[
domodlib('Loot_func')
function onDeath(cid, corpse, deathList)
local killer,pos = deathList[1],getCreaturePosition(cid)
addEvent(corpseRetireItems,1,killer,pos)
return true
end]]></event>
<event type="combat" name="MonsterAttack" event="script"><![CDATA[
domodlib('Loot_func')
if isPlayer(cid) and isMonster(target) and not isInArray(info.BlockMonsters,string.lower(getCreatureName(target))) then
registerCreatureEvent(target, "LootEventDeath")
end
return true]]></event>
<talkaction words="!autoloot;/autoloot" event="buffer"><![CDATA[
domodlib('Loot_func')
if info.defaultMaxSlot and getPlayerStorageValue(cid, info.maxSlotsStorage) <= 0 then
	setPlayerStorageValue(cid, info.maxSlotsStorage, info.defaultMaxSlot)
end
local t = string.explode(string.lower(param), ",")
local stt = getPlayerStorageTable(cid, 27000)
for i = 1, #info.coinnames do
	local p = table.find(stt, getItemIdByName(info.coinnames[i], false))
	if p then
		table.remove(stt, p)
	end
end
if info.OnlyPremium == true and not isPremium(cid) then
doPlayerSendCancel(cid, "you must be a premium account.") return true
elseif not t[1] then
ShowItemsTabble(cid) return true
elseif t[1] == "clear" then
setPlayerStorageTable(cid, 27000, {})
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Voce removeu todos os items da lista") return true
elseif tonumber(t[1]) or tonumber(t[2]) then
doPlayerSendCancel(cid, "enter !autoloot add,name or !autoloot remove,name") return true
elseif isInArray({"add","remove"}, tostring(t[1])) then
local func,check = tostring(t[1]) == "add" and addItemTable or removeItemTable, tostring(t[1]) == "add" and true or false
local item = getItemIdByName(tostring(t[2]), false)
if t[2] ~= "gold" and not item then
doPlayerSendCancel(cid, "O item nao existe") return true
elseif t[2] ~= "gold" and check == true and isInArray(info.BlockItemsList, item) then
doPlayerSendCancel(cid, "Esse item nao é permitido a ser adicionado.") return true
elseif t[2] ~= "gold" and isInTable(cid, item) == check then
doPlayerSendCancel(cid, "This Item "..(check == true and "already" or "is not").." in your list.") return true
elseif t[2] ~= "gold" and check and info.defaultMaxSlot and #stt >= getPlayerStorageValue(cid, info.maxSlotsStorage) and not table.find(info.coinnames, t[2]) then
doPlayerSendCancel(cid, "You cannot add more than " .. getPlayerStorageValue(cid, info.maxSlotsStorage) .. " items in your list.") return true
end
if t[2] ~= "gold" then
func(cid, item)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,check == true and "Voce adicionou o item "..t[2].." a sua lista" or "Voce removeu o item "..t[2].." from the list") return true
else
for i = 1, #info.coinnames do
local item = getItemIdByName(info.coinnames[i], false)
if not item then
error("shit happened. check coin names")
else
if isInTable(cid, item) ~= check then
func(cid, item)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,check == true and "Voce adicionou o item "..info.coinnames[i].." a sua lista" or "Voce removeu o item "..info.coinnames[i].." from the list")
end
end
end
end
end
return true]]></talkaction>
<action itemid="5889" event="buffer"><![CDATA[
	domodlib('Loot_func')
	local s = doPlayerRemoveItem(cid,item.itemid,1)
	if s then
		setPlayerStorageValue(cid, info.maxSlotsStorage, getPlayerStorageValue(cid, info.maxSlotsStorage)+info.itemAddValue)
		doSendAnimatedText(getPlayerPosition(cid), "Boosted" , COLOR_RED)
		doSendMagicEffect(getPlayerPosition(cid), 26)
	else
		doPlayerSendCancel(cid, "Pick up the item first.")
	end
	return true
]]></action>

</mod>


!autoloot (add/remove), gold -- add/retira todos os items da tabela "coinnames" na lootlist

Os items da tabela não contam slot, ou seja voce pode adicionar eles tres usando o !autoloot add, gold ou um por um que não faz diferença.

 

E mais uma coisa voce deveria botar setPlayerStorageValue(cid, 27000, -1) no login.lua pra evitar bugs, se voce ja estivesse rodando esse script antes em algum server, e na minha opniao resetar a table de loot quando logar é melhor se for fazer alguma modificaçao depois.

Editado por MatheusMkalo
Link para o comentário
Compartilhar em outros sites

  • 0

Parece que quando usa mais de 1 item buga os slots, ficam tipo infinitos...

È possivel deixar para ativar só 1 e ficar permanente?

Ou

Ativar o item por x dias, depois desses x dias os 2 slot que ele ganhou ao clicar do item, iriam sumir...

 

E esse modo de add o gold ficou meio estranho, tipo:

eu falo !autoloot add,gold:

 

23:06 Voce adicionou o item platinum coin a sua lista
23:06 Voce adicionou o item crystal coin a sua lista
Queria um que agente fala, !autoloot gold ai aparece uma mensagem assim:
Você ativou a coleta de gold altomatico..
De resto perfeito, agradeço novamente!!! E desculpe por ser "chato" ...
Link para o comentário
Compartilhar em outros sites

Visitante
Este tópico está impedido de receber novos posts.
×
×
  • Criar Novo...