Ir para conteúdo
  • Cadastre-se

(Resolvido)Error CreatureScript - Item Por Level e Vocação


Ir para solução Resolvido por Danyel Varejao,

Posts Recomendados

Bom pessoal, estou tentando resolver, usei  outros script mais também não obtive sucesso nos planos, o mais completo é esse, e ele até entrega os items, mais logo depois buga, e parece este erro na distro: 

 

dzwg10.png

 

Alguem consegue arrumalo pra mim? Estou usando TFS 0.4.

 

creaturescript/script/VocReward.lua:

Spoiler

local c = {
   [{1,5}] = {
     [13] = {items = {{itemid = 2191, count = 1}, {itemid = 2160, count = 1}}, storage = 40953},
     [19] = {items = {{itemid = 2188, count = 1}, {itemid = 2160, count = 2}}, storage = 40954}
     },
   [{2,6}] = {
     [13] = {items = {{itemid = 2186, count = 1}}, storage = 40953},
     [19] = {items = {{itemid = 2185, count = 1}}, storage = 40954},
     [22] = {items = {{itemid = 8911, count = 1}}, storage = 40955},
     [26] = {items = {{itemid = 2181, count = 1}}, storage = 40956},
     [33] = {items = {{itemid = 2183, count = 1}, {itemid = 2152, count = 25}}, storage = 40957},
     [37] = {items = {{itemid = 8912, count = 1}, {itemid = 2152, count = 50}}, storage = 40958},
     [42] = {items = {{itemid = 8910, count = 1}, {itemid = 2160, count = 1}}, storage = 40959}
   },
   [{3,7}] = {
     [12] = {items = {{itemid = 2389, count = 5}}, storage = 40953},
     [16] = {items = {{itemid = 2389, count = 10}}, storage = 40954},
     [20] = {items = {{itemid = 3965, count = 10}}, storage = 40955},
     [25] = {items = {{itemid = 7378, count = 10}}, storage = 40956},
     [30] = {items = {{itemid = 2456, count = 1}, {itemid = 2544, count = 100}}, storage = 40957},
     [35] = {items = {{itemid = 7364, count = 100}, {itemid = 2152, count = 75}}, storage = 40958},
     [40] = {items = {{itemid = 7365, count = 100}, {itemid = 2160, count = 1}}, storage = 40959}
   },
   [{4,8}] = {
     [15] = {items = {{itemid = 2409, count = 1}}, storage = 40953},
     [30] = {items = {{itemid = 2392, count = 1}, {itemid = 2152, count = 75}}, storage = 40957},
     [40] = {items = {{itemid = 2407, count = 1}, {itemid = 2160, count = 1}}, storage = 40959}
   }
}
function onAdvance(cid, skill, oldlevel, newlevel)
         if skill ~= SKILL__LEVEL then
             return true
         end
         for voc, x in pairs(c) do
             if isInArray(voc, getPlayerVocation(cid)) then
                     for level, z in pairs(x) do
                         if newlevel >= level and getPlayerStorageValue(cid, z.storage) ~= 1 then
                    local text = ""
                    for v = 1, #z.items do
                        count, info = z.items[v].count, getItemInfo(z.items[v].itemid)
                        local ret = ", "
                        if v == 1 then
                            ret = ""
                        elseif v == #z.items then
                            ret = " and "
                        end
                        text = text .. ret
                        text = text .. (count > 1 and count or info.article).." "..(count > 1 and info.plural or info.name)
                        doPlayerAddItem(cid, z.items[v].itemid, z.items[v].count)
                    end
                                 doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Parabens, voce alcancou o level "..level.." e obteve "..text..".")
                                 doSendMagicEffect(getPlayerPosition(cid), CONST_ME_FIREWORK_YELLOW)
                                 setPlayerStorageValue(cid, z.storage, 1)
                         end
                     end
             end
         end
         return true
end

 

creaturescript/script/login.lua:

Spoiler

    registerCreatureEvent(cid, "VocReward")

 

creaturescript/creaturescript.xml:

Spoiler

    <event type="advance" name="VocReward" event="script" value="Item Por Level/VocReward.lua"/>

 

Rep+, obrigado!

 

                                                           

55f6tc.gif                     

Link para o post
Compartilhar em outros sites

@Digoshow não tem diferença, apenas um pouco identado:

Spoiler

local c = {
[{1,5}] = {
  [421] = {items = {{itemid = 2160, count = 1}, {itemid = 2160, count = 2}}, storage = 40953},
  [424] = {items = {{itemid = 2160, count = 1}, {itemid = 2160, count = 2}}, storage = 40954},
  [426] = {items = {{itemid = 2148, count = 1}, {itemid = 2148, count = 2}}, storage = 40955}
  },
[{2,6}] = {
  [13] = {items = {{itemid = 2186, count = 1}}, storage = 40953},
  [19] = {items = {{itemid = 2185, count = 1}}, storage = 40954},
  [22] = {items = {{itemid = 8911, count = 1}}, storage = 40955},
  [26] = {items = {{itemid = 2181, count = 1}}, storage = 40956},
  [33] = {items = {{itemid = 2183, count = 1}, {itemid = 2152, count = 25}}, storage = 40957},
  [37] = {items = {{itemid = 8912, count = 1}, {itemid = 2152, count = 50}}, storage = 40958},
  [42] = {items = {{itemid = 8910, count = 1}, {itemid = 2160, count = 1}}, storage = 40959}
},
[{3,7}] = {
  [12] = {items = {{itemid = 2389, count = 5}}, storage = 40953},
  [16] = {items = {{itemid = 2389, count = 10}}, storage = 40954},
  [20] = {items = {{itemid = 3965, count = 10}}, storage = 40955},
  [25] = {items = {{itemid = 7378, count = 10}}, storage = 40956},
  [30] = {items = {{itemid = 2456, count = 1}, {itemid = 2544, count = 100}}, storage = 40957},
  [35] = {items = {{itemid = 7364, count = 100}, {itemid = 2152, count = 75}}, storage = 40958},
  [40] = {items = {{itemid = 7365, count = 100}, {itemid = 2160, count = 1}}, storage = 40959}
},
[{4,8}] = {
  [15] = {items = {{itemid = 2409, count = 1}}, storage = 40953},
  [30] = {items = {{itemid = 2392, count = 1}, {itemid = 2152, count = 75}}, storage = 40957},
  [40] = {items = {{itemid = 2407, count = 1}, {itemid = 2160, count = 1}}, storage = 40959}
}
}
function onAdvance(cid, skill, oldlevel, newlevel)
 if skill ~= SKILL__LEVEL then
  return true
 end
 
for voc, x in pairs(c) do
 if isInArray(voc, getPlayerVocation(cid)) then
  for level, z in pairs(x) do
   if newlevel >= level and getPlayerStorageValue(cid, z.storage) ~= 1 then
   local text = ""
    for v = 1, #z.items do
    count, info = z.items[v].count, getItemInfo(z.items[v].itemid)
    local ret = ", "
     if v == 1 then
      ret = ""
     elseif v == #z.items then
      ret = " and "
     end
     text = text .. ret
     text = text .. (count > 1 and count or info.article).." "..(count > 1 and info.plural or info.name)
     doPlayerAddItem(cid, z.items[v].itemid, z.items[v].count)
    end
    setPlayerStorageValue(cid, z.storage, 1)
    doSendMagicEffect(getPlayerPosition(cid), CONST_ME_FIREWORK_YELLOW)
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Parabens, voce alcancou o level "..level.." e obteve "..text..".")
   end
  end
 end
end
return true
end

 

 

Testei aqui, e o scripts está funcionando como deveria, o erro no console é devido a outro script, mais precisamente no callback onKill, dando erro nesse callback, retorna erro na morte do monstro/player, no caso do monstro, as vezes pode não retorna o exp.

O erro do script da print está interferindo no funcionamento do script acima.

O erro da print vem de algum mod, desabilite ou conserte, e teste!

 

 

                                                              ezgif-1-98aab239f3.gif.1a897c9c3225228909e7b356a5cfb8e4.gif

Link para o post
Compartilhar em outros sites
5 horas atrás, KotZletY disse:

@Digoshow não tem diferença, apenas um pouco identado:

  Ocultar conteúdo


local c = {
[{1,5}] = {
  [421] = {items = {{itemid = 2160, count = 1}, {itemid = 2160, count = 2}}, storage = 40953},
  [424] = {items = {{itemid = 2160, count = 1}, {itemid = 2160, count = 2}}, storage = 40954},
  [426] = {items = {{itemid = 2148, count = 1}, {itemid = 2148, count = 2}}, storage = 40955}
  },
[{2,6}] = {
  [13] = {items = {{itemid = 2186, count = 1}}, storage = 40953},
  [19] = {items = {{itemid = 2185, count = 1}}, storage = 40954},
  [22] = {items = {{itemid = 8911, count = 1}}, storage = 40955},
  [26] = {items = {{itemid = 2181, count = 1}}, storage = 40956},
  [33] = {items = {{itemid = 2183, count = 1}, {itemid = 2152, count = 25}}, storage = 40957},
  [37] = {items = {{itemid = 8912, count = 1}, {itemid = 2152, count = 50}}, storage = 40958},
  [42] = {items = {{itemid = 8910, count = 1}, {itemid = 2160, count = 1}}, storage = 40959}
},
[{3,7}] = {
  [12] = {items = {{itemid = 2389, count = 5}}, storage = 40953},
  [16] = {items = {{itemid = 2389, count = 10}}, storage = 40954},
  [20] = {items = {{itemid = 3965, count = 10}}, storage = 40955},
  [25] = {items = {{itemid = 7378, count = 10}}, storage = 40956},
  [30] = {items = {{itemid = 2456, count = 1}, {itemid = 2544, count = 100}}, storage = 40957},
  [35] = {items = {{itemid = 7364, count = 100}, {itemid = 2152, count = 75}}, storage = 40958},
  [40] = {items = {{itemid = 7365, count = 100}, {itemid = 2160, count = 1}}, storage = 40959}
},
[{4,8}] = {
  [15] = {items = {{itemid = 2409, count = 1}}, storage = 40953},
  [30] = {items = {{itemid = 2392, count = 1}, {itemid = 2152, count = 75}}, storage = 40957},
  [40] = {items = {{itemid = 2407, count = 1}, {itemid = 2160, count = 1}}, storage = 40959}
}
}
function onAdvance(cid, skill, oldlevel, newlevel)
 if skill ~= SKILL__LEVEL then
  return true
 end
 
for voc, x in pairs(c) do
 if isInArray(voc, getPlayerVocation(cid)) then
  for level, z in pairs(x) do
   if newlevel >= level and getPlayerStorageValue(cid, z.storage) ~= 1 then
   local text = ""
    for v = 1, #z.items do
    count, info = z.items[v].count, getItemInfo(z.items[v].itemid)
    local ret = ", "
     if v == 1 then
      ret = ""
     elseif v == #z.items then
      ret = " and "
     end
     text = text .. ret
     text = text .. (count > 1 and count or info.article).." "..(count > 1 and info.plural or info.name)
     doPlayerAddItem(cid, z.items[v].itemid, z.items[v].count)
    end
    setPlayerStorageValue(cid, z.storage, 1)
    doSendMagicEffect(getPlayerPosition(cid), CONST_ME_FIREWORK_YELLOW)
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Parabens, voce alcancou o level "..level.." e obteve "..text..".")
   end
  end
 end
end
return true
end

 

 

Testei aqui, e o scripts está funcionando como deveria, o erro no console é devido a outro script, mais precisamente no callback onKill, dando erro nesse callback, retorna erro na morte do monstro/player, no caso do monstro, as vezes pode não retorna o exp.

O erro do script da print está interferindo no funcionamento do script acima.

O erro da print vem de algum mod, desabilite ou conserte, e teste!

 

 

Sim, este erro acontece quando eu mato uma criatura, ela fica sem life mais não morre, tipo não muda pra corpse, e o erro aparece na Distro, os unicos mods que tenho é firstitems e autoloot:

 

firstitems:

Spoiler

 

<?xml version="1.0" encoding="UTF-8"?>
<mod name="First Items" version="1.0" author="The Forgotten Server" contact="otland.net" enabled="yes">
<config name="firstitems_config"><![CDATA[
config = {
storage = 30001,
items = {2050}
}
]]></config>
<event type="login" name="FirstItems" event="script"> <![CDATA[
domodlib('firstitems_config')
        
function onLogin(cid)
local config = {
voc_items = {
{ -- SORC
{2190}, -- wand of vortex
{2175}, -- spellbook
{8820}, -- mage hat
{8819}, -- mage robe
{2468} -- studded legs
},
{ -- DRUID
{2182}, -- snakebite rod
{2175}, -- spellbook
{8820}, -- mage hat
{8819}, -- mage robe
{2468} -- studded legs
},
{ -- PALADIN
{2389, 5}, -- Spear
{2456}, -- Bow
{2544, 100}, -- Arrow
{2480}, -- legion helmet
{2660}, -- Ranger's Cloak
{8923} -- Ranger Legs
},
{ -- KNIGHT
{8602}, -- jagged sword
{8601}, -- steel axe
{8602}, -- jagged sword
{2509}, -- steel shield
{2481}, -- soldier helmet
{2478}, -- brass legs
{2465} -- brass armor
}
},
all_items = {
{2661}, -- scarf
{2643} -- leather boots
},
extra_items = {
{2789, 15},
{2120},
{7620, 1},
{7618, 1},
{5710}
},
knight_weapons = {
{2423}, -- clerical mace
{2429} -- barbarian axe
}
}
if getPlayerGroupId(cid) < 3 then
if getPlayerStorageValue(cid, storage) == -1 then
local common = config.voc_items[getPlayerVocation(cid)]
if common ~= nil then
for _, v in ipairs(common) do
doPlayerAddItem(cid, v[1], v[2] or 1)
end
end

local all = config.all_items
if all ~= nil then
for _, v in ipairs(all) do
doPlayerAddItem(cid, v[1], v[2] or 1)
end
end

local extra = config.extra_items
local bp = doPlayerAddItem(cid, 1988, 1)
if extra ~= nil then
for _, v in ipairs(extra) do
doAddContainerItem(bp, v[1], v[2] or 1)
end
end

local weapons = config.knight_weapons
if weapons ~= nil then
for _, w in ipairs(weapons) do
if isKnight(cid) then
doAddContainerItem(bp, w[1], w[2] or 1)
end
end
end

setPlayerStorageValue(cid, storage, 1)
end
end
return true
end
]]></event>
</mod>

 

 

Auto Loot:

Spoiler

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

info = {
    AutomaticDeposit = true,
    BlockMonsters = {'Bazir', 'Annihilon', 'Zugurosh', 'Ushuriel', 'Orshabaal', 'Morgaroth', 'Leviathan', 'Ghazbaran', 'Ferumbras'},
    BlockItemsList = {},
    Max_Slots = {free = 1, premium = 3},
    Storages = {27000,28001,28002}
}
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, info.Storages[1]))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, info.Storages[1]) do
        table.insert(x,getPlayerStorageTable(cid, info.Storages[1]))
    end
    if x ~= 0 then
        table.insert(x,tonumber(item))
        setPlayerStorageTable(cid, info.Storages[1], x)
    else
        setPlayerStorageTable(cid, info.Storages[1], {item})
    end
end
function removeItemTable(cid, item)
    local x = {}
    for i = 1,#getPlayerStorageTable(cid, info.Storages[1]) do
        table.insert(x,getPlayerStorageTable(cid, info.Storages[1]))
    end
    for i,v in ipairs(x) do
        if tonumber(v) == tonumber(item) then
            table.remove(x,i)
        end
    end
    return setPlayerStorageTable(cid, info.Storages[1], x)
end
function ShowItemsTabble(cid)
    local n,str = 0,"[+] Auto Loot Comandos [+]\n\n!autoloot item name --> Para adicionar ou Remover item da lista.\n!autoloot gold --> Para coletar golds automaticamente.\n!autoloot clear --> Para limpar a lista.\n!autoloot on/off --> Para ativar ou desativar a coleta de itens no sistema, se não usar o sistema deixe desativado!\n\n[+] Auto Loot Info [+]\n\nSystem: "..(getPlayerStorageValue(cid, info.Storages[3]) <= 0 and "Activated" or "Disabled")..".\nGold Collecting: "..(getPlayerStorageValue(cid, info.Storages[2]) > 0 and "Activated" or "Disabled")..".\nBalance Total: ["..getPlayerBalance(cid).."] gp's.\nMaximum Slots: ["..#getPlayerStorageTable(cid, info.Storages[1]).."/"..(isPremium(cid) and info.Max_Slots.premium or info.Max_Slots.free).."]\n\n[+] Auto Loot Slots [+]\n\n"
    for i = 1,#getPlayerStorageTable(cid, info.Storages[1]) do
        n = n + 1
        str = str.."Slot "..n.." - "..getItemNameById(getPlayerStorageTable(cid, info.Storages[1])).."\n"
    end
    return doPlayerPopupFYI(cid, 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, amount) -- revisado
    local item, _G = getItemsInContainerById(getPlayerSlotItem(cid, 3).uid, itemid), 0
    if #item > 0 then
        for _ ,x in pairs(item) do
            local ret = getThing(x)
            if ret.type < 100 then
                doTransformItem(ret.uid, itemid, ret.type+amount) 
                if ret.type+amount > 100 then
                    doPlayerAddItem(cid, itemid, ret.type+amount-100)
                end
                break
            else
                _G = _G+1
            end
        end
        if _G == #item then
            doPlayerAddItem(cid, itemid, amount)
        end
    else
        return doPlayerAddItem(cid, itemid, amount)
    end
end
function AutomaticDeposit(cid,item,n)
    local deposit = item == tonumber(9971) and (n*1000000) or tonumber(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, info.Storages[1]), tonumber(x.itemid)) or getPlayerStorageValue(cid, info.Storages[2]) > 0 and isInArray({2148,2152,2160,9971},tonumber(x.itemid)) then
                if isItemStackable(x.itemid) then
                    doPlayerAddItemStacking(cid, x.itemid, x.type)
                    if info.AutomaticDeposit == true and isInArray({2148,2152,2160,9971}, 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, "LootEventKIll")
    if isPremium(cid) and getPlayerStorageValue(cid, 27001) <= 0 then
        setPlayerStorageValue(cid, 27001, 1)
    elseif getPlayerStorageValue(cid, 27001) > 0 and not isPremium(cid) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "[Auto Loot] You premium is Over, Start a new list!")
        setPlayerStorageValue(cid, 27001, -1)
        setPlayerStorageValue(cid, info.Storages[1], -1)
    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[3]) <= 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 gold [+] !autoloot on/off") return true
elseif isInArray({"clean","limpar", "clear"}, param) then
    setPlayerStorageValue(cid, info.Storages[1], -1)
    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[3], getPlayerStorageValue(cid, info.Storages[3]) <= 0 and 1 or 0)
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,"[Auto Loot] "..(getPlayerStorageValue(cid, info.Storages[3]) > 0 and "Stopped" or "Started")..".") 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,"[Auto Loot] Gold Colleting "..(getPlayerStorageValue(cid, info.Storages[2]) > 0 and "Activated" or "disabled")..".") return true
end
local item = getItemIdByName(param, false)
if not item then
    doPlayerSendCancel(cid, "This item does not exist.") return true
end
local var = isInTable(cid, item)
if isInArray({2148,2152,2160,9971},item) then 
    doPlayerSendCancel(cid, "Enter !autoloot gold to add gold 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 #getPlayerStorageTable(cid, info.Storages[1]) >= slots then
    doPlayerSendCancel(cid, "Você ja atingiu o limite de "..slots.." slots, You have already reached the limit of "..slots.." slots") return true
end
if not var then
    addItemTable(cid, item)
else
    removeItemTable(cid, item)
end
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")
return true]]></talkaction>
</mod>

 

 

Ta ae as scripts, eu acho que se for alguma dessa, vai ser mais provavel que seja o autoloot, vou fazer o testes aqui enquanto isso, por enquanto obrigado!

 

                                                           

55f6tc.gif                     

Link para o post
Compartilhar em outros sites

Bom, realemte o problema era com o mod Autoloot, testei sem e o script de dar o Item por Level e Vocação também funcionou perfeitamente, então troquei o script MODs do Autoloot por um outro Creaturescript, porem continua aparecendo este erro de onKill quando eu ligo o comando !autoloot gold ou adiciono algum item pelo comando do autoloot, de uma conferida na distro:

 

5do2gn.png

 

data/creaturescripts/scripts/Autoloot/Auto Loot.lua:

Spoiler

-- Sistema de auto loot por Paulo Victor xZonaah  TK --
local tabela = {}
local function getPlayerList(cid)
    local tab = {}
    if getPlayerStorageValue(cid, 0442002) ~= -1 then
        table.insert(tab, getPlayerStorageValue(cid, 0442002))
    end
    if getPlayerStorageValue(cid, 0442003) ~= -1 then
        table.insert(tab, getPlayerStorageValue(cid, 0442003))
    end
    if getPlayerStorageValue(cid, 0442004) ~= -1 then
        table.insert(tab, getPlayerStorageValue(cid, 0442004))
    end
    if getPlayerStorageValue(cid, 0442005) ~= -1 then
        table.insert(tab, getPlayerStorageValue(cid, 0442005))
    end
    if #tab > 0 then
        return tab
    end
    return false
end
local function autoLoot(cid, pos)
    local check = false
    local str = ""
    local position = {}
    for i = 1, 255 do
        pos.stackpos = i
        if getThingFromPos(pos).uid and getThingFromPos(pos).uid > 0 and isContainer(getThingFromPos(pos).uid) then
            position = pos
            check = true
            break
        end
    end
    if check then
        local corpse = getContainerItemsInfo(getThingFromPos(position).uid)        
        if corpse then
            for index, info in pairs(corpse) do
                if index < countTable(corpse) then
                        if tonumber(info.uid) and tonumber(info.itemid) then
                        if isContainer(info.uid) then
                            local bag = getContainerItemsInfo(info.uid)
                            for i = 1, countTable(bag) - 1 do
                                if isInArray(getPlayerList(cid), bag.itemid) then
                                    if bag.quant > 1 then
                                        doRemoveItem(bag.uid, bag.quant)
                                        doPlayerAddItem(cid, bag.itemid, bag.quant)
                                        str = str.." "..bag.quant.." "..getItemNameById(bag.itemid)..","
                                    else
                                        doRemoveItem(bag.uid)
                                        doPlayerAddItem(cid, bag.itemid, 1)
                                        str = str.." 1 "..getItemNameById(bag.itemid)..","
                                    end
                                end
                            end
                        end
                    end
                end
                if isInArray(getPlayerList(cid), info.itemid) then
                    if info.quant > 1 then
                        doRemoveItem(info.uid, info.quant)
                        doPlayerAddItem(cid, info.itemid, info.quant)
                        str = str.." "..info.quant.." "..getItemNameById(info.itemid)..","
                    else
                        doRemoveItem(info.uid)
                        doPlayerAddItem(cid, info.itemid, 1)
                        str = str.." 1 "..getItemNameById(info.itemid)..","
                    end
                end
            end
        end
    end
    tabela[getCreatureName(cid)] = {item = "[Zona Loot] Coletados: "..str, gold = 0}
end
local function autoGold(cid, pos)
    local check = false
    local total = 0
    local position = {}
    for i = 1, 255 do
        pos.stackpos = i
        if getThingFromPos(pos).uid and getThingFromPos(pos).uid > 0 and isContainer(getThingFromPos(pos).uid) then
            position = pos
            check = true
            break
        end
    end
    if check then
        local corpse = getContainerItemsInfo(getThingFromPos(position).uid)
        if corpse then
            for index, info in pairs(corpse) do
                if info.uid and info.itemid then
                    if index < countTable(corpse) then
                        if isContainer(info.uid) then
                            local bag = getContainerItemsInfo(info.uid)
                            for i = 1, countTable(bag) - 1 do
                                if isInArray({2148, 2152, 2160}, bag.itemid) then
                                    local multiplie = 1
                                    if bag.itemid == 2148 then
                                        multiplie = 1
                                    elseif bag.itemid == 2152 then
                                        multiplie = 100
                                    elseif bag.itemid == 2160 then
                                        multiplie = 10000
                                    end
                                    doRemoveItem(bag.uid, bag.quant)
                                    doPlayerSetBalance(cid, getPlayerBalance(cid) + (tonumber(bag.quant) and tonumber(bag.quant) * multiplie or 0))
                                    total = total + (tonumber(bag.quant) and tonumber(bag.quant) * multiplie or 0)
                                    doPlayerSetStorageValue(cid, 0442102, getPlayerStorageZero(cid, 0442102) + (tonumber(bag.quant) and tonumber(bag.quant) * multiplie or 0))
                                end
                            end
                        end
                    end
                    if isInArray({2148, 2152, 2160}, info.itemid) then
                        local multiplie = 1
                        if info.itemid == 2148 then
                            multiplie = 1
                        elseif info.itemid == 2152 then
                            multiplie = 100
                        elseif info.itemid == 2160 then
                            multiplie = 10000
                        end
    doRemoveItem(info.uid, info.quant)
                        doPlayerSetBalance(cid, getPlayerBalance(cid) + (tonumber(info.quant) and tonumber(info.quant) * tonumber(multiplie) or 0))
                        doPlayerSetStorageValue(cid, 0442102, getPlayerStorageZero(cid, 0442102) + (tonumber(info.quant) and tonumber(info.quant) * tonumber(multiplie) or 0))
                        total = total + (tonumber(info.quant) and tonumber(info.quant) * multiplie or 0)
                    end
                end
            end
        end
    end
    if tabela[getCreatureName(cid)] and tabela[getCreatureName(cid)].gold then
        tabela[getCreatureName(cid)].gold = total
    end
end
local function sendMsg(cid)
    if tabela[getCreatureName(cid)] and tabela[getCreatureName(cid)].gold then
        if tabela[getCreatureName(cid)].gold == 0 then
            doPlayerSendTextMessage(cid, 23, tabela[getCreatureName(cid)].item)
        else
            doPlayerSendTextMessage(cid, 23, tabela[getCreatureName(cid)].item.." "..tabela[getCreatureName(cid)].gold.." gold coins.")
        end
        tabela[getCreatureName(cid)] = nil
    end
end
function onKill(cid, target, lastHit)
    if isPlayer(cid) and isMonster(target) then
        if getPlayerStorageValue(cid, 0442100) == 1 and getPlayerList(cid) then
            local pos = getCreaturePosition(target)
            addEvent(autoLoot, 500, cid, pos)
        end
        if getPlayerStorageValue(cid, 0442101) == 1 then
            local pos = getCreaturePosition(target)
            addEvent(autoGold, 500, cid, pos)
        end
        if getPlayerStorageValue(cid, 0442100) == 1 or getPlayerStorageValue(cid, 0442101) == 1 then
            addEvent(sendMsg, 540, cid)
        end
    end
    return true
end

 

O que você me diz? Teria como resolver este problema mantendo o script de dar os items?

Editado por Digoshow (veja o histórico de edições)

 

                                                           

55f6tc.gif                     

Link para o post
Compartilhar em outros sites

Continuo com problema, alguem sabe alguma solução para este problema? @UP

 

                                                           

55f6tc.gif                     

Link para o post
Compartilhar em outros sites

@UP

 

                                                           

55f6tc.gif                     

Link para o post
Compartilhar em outros sites

Olá, coloca isso na sua lib 050-function.

 

function 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, quant = Item.type}
        end
        return Table
    end
    return false
end

 

Link para o post
Compartilhar em outros sites
9 horas atrás, Danyel Varejao disse:

Olá, coloca isso na sua lib 050-function.

 


function 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, quant = Item.type}
        end
        return Table
    end
    return false
end

 

Amigo, o que isso ae faz exatamente? hehehe

Bom eu coloquei e o problema continua

 

Imagem do Erro na Distro:

2e1zorn.png

 

creaturescript/script/Autoloot/Auto Loot.lua:

Spoiler

-- Sistema de auto loot por Paulo Victor xZonaah  TK --
local tabela = {}
local function getPlayerList(cid)
    local tab = {}
    if getPlayerStorageValue(cid, 0442002) ~= -1 then
        table.insert(tab, getPlayerStorageValue(cid, 0442002))
    end
    if getPlayerStorageValue(cid, 0442003) ~= -1 then
        table.insert(tab, getPlayerStorageValue(cid, 0442003))
    end
    if getPlayerStorageValue(cid, 0442004) ~= -1 then
        table.insert(tab, getPlayerStorageValue(cid, 0442004))
    end
    if getPlayerStorageValue(cid, 0442005) ~= -1 then
        table.insert(tab, getPlayerStorageValue(cid, 0442005))
    end
    if #tab > 0 then
        return tab
    end
    return false
end
local function autoLoot(cid, pos)
    local check = false
    local str = ""
    local position = {}
    for i = 1, 255 do
        pos.stackpos = i
        if getThingFromPos(pos).uid and getThingFromPos(pos).uid > 0 and isContainer(getThingFromPos(pos).uid) then
            position = pos
            check = true
            break
        end
    end
    if check then
        local corpse = getContainerItemsInfo(getThingFromPos(position).uid)        
        if corpse then
            for index, info in pairs(corpse) do
                if index < countTable(corpse) then
                        if tonumber(info.uid) and tonumber(info.itemid) then
                        if isContainer(info.uid) then
                            local bag = getContainerItemsInfo(info.uid)
                            for i = 1, countTable(bag) - 1 do
                                if isInArray(getPlayerList(cid), bag.itemid) then
                                    if bag.quant > 1 then
                                        doRemoveItem(bag.uid, bag.quant)
                                        doPlayerAddItem(cid, bag.itemid, bag.quant)
                                        str = str.." "..bag.quant.." "..getItemNameById(bag.itemid)..","
                                    else
                                        doRemoveItem(bag.uid)
                                        doPlayerAddItem(cid, bag.itemid, 1)
                                        str = str.." 1 "..getItemNameById(bag.itemid)..","
                                    end
                                end
                            end
                        end
                    end
                end
                if isInArray(getPlayerList(cid), info.itemid) then
                    if info.quant > 1 then
                        doRemoveItem(info.uid, info.quant)
                        doPlayerAddItem(cid, info.itemid, info.quant)
                        str = str.." "..info.quant.." "..getItemNameById(info.itemid)..","
                    else
                        doRemoveItem(info.uid)
                        doPlayerAddItem(cid, info.itemid, 1)
                        str = str.." 1 "..getItemNameById(info.itemid)..","
                    end
                end
            end
        end
    end
    tabela[getCreatureName(cid)] = {item = "[Zona Loot] Coletados: "..str, gold = 0}
end
local function autoGold(cid, pos)
    local check = false
    local total = 0
    local position = {}
    for i = 1, 255 do
        pos.stackpos = i
        if getThingFromPos(pos).uid and getThingFromPos(pos).uid > 0 and isContainer(getThingFromPos(pos).uid) then
            position = pos
            check = true
            break
        end
    end
    if check then
        local corpse = getContainerItemsInfo(getThingFromPos(position).uid)
        if corpse then
            for index, info in pairs(corpse) do
                if info.uid and info.itemid then
                    if index < countTable(corpse) then
                        if isContainer(info.uid) then
                            local bag = getContainerItemsInfo(info.uid)
                            for i = 1, countTable(bag) - 1 do
                                if isInArray({2148, 2152, 2160}, bag.itemid) then
                                    local multiplie = 1
                                    if bag.itemid == 2148 then
                                        multiplie = 1
                                    elseif bag.itemid == 2152 then
                                        multiplie = 100
                                    elseif bag.itemid == 2160 then
                                        multiplie = 10000
                                    end
                                    doRemoveItem(bag.uid, bag.quant)
                                    doPlayerSetBalance(cid, getPlayerBalance(cid) + (tonumber(bag.quant) and tonumber(bag.quant) * multiplie or 0))
                                    total = total + (tonumber(bag.quant) and tonumber(bag.quant) * multiplie or 0)
                                    doPlayerSetStorageValue(cid, 0442102, getPlayerStorageZero(cid, 0442102) + (tonumber(bag.quant) and tonumber(bag.quant) * multiplie or 0))
                                end
                            end
                        end
                    end
                    if isInArray({2148, 2152, 2160}, info.itemid) then
                        local multiplie = 1
                        if info.itemid == 2148 then
                            multiplie = 1
                        elseif info.itemid == 2152 then
                            multiplie = 100
                        elseif info.itemid == 2160 then
                            multiplie = 10000
                        end
    doRemoveItem(info.uid, info.quant)
                        doPlayerSetBalance(cid, getPlayerBalance(cid) + (tonumber(info.quant) and tonumber(info.quant) * tonumber(multiplie) or 0))
                        doPlayerSetStorageValue(cid, 0442102, getPlayerStorageZero(cid, 0442102) + (tonumber(info.quant) and tonumber(info.quant) * tonumber(multiplie) or 0))
                        total = total + (tonumber(info.quant) and tonumber(info.quant) * multiplie or 0)
                    end
                end
            end
        end
    end
    if tabela[getCreatureName(cid)] and tabela[getCreatureName(cid)].gold then
        tabela[getCreatureName(cid)].gold = total
    end
end
local function sendMsg(cid)
    if tabela[getCreatureName(cid)] and tabela[getCreatureName(cid)].gold then
        if tabela[getCreatureName(cid)].gold == 0 then
            doPlayerSendTextMessage(cid, 23, tabela[getCreatureName(cid)].item)
        else
            doPlayerSendTextMessage(cid, 23, tabela[getCreatureName(cid)].item.." "..tabela[getCreatureName(cid)].gold.." gold coins.")
        end
        tabela[getCreatureName(cid)] = nil
    end
end
function onKill(cid, target, lastHit)
    if isPlayer(cid) and isMonster(target) then
        if getPlayerStorageValue(cid, 0442100) == 1 and getPlayerList(cid) then
            local pos = getCreaturePosition(target)
            addEvent(autoLoot, 500, cid, pos)
        end
        if getPlayerStorageValue(cid, 0442101) == 1 then
            local pos = getCreaturePosition(target)
            addEvent(autoGold, 500, cid, pos)
        end
        if getPlayerStorageValue(cid, 0442100) == 1 or getPlayerStorageValue(cid, 0442101) == 1 then
            addEvent(sendMsg, 540, cid)
        end
    end
    return true
end

 

creaturescript/creaturescript.xml:

Citar

    <event type="kill" name="Auto Loot" event="script" value="Autoloot/Auto Loot.lua"/>

 

O problema está "eu acho" na linha 74 e 91 pelo que eu entendi na Distro!

Editado por Digoshow (veja o histórico de edições)

 

                                                           

55f6tc.gif                     

Link para o post
Compartilhar em outros sites
  • Solução

Isso é um sistema de autoloot...

Certo, o erro mudou agr coloca isso daqui na mesma lib:

 

function countTable(table)
    local y = 0
    if type(table) == "table" then
        for _ in pairs(table) do
            y = y + 1
        end
        return y
    end
    return false
end

 

Link para o post
Compartilhar em outros sites
7 minutos atrás, Danyel Varejao disse:

Isso é um sistema de autoloot...

Certo, o erro mudou agr coloca isso daqui na mesma lib:

 


function countTable(table)
    local y = 0
    if type(table) == "table" then
        for _ in pairs(table) do
            y = y + 1
        end
        return y
    end
    return false
end

 

O erro agora sumiu da Distro, porem ele não pega nada, mesmo adicionando o item ou ativando o autoloot gold ;/

 

                                                           

55f6tc.gif                     

Link para o post
Compartilhar em outros sites
8 minutos atrás, Danyel Varejao disse:

Posta seu creaturescripts.xml e seu login.lua ai por favor.

 

data\creaturescripts\scripts\Autoloot\Auto Loot.lua

Spoiler

local aloot_boost = {[2406] = 36, [2537] = 4800, [2377] = 480, [2663] = 600, [2472] = 195000, [2398] = 36, [2475] = 7200, [2519] = 6500, [2497] = 10700, [2523] = 180000, [2494] = 325000, [2400] = 144000, [2491] = 6000, [2421] = 325000, [2646] = 260000, [2477] = 7200, [2413] = 84, [2656] = 18000, [2498] = 52000, [2647] = 600, [2534] = 32500, [7402] = 19500, [2466] = 26000, [2465] = 240, [2408] = 120000, [2518] = 1800, [2500] = 3000, [2376] = 30, [2470] = 91000, [2388] = 24, [2645] = 26000, [2434] = 2400, [2463] = 480, [2536] = 11700, [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, [7382] = 13000, [2462] = 1300, [2520] = 39000, [2390] = 180000, [2417] = 72, [2436] = 1200, [5741] = 52000, [2378] = 120, [2487] = 24000, [2476] = 6500, [8891] = 36000, [2459] = 36, [2195] = 52000, [2391] = 7200, [2464] = 120, [8889] = 72000, [2432] = 13000, [2431] = 108000, [2492] = 52000, [2515] = 240, [2430] = 2400, [2393] = 13000, [7419] = 36000, [2522] = 130000, [2514] = 65000}

local function getPlayerStorageZero(cid, storage) -- By Killua
    local sto = getPlayerStorageValue(cid, storage)
    if tonumber(sto) then
        return tonumber(sto) > tonumber(0) and tonumber(sto) or tonumber(0)
    end
    return tonumber(0)
end

local tabela = {}

local function getPlayerList(cid)
    local tab = {}
    if getPlayerStorageValue(cid, 04420021) ~= -1 then
        table.insert(tab, getPlayerStorageValue(cid, 04420021))
    end
    if getPlayerStorageValue(cid, 04420031) ~= -1 then
        table.insert(tab, getPlayerStorageValue(cid, 04420031))
    end
    if getPlayerStorageValue(cid, 04420041) ~= -1 then
        table.insert(tab, getPlayerStorageValue(cid, 04420041))
    end
    if getPlayerStorageValue(cid, 04420051) ~= -1 then
        table.insert(tab, getPlayerStorageValue(cid, 04420051))
    end
    if #tab > 0 then
        return tab
    end
    return {}
end

local function boost(cid)
    return tonumber(getPlayerStorageValue(cid,722381)) >= os.time()
end

local function autoLoot(cid, pos)
    if not isPlayer(cid) then return end
    local check = false
    local str = ""
    local position = {}
    for i = 1, 255 do
        pos.stackpos = i
        if getThingFromPos(pos).uid and getThingFromPos(pos).uid > 0 and isContainer(getThingFromPos(pos).uid) then
            position = pos
            check = true
            break
        end
    end
    if check then
        local corpse = getContainerItemsInfo(getThingFromPos(position).uid)        
        if corpse then
            for index, info in pairs(corpse) do
                if index < countTable(corpse) then
                    if info.uid and info.itemid then
                        if isContainer(info.uid) then
                            local bag = getContainerItemsInfo(info.uid)
                            for i = 1, countTable(bag) do
                                if isInArray(getPlayerList(cid), bag.itemid) then
                                    if bag.quant > 1 then
                                        doRemoveItem(bag.uid, bag.quant)
                                        doPlayerAddItem(cid, bag.itemid, bag.quant)
                                        str = str.." "..bag.quant.." "..getItemNameById(bag.itemid).." +"
                                    else
                                        doRemoveItem(bag.uid)
                                        if boost(cid) then
                                            if aloot_boost[bag.itemid] then
                                                doPlayerSetBalance(cid,getPlayerBalance(cid) + aloot_boost[bag.itemid])
                                                str = str.." 1 "..getItemNameById(bag.itemid).." ("..aloot_boost[bag.itemid].."gp no banco) +"
                                            else
                                                doPlayerAddItem(cid, bag.itemid, 1)
                                                str = str.." 1 "..getItemNameById(bag.itemid).." +"
                                            end
                                        else
                                            doPlayerAddItem(cid, bag.itemid, 1)
                                            str = str.." 1 "..getItemNameById(bag.itemid).." +"
                                        end
                                    end
                                end
                            end
                        end
                    end
                end
                if isInArray(getPlayerList(cid), info.itemid) then
                    if info.quant > 1 then
                        doRemoveItem(info.uid, info.quant)
                        doPlayerAddItem(cid, info.itemid, info.quant)
                        str = str.." "..info.quant.." "..getItemNameById(info.itemid).." +"
                    else
                        doRemoveItem(info.uid)
                        if boost(cid) then
                            if aloot_boost[info.itemid] then
                                doPlayerSetBalance(cid,getPlayerBalance(cid) + aloot_boost[info.itemid])
                                str = str.." 1 "..getItemNameById(info.itemid).." ("..aloot_boost[info.itemid].."gps no banco) +"
                            else
                                doPlayerAddItem(cid, info.itemid, 1)
                                str = str.." 1 "..getItemNameById(info.itemid).." +"
                            end
                        else
                            doPlayerAddItem(cid, info.itemid, 1)
                            str = str.." 1 "..getItemNameById(info.itemid).." +"
                        end
                    end
                end
            end
        end
    end
    setPlayerTableStorage(cid,822564,{[1] = str, [2] = 0})
end

local function autoGold(cid, pos)
    if not isPlayer(cid) then return end
    local check = false
    local total = 0
    local position = {}
    for i = 1, 255 do
        pos.stackpos = i
        if getThingFromPos(pos).uid and getThingFromPos(pos).uid > 0 and isContainer(getThingFromPos(pos).uid) then
            position = pos
            check = true
            break
        end
    end
    if check then
        local corpse = getContainerItemsInfo(getThingFromPos(position).uid)
        if corpse then
            for index, info in pairs(corpse) do
                if info.uid and info.itemid then
                    if index < countTable(corpse) then
                        if isContainer(info.uid) then
                            local bag = getContainerItemsInfo(info.uid)
                            for i = 1, countTable(bag) do
                                if isInArray({2148, 2152, 2160}, bag.itemid) then
                                    local multiplie = 1
                                    if bag.itemid == 2148 then
                                        multiplie = 1
                                    elseif bag.itemid == 2152 then
                                        multiplie = 100
                                    elseif bag.itemid == 2160 then
                                        multiplie = 10000
                                    end
                                    doRemoveItem(bag.uid, bag.quant)
                                    doPlayerSetBalance(cid, getPlayerBalance(cid) + tonumber(bag.quant) * multiplie)
                                    total = total + bag.quant * multiplie
                                    doPlayerSetStorageValue(cid, 04421021, tonumber(getPlayerStorageZero(cid, 04421021)) + tonumber(info.quant) * tonumber(multiplie))
                                end
                            end
                        end
                    end
                    if isInArray({2148, 2152, 2160}, info.itemid) then
                        local multiplie = 1
                        if info.itemid == 2148 then
                            multiplie = 1
                        elseif info.itemid == 2152 then
                            multiplie = 100
                        elseif info.itemid == 2160 then
                            multiplie = 10000
                        end
                        doRemoveItem(info.uid, info.quant)
                        doPlayerSetBalance(cid, getPlayerBalance(cid) + info.quant * multiplie)
                        doPlayerSetStorageValue(cid, 04421021, tonumber(getPlayerStorageZero(cid, 04421021)) + tonumber(info.quant) * tonumber(multiplie))
                        total = total + info.quant * multiplie
                    end
                end
            end
        end
    end
    if total > 0 then
        total = total - (total * 0.2) 
        total = math.ceil(total)
        doPlayerSetBalance(cid,getPlayerBalance(cid) + total)
        local tab = getPlayerTableStorage(cid,822564)
        tab[2] = total
        setPlayerTableStorage(cid,822564,tab)
    end
end

local function sendMsg(cid)
    if not isPlayer(cid) then return end
    local tab = getPlayerTableStorage(cid,822564)
    if countTable(tab) >= 1 then
        if tab[1] then
            if tab[2] and tab[2] > 0 then
                doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "[Auto Loot System] Coletados: ".. tab[1] .." ".. tab[2] .." gold coins.")
            else
                if type(tab[1]) == "string" and string.len(tab[1]) > 1 then
                    doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "[Auto Loot System] Coletados: "..tab[1])
                end
            end
        elseif not tab[1] then
            if tab[2] then
                doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "[Auto Loot System] Coletados: "..tab[2].." gold coins.")
            end
        end
    end
    doPlayerSetStorageValue(cid,822564,-1)
end

function onKill(cid, target, lastHit)
    if isPlayer(cid) and isMonster(target) then
        if getPlayerStorageValue(cid, 04421001) == 1 and #getPlayerList(cid) > 0 then
            local pos = getCreaturePosition(target)
            addEvent(autoLoot, 500, cid, pos)
        end
        if getPlayerStorageValue(cid, 04421011) == 1 then
            local pos = getCreaturePosition(target)
            addEvent(autoGold, 540, cid, pos)
        end
        if getPlayerStorageValue(cid, 04421001) == 1 or getPlayerStorageValue(cid, 04421011) == 1 then
            addEvent(sendMsg, 560, cid)
        end
    end
    return true
end

 

data\creaturescripts\scripts\Login.lua

Citar

    registerCreatureEvent(cid, "autoloot")
    registerCreatureEvent(cid, "Auto Loot")

 

data\creaturescripts\creaturescripts.xml

Citar

    <!-- Auto Loot  -->
    <event type="kill" name="autoloot" event="script" value="Autoloot/Auto Loot.lua"/>

 

Editado por Digoshow (veja o histórico de edições)

 

                                                           

55f6tc.gif                     

Link para o post
Compartilhar em outros sites
3 minutos atrás, Danyel Varejao disse:

Creaturescripts.xml não é o script não rsrs

Opa kkkkkk, vou editar o post de cima só atualizar!

 

                                                           

55f6tc.gif                     

Link para o post
Compartilhar em outros sites

 

Adiciona isso na lib lá e testa dnv.

 

tabela_storages = {
	filtrateString = function(str)
		local tb, x, old, last = {}, 0, 0, 0
		local first, second, final = 0, 0, 0
		if type(str) ~= "string" then
			return tb
		end
		for i = 2, #str-1 do
			if string.byte(str:sub(i,i)) == string.byte(':') then
				x, second, last = x+1, i-1, i+2
				for t = last,#str-1 do
					if string.byte(str:sub(t,t)) == string.byte(',') then
						first = x == 1 and 2 or old
						old, final = t+2, t-1
						local index, var = str:sub(first,second), str:sub(last,final)
						tb[tonumber(index) or tostring(index)] = tonumber(var) or tostring(var)
						break
					end
				end
			end
		end
		return tb
	end,

	translateIntoString = function(tb)
		local str = ""
		if type(tb) ~= "table" then
			return str
		end
		for i, t in pairs(tb) do
			str = str..i..": "..t..", "
		end
		str = "a"..str.."a"
		return tostring(str)
	end
}

function setPlayerTableStorage(cid, key, value)
    return doPlayerSetStorageValue(cid, key, tabela_storages.translateIntoString(value))
end

function getPlayerTableStorage(cid, key)
    return tabela_storages.filtrateString(getPlayerStorageValue(cid, key))
end

function setGlobalTableStorage(key, value)
    return setGlobalStorageValue(key, tabela_storages.translateIntoString(value))
end

function getGlobalTableStorage(key)
    return tabela_storages.filtrateString(getGlobalStorageValue(key))
end

function getStorageZero(storage)
    local sto = getGlobalStorageValue(storage)
    return sto > 0 and sto or 0
end

function getPlayerStorageZero(cid, storage)
    local sto = getPlayerStorageValue(cid, storage)
    if tonumber(sto) then
        return tonumber(sto) > tonumber(0) and tonumber(sto) or tonumber(0)
    end
    return tonumber(0)
end

 

Link para o post
Compartilhar em outros sites
4 minutos atrás, Danyel Varejao disse:

 

Adiciona isso na lib lá e testa dnv.

 


tabela_storages = {
	filtrateString = function(str)
		local tb, x, old, last = {}, 0, 0, 0
		local first, second, final = 0, 0, 0
		if type(str) ~= "string" then
			return tb
		end
		for i = 2, #str-1 do
			if string.byte(str:sub(i,i)) == string.byte(':') then
				x, second, last = x+1, i-1, i+2
				for t = last,#str-1 do
					if string.byte(str:sub(t,t)) == string.byte(',') then
						first = x == 1 and 2 or old
						old, final = t+2, t-1
						local index, var = str:sub(first,second), str:sub(last,final)
						tb[tonumber(index) or tostring(index)] = tonumber(var) or tostring(var)
						break
					end
				end
			end
		end
		return tb
	end,

	translateIntoString = function(tb)
		local str = ""
		if type(tb) ~= "table" then
			return str
		end
		for i, t in pairs(tb) do
			str = str..i..": "..t..", "
		end
		str = "a"..str.."a"
		return tostring(str)
	end
}

function setPlayerTableStorage(cid, key, value)
    return doPlayerSetStorageValue(cid, key, tabela_storages.translateIntoString(value))
end

function getPlayerTableStorage(cid, key)
    return tabela_storages.filtrateString(getPlayerStorageValue(cid, key))
end

function setGlobalTableStorage(key, value)
    return setGlobalStorageValue(key, tabela_storages.translateIntoString(value))
end

function getGlobalTableStorage(key)
    return tabela_storages.filtrateString(getGlobalStorageValue(key))
end

function getStorageZero(storage)
    local sto = getGlobalStorageValue(storage)
    return sto > 0 and sto or 0
end

function getPlayerStorageZero(cid, storage)
    local sto = getPlayerStorageValue(cid, storage)
    if tonumber(sto) then
        return tonumber(sto) > tonumber(0) and tonumber(sto) or tonumber(0)
    end
    return tonumber(0)
end

 

Mesma coisa, sem erro da Distro, porem não pegou os golds! ;/

 

                                                           

55f6tc.gif                     

Link para o post
Compartilhar em outros sites
22 horas atrás, Danyel Varejao disse:

Você está ligando o autoloot, usando !autoloot power ou !autoloot on, algo do tipo?

Sim, esta tudo certinho...adicionei tudo que me disse

 

Entro digo, !autoloot gold, !autoloot add, meat e depois !autolootpower

 

Mais não pega nada e também não tem erro na Distro, vou ter que trocar de systema auto loot sera ou podemos tentar mais alguma coisa? hehe

 

@EDIT

 

Pessoal minha duvida foi resolvida graças ao amigo @Danyel Varejao, no qual recebi um grande suporte até em game para que ele pudesse vim resolver este problema!

 

O link do Tutorial do System de Auto Loot funcional do @Danyel Varejao, vai ser postado aqui, para ser encaminhado ao Tutorial dele caso alguem com o mesmo problema venha cair aqui... valeu e obrigado a todos!

 

Solução: 

 

Editado por Digoshow (veja o histórico de edições)

 

                                                           

55f6tc.gif                     

Link para o post
Compartilhar em outros sites

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

×   Seu conteúdo anterior foi restaurado.   Limpar o editor

×   Não é possível colar imagens diretamente. Carregar ou inserir imagens do URL.

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo