Ir para conteúdo
  • 0

[ERROR] Addon System


boxxer321

Pergunta

Galera, estou com esse erro em um sistema de addon:

quem puder ajudar, obrigado!

 

Spoiler

[19/02/2019 14:15:21] [Error - CreatureScript Interface] 
[19/02/2019 14:15:21] In a timer event called from: 
[19/02/2019 14:15:21] data/creaturescripts/scripts/addonSystem.lua:onOutfit
[19/02/2019 14:15:21] Description: 
[19/02/2019 14:15:21] data/lib/011-string.lua:29: attempt to index local 'str' (a number value)
[19/02/2019 14:15:21] stack traceback:
[19/02/2019 14:15:21]     data/lib/011-string.lua:29: in function 'explode'
[19/02/2019 14:15:21]     data/creaturescripts/scripts/addonSystem.lua:48: in function <data/creaturescripts/scripts/addonSystem.lua:44>

 

addonsystem.lua:

Spoiler

function onOutfit(cid, old, current)
local pk = getCreatureSummons(cid)
if #pk >= 1 and getPlayerStorageValue(cid, pokeAddons[getPokemonName(pk[1])].default) >= 1 then
    
    local oldStorages = string.explode(getPlayerStorageValue(cid, storages.addonSystem), ",")
    for i = 1, #oldStorages do
      for t1, t2 in pairs(stringStorages) do
       if oldStorages == t1 then
          setPlayerStorageValue(cid, t2, 1)
       end
      end 
    end
    
    local oldStoragess = string.explode(getPlayerStorageValue(cid, storages.addonSystem3), ",")
    for i = 1, #oldStoragess do
      for t1, t2 in pairs(pokeStrings) do
       if i >= 1 and oldStoragess == t1 then
          setPlayerStorageValue(cid, t2, 0)
          setPlayerStorageValue(cid, pokeAddons[getPokemonName(pk[1])].default, 0)
       end
      end 
    end
      for id1, id2 in pairs(itensAddons) do
       local a = {"addon", "addon2", "addon3", "addon4", "addon5", "addon6", "addon7"}
          for i = 1, #a do 
           if getItemAttribute(getPlayerSlotItem(cid, 8).uid, a) == id2.addon then 
             setPlayerStorageValue(cid, id2.stor, 0)
             setPlayerStorageValue(cid, pokeAddons[getPokemonName(pk[1])].default, 0)
           else
             setPlayerStorageValue(cid, pokeAddons[getPokemonName(pk[1])].default, 0)  
          end
          end
      end
    setPlayerStorageValue(cid, storages.checkOutfitColor, "")
    setPlayerStorageValue(cid, storages.checkOutfitColor, getPlayerStorageValue(cid, storages.checkOutfitColor)..","..getCreatureOutfit(cid).lookBody..","..getCreatureOutfit(cid).lookHead..","..getCreatureOutfit(cid).lookLegs..","..getCreatureOutfit(cid).lookFeet) 
    setPlayerStorageValue(cid, storages.addonSystem2, getCreatureOutfit(cid).lookType) 
    addEvent(doSet, 2, cid, pk)
           

end
return true
end

function doSet(cid, summon)
if not isCreature(cid) then return true end
if not isCreature(summon[1]) then return true end
local out = getCreatureOutfit(cid)
local colors = string.explode(getPlayerStorageValue(cid, storages.checkOutfitColor), ",")
    doSetCreatureOutfit(summon[1], {lookType = getCreatureOutfit(cid).lookType, lookBody = out.lookBody, lookHead = out.lookHead, lookLegs = out.lookLegs, lookFeet = out.lookFeet}, -1)
    doItemSetAttribute(getPlayerSlotItem(cid, 8).uid, "color1", out.lookBody)
    doItemSetAttribute(getPlayerSlotItem(cid, 8).uid, "color2", out.lookHead)
    doItemSetAttribute(getPlayerSlotItem(cid, 8).uid, "color3", out.lookLegs)
    doItemSetAttribute(getPlayerSlotItem(cid, 8).uid, "color4", out.lookFeet)
    doItemSetAttribute(getPlayerSlotItem(cid, 8).uid, "addonNow", getCreatureOutfit(cid).lookType)
    doCreatureChangeOutfit(cid, {lookType = getPlayerStorageValue(cid, storages.addonSystem2), lookBody = colors[1], lookHead = colors[2], lookLegs = colors[3], lookFeet = colors[4]})
end

 

011-string.lua:

Spoiler

string.split = function (str)
    local t = {}
    return not str:gsub("%w+", function(s) table.insert(t, s) return "" end):find("%S") and t or {}
end

string.trim = function (str)
    return str:gsub("^%s*(.-)%s*$", "%1")
end

string.explode = function (str, sep, limit)
    if(type(sep) ~= 'string' or isInArray({tostring(str):len(), sep:len()}, 0)) then
        return {}
    end

    local i, pos, tmp, t = 0, 1, "", {}
    for s, e in function() return string.find(str, sep, pos) end do
        tmp = str:sub(pos, s - 1):trim()
        if tmp ~= "" then               --alterado v1.8
           table.insert(t, tmp)
        end
        pos = e + 1

        i = i + 1
        if(limit ~= nil and i == limit) then
            break
        end
    end

    tmp = str:sub(pos):trim()
    if tmp ~= "" then              --alterado v1.8
       table.insert(t, tmp)
    end
    return t
end

string.expand = function (str)
    return string.gsub(str, "$(%w+)", function(n) return _G[n] end)
end

string.timediff = function (diff)
    local format = {
        {"week", diff / 60 / 60 / 24 / 7},
        {"day", diff / 60 / 60 / 24 % 7},
        {"hour", diff / 60 / 60 % 24},
        {"minute", diff / 60 % 60},
        {"second", diff % 60}
    }

    local t = {}
    for k, v in ipairs(format) do
        local d, tmp = math.floor(v[2]), ""
        if(d > 0) then
            tmp = (k < table.maxn(format) and (table.maxn(t) > 0 and ", " or "") or " and ") .. d .. " " .. v[1] .. (d ~= 1 and "s" or "")
            table.insert(t, tmp)
        end
    end

    return t
end

 

Link para o comentário
Compartilhar em outros sites

8 respostass a esta questão

Posts Recomendados

  • 0
2 horas atrás, boxxer321 disse:
Versão do Servidor: TFS - 0.3.5
Tipo de Script: creaturescript

Galera, estou com esse erro em um sistema de addon:

quem puder ajudar, obrigado!

 

  Ocultar conteúdo

[19/02/2019 14:15:21] [Error - CreatureScript Interface] 
[19/02/2019 14:15:21] In a timer event called from: 
[19/02/2019 14:15:21] data/creaturescripts/scripts/addonSystem.lua:onOutfit
[19/02/2019 14:15:21] Description: 
[19/02/2019 14:15:21] data/lib/011-string.lua:29: attempt to index local 'str' (a number value)
[19/02/2019 14:15:21] stack traceback:
[19/02/2019 14:15:21]     data/lib/011-string.lua:29: in function 'explode'
[19/02/2019 14:15:21]     data/creaturescripts/scripts/addonSystem.lua:48: in function <data/creaturescripts/scripts/addonSystem.lua:44>

 

addonsystem.lua:

  Ocultar conteúdo

function onOutfit(cid, old, current)
local pk = getCreatureSummons(cid)
if #pk >= 1 and getPlayerStorageValue(cid, pokeAddons[getPokemonName(pk[1])].default) >= 1 then
    
    local oldStorages = string.explode(getPlayerStorageValue(cid, storages.addonSystem), ",")
    for i = 1, #oldStorages do
      for t1, t2 in pairs(stringStorages) do
       if oldStorages == t1 then
          setPlayerStorageValue(cid, t2, 1)
       end
      end 
    end
    
    local oldStoragess = string.explode(getPlayerStorageValue(cid, storages.addonSystem3), ",")
    for i = 1, #oldStoragess do
      for t1, t2 in pairs(pokeStrings) do
       if i >= 1 and oldStoragess == t1 then
          setPlayerStorageValue(cid, t2, 0)
          setPlayerStorageValue(cid, pokeAddons[getPokemonName(pk[1])].default, 0)
       end
      end 
    end
      for id1, id2 in pairs(itensAddons) do
       local a = {"addon", "addon2", "addon3", "addon4", "addon5", "addon6", "addon7"}
          for i = 1, #a do 
           if getItemAttribute(getPlayerSlotItem(cid, 8).uid, a) == id2.addon then 
             setPlayerStorageValue(cid, id2.stor, 0)
             setPlayerStorageValue(cid, pokeAddons[getPokemonName(pk[1])].default, 0)
           else
             setPlayerStorageValue(cid, pokeAddons[getPokemonName(pk[1])].default, 0)  
          end
          end
      end
    setPlayerStorageValue(cid, storages.checkOutfitColor, "")
    setPlayerStorageValue(cid, storages.checkOutfitColor, getPlayerStorageValue(cid, storages.checkOutfitColor)..","..getCreatureOutfit(cid).lookBody..","..getCreatureOutfit(cid).lookHead..","..getCreatureOutfit(cid).lookLegs..","..getCreatureOutfit(cid).lookFeet) 
    setPlayerStorageValue(cid, storages.addonSystem2, getCreatureOutfit(cid).lookType) 
    addEvent(doSet, 2, cid, pk)
           

end
return true
end

function doSet(cid, summon)
if not isCreature(cid) then return true end
if not isCreature(summon[1]) then return true end
local out = getCreatureOutfit(cid)
local colors = string.explode(getPlayerStorageValue(cid, storages.checkOutfitColor), ",")
    doSetCreatureOutfit(summon[1], {lookType = getCreatureOutfit(cid).lookType, lookBody = out.lookBody, lookHead = out.lookHead, lookLegs = out.lookLegs, lookFeet = out.lookFeet}, -1)
    doItemSetAttribute(getPlayerSlotItem(cid, 8).uid, "color1", out.lookBody)
    doItemSetAttribute(getPlayerSlotItem(cid, 8).uid, "color2", out.lookHead)
    doItemSetAttribute(getPlayerSlotItem(cid, 8).uid, "color3", out.lookLegs)
    doItemSetAttribute(getPlayerSlotItem(cid, 8).uid, "color4", out.lookFeet)
    doItemSetAttribute(getPlayerSlotItem(cid, 8).uid, "addonNow", getCreatureOutfit(cid).lookType)
    doCreatureChangeOutfit(cid, {lookType = getPlayerStorageValue(cid, storages.addonSystem2), lookBody = colors[1], lookHead = colors[2], lookLegs = colors[3], lookFeet = colors[4]})
end

 

011-string.lua:

  Mostrar conteúdo oculto

string.split = function (str)
    local t = {}
    return not str:gsub("%w+", function(s) table.insert(t, s) return "" end):find("%S") and t or {}
end

string.trim = function (str)
    return str:gsub("^%s*(.-)%s*$", "%1")
end

string.explode = function (str, sep, limit)
    if(type(sep) ~= 'string' or isInArray({tostring(str):len(), sep:len()}, 0)) then
        return {}
    end

    local i, pos, tmp, t = 0, 1, "", {}
    for s, e in function() return string.find(str, sep, pos) end do
        tmp = str:sub(pos, s - 1):trim()
        if tmp ~= "" then               --alterado v1.8
           table.insert(t, tmp)
        end
        pos = e + 1

        i = i + 1
        if(limit ~= nil and i == limit) then
            break
        end
    end

    tmp = str:sub(pos):trim()
    if tmp ~= "" then              --alterado v1.8
       table.insert(t, tmp)
    end
    return t
end

string.expand = function (str)
    return string.gsub(str, "$(%w+)", function(n) return _G[n] end)
end

string.timediff = function (diff)
    local format = {
        {"week", diff / 60 / 60 / 24 / 7},
        {"day", diff / 60 / 60 / 24 % 7},
        {"hour", diff / 60 / 60 % 24},
        {"minute", diff / 60 % 60},
        {"second", diff % 60}
    }

    local t = {}
    for k, v in ipairs(format) do
        local d, tmp = math.floor(v[2]), ""
        if(d > 0) then
            tmp = (k < table.maxn(format) and (table.maxn(t) > 0 and ", " or "") or " and ") .. d .. " " .. v[1] .. (d ~= 1 and "s" or "")
            table.insert(t, tmp)
        end
    end

    return t
end

 

print(getPlayerStorageValue(cid, storages.checkOutfitColor))

adiciona essa linha logo após

function onOutfit(cid, old, current)

 e me fala oq vai aparecer

Link para o comentário
Compartilhar em outros sites

  • 0
24 minutos atrás, Refe disse:

print(getPlayerStorageValue(cid, storages.checkOutfitColor))

adiciona essa linha logo após


function onOutfit(cid, old, current)

 e me fala oq vai aparecer

formatei para ANSI o script pois estava dando erro.

depois no jogo, a outfit com o addon foi para o meu personagem ao inves de ir para o pokémon, (isso não acontecia antes, nenhum dos dois ganhavam o addon kkk) e deu o seguinte erro no console:

Spoiler

 

[19/02/2019 17:30:37] ,100

[19/02/2019 17:30:37] [Error - CreatureScript Interface] 
[19/02/2019 17:30:37] In a timer event called from: 
[19/02/2019 17:30:37] data/creaturescripts/scripts/addonSystem.lua:onOutfit
[19/02/2019 17:30:37] Description: 
[19/02/2019 17:30:37] data/lib/011-string.lua:29: attempt to index local 'str' (a number value)
[19/02/2019 17:30:37] stack traceback:
[19/02/2019 17:30:37]     data/lib/011-string.lua:29: in function 'explode'
[19/02/2019 17:30:37]     data/creaturescripts/scripts/addonSystem.lua:49: in function <data/creaturescripts/scripts/addonSystem.lua:45>

 

apareceu esse ",100"

Link para o comentário
Compartilhar em outros sites

  • 0

Faz assim, na linha 48 vai ter isso:

local colors = string.explode(getPlayerStorageValue(cid, storages.checkOutfitColor), ",")

Tenta modificar para isso:

local colors = string.explode(","..getPlayerStorageValue(cid, storages.checkOutfitColor), ",")

Ou para isso:

local colors = getPlayerStorageValue(cid, storages.checkOutfitColor):explode(",")

 

Link para o comentário
Compartilhar em outros sites

  • 0
local colors = string.explode(","..getPlayerStorageValue(cid, storages.checkOutfitColor), ",")

esse conseguiu adicionar o addon ao pokémon e trocar, porém, algumas vezes travou a outfit do personagem e tive que relogar e logar algumas vezes para voltar.

 

e esse, mudou nada e deu esse erro no console:

local colors = getPlayerStorageValue(cid, storages.checkOutfitColor):explode(",")

[19/02/2019 18:00:55] [Error - CreatureScript Interface] 
[19/02/2019 18:00:55] In a timer event called from: 
[19/02/2019 18:00:55] data/creaturescripts/scripts/addonSystem.lua:onOutfit
[19/02/2019 18:00:55] Description: 
[19/02/2019 18:00:55] data/creaturescripts/scripts/addonSystem.lua:49: attempt to index a number value
[19/02/2019 18:00:55] stack traceback:
[19/02/2019 18:00:55]     data/creaturescripts/scripts/addonSystem.lua:49: in function <data/creaturescripts/scripts/addonSystem.lua:45>

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

  • 0
20 horas atrás, boxxer321 disse:

local colors = string.explode(","..getPlayerStorageValue(cid, storages.checkOutfitColor), ",")

esse conseguiu adicionar o addon ao pokémon e trocar, porém, algumas vezes travou a outfit do personagem e tive que relogar e logar algumas vezes para voltar.

 

e esse, mudou nada e deu esse erro no console:


local colors = getPlayerStorageValue(cid, storages.checkOutfitColor):explode(",")

[19/02/2019 18:00:55] [Error - CreatureScript Interface] 
[19/02/2019 18:00:55] In a timer event called from: 
[19/02/2019 18:00:55] data/creaturescripts/scripts/addonSystem.lua:onOutfit
[19/02/2019 18:00:55] Description: 
[19/02/2019 18:00:55] data/creaturescripts/scripts/addonSystem.lua:49: attempt to index a number value
[19/02/2019 18:00:55] stack traceback:
[19/02/2019 18:00:55]     data/creaturescripts/scripts/addonSystem.lua:49: in function <data/creaturescripts/scripts/addonSystem.lua:45>

 

O problema é que por algum motivo só tá setando 1 cor, ali pede 4, tenta fazer assim:

local colors = string.explode("1,1,1"..getPlayerStorageValue(cid, storages.checkOutfitColor), ",")

 

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

  • 0
2 horas atrás, Refe disse:

 

O problema é que por algum motivo só tá setando 1 cor, ali pede 4, tenta fazer assim:


local colors = string.explode("1,1,1"..getPlayerStorageValue(cid, storages.checkOutfitColor), ",")

 

mesma coisa... em algum momento de troca de addon, nao consegue mudar a outfit do persongem, mas a do pokémon, sim.

Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...