Ir para conteúdo
  • Cadastre-se

Normal ERRO: attempt to index local 'monster' (a nil value)


Posts Recomendados

Alguém pode me ajudar resolver o erro:

 

 

[14:46:33.658] [Error - CreatureScript Interface]
[14:46:33.660] data/creaturescripts/scripts/killmissions.lua:onKill
[14:46:33.661] Description:
[14:46:33.662] data/creaturescripts/scripts/killmissions.lua:15: attempt to index local 'monster' (a nil value)
[14:46:33.663] stack traceback:
[14:46:33.665]  data/creaturescripts/scripts/killmissions.lua:15: in function <data/creaturescripts/scripts/killmissions.lua:1>

 

SCRIPT:

 

function onKill(cid, target)

local config = {
     ['troll'] = {amount = 10, storage = 21900, startstorage = 45553, startvalue = 1, tit = "Criaturas Humanoides"},
     ['rotworm'] = {amount = 26, storage = 21901, startstorage = 45551, startvalue = 2},
     ['dragon lord'] = {amount = 25, storage = 21902, startstorage = 45551, startvalue = 4}
}


     local monster = config[getCreatureName(target):lower()]
     if isPlayer(target) and isMonster(target) then
         return true
     end
 
     if (getPlayerStorageValue(cid, monster.storage)+1) < monster.amount and getPlayerStorageValue(cid, monster.startstorage) >= monster.startvalue then
         setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, monster.storage) + 1)
         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, '[Sistema de Sincronização]: '..(getPlayerStorageValue(cid, monster.storage)+1)..' de '..monster.amount..' '..getCreatureName(target)..'s mortos.')
     end
     if (getPlayerStorageValue(cid, monster.storage)+1) == monster.amount then
         doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Concluido ! Você matou '..(getPlayerStorageValue(cid, monster.storage)+1)..' '..getCreatureName(target)..'s e completou a missão '..tit..'.')
         setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, monster.storage) + 1)
     end
     return true
end
 
 
 

 

Isso acontece toda vez que eu mato um mostro que não está na lista, ai o mostro não morre e fica imortal.

Link para o post
Compartilhar em outros sites
function onKill(cid, target)

local config = {
     ['troll'] = {amount = 10, storage = 21900, startstorage = 45553, startvalue = 1, tit = "Criaturas Humanoides"},
     ['rotworm'] = {amount = 26, storage = 21901, startstorage = 45551, startvalue = 2},
     ['dragon lord'] = {amount = 25, storage = 21902, startstorage = 45551, startvalue = 4}
}

     if isPlayer(target) and isMonster(target) then
         return true
     end

     if not config[getCreatureName(target):lower()] then
         return true
     end

    local monster = config[getCreatureName(target):lower()]

     if (getPlayerStorageValue(cid, monster.storage)+1) < monster.amount and getPlayerStorageValue(cid, monster.startstorage) >= monster.startvalue then
         setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, monster.storage) + 1)
         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, '[Sistema de Sincronização]: '..(getPlayerStorageValue(cid, monster.storage)+1)..' de '..monster.amount..' '..getCreatureName(target)..'s mortos.')
     end
     if (getPlayerStorageValue(cid, monster.storage)+1) == monster.amount then
         doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Concluido ! Você matou '..(getPlayerStorageValue(cid, monster.storage)+1)..' '..getCreatureName(target)..'s e completou a missão '..tit..'.')
         setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, monster.storage) + 1)
     end
     return true
end

 

                                                                     Ajudei? De nada \o/                                            Att Rusherzin

Link para o post
Compartilhar em outros sites

O que tinha de errado mano ? 

 

Vllw pela ajuda.

 

É pooq to aprendendo scripting

6 minutos atrás, Rusherzin disse:

function onKill(cid, target)

local config = {
     ['troll'] = {amount = 10, storage = 21900, startstorage = 45553, startvalue = 1, tit = "Criaturas Humanoides"},
     ['rotworm'] = {amount = 26, storage = 21901, startstorage = 45551, startvalue = 2},
     ['dragon lord'] = {amount = 25, storage = 21902, startstorage = 45551, startvalue = 4}
}

     if isPlayer(target) and isMonster(target) then
         return true
     end

     if not config[getCreatureName(target):lower()] then
         return true
     end

    local monster = config[getCreatureName(target):lower()]

     if (getPlayerStorageValue(cid, monster.storage)+1) < monster.amount and getPlayerStorageValue(cid, monster.startstorage) >= monster.startvalue then
         setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, monster.storage) + 1)
         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, '[Sistema de Sincronização]: '..(getPlayerStorageValue(cid, monster.storage)+1)..' de '..monster.amount..' '..getCreatureName(target)..'s mortos.')
     end
     if (getPlayerStorageValue(cid, monster.storage)+1) == monster.amount then
         doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Concluido ! Você matou '..(getPlayerStorageValue(cid, monster.storage)+1)..' '..getCreatureName(target)..'s e completou a missão '..tit..'.')
         setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, monster.storage) + 1)
     end
     return true
end

 

Deu erro :

 

 

[15:15:55.687] [Error - CreatureScript Interface]
[15:15:55.689] data/creaturescripts/scripts/killmissions.lua:onKill
[15:15:55.689] Description:
[15:15:55.690] data/creaturescripts/scripts/killmissions.lua:24: attempt to concatenate global 'tit' (a nil value)
[15:15:55.691] stack traceback:
[15:15:55.691]  data/creaturescripts/scripts/killmissions.lua:24: in function <data/creaturescripts/scripts/killmissions.lua:1>

Link para o post
Compartilhar em outros sites

Ele estava tentando indexar com um índice que não estava na lista.
Ex:

config['rat']

Então coloquei uma checagem
 

if not config[getCreatureName(target):lower()] then
    return true
end

Se ele não conseguir indexar (ou seja, não achar o monstro na lista), ele retorna verdadeiro para a morte ser concluída sem exibir nenhuma mensagem de task.
Sobre o erro, esqueceu de botar monster antes de tit. Ficaria assim:

function onKill(cid, target)

local config = {
     ['troll'] = {amount = 10, storage = 21900, startstorage = 45553, startvalue = 1, tit = "Criaturas Humanoides"},
     ['rotworm'] = {amount = 26, storage = 21901, startstorage = 45551, startvalue = 2},
     ['dragon lord'] = {amount = 25, storage = 21902, startstorage = 45551, startvalue = 4}
}

     if isPlayer(target) and isMonster(target) then
         return true
     end

     if not config[getCreatureName(target):lower()] then
         return true
     end

    local monster = config[getCreatureName(target):lower()]

     if (getPlayerStorageValue(cid, monster.storage)+1) < monster.amount and getPlayerStorageValue(cid, monster.startstorage) >= monster.startvalue then
         setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, monster.storage) + 1)
         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, '[Sistema de Sincronização]: '..(getPlayerStorageValue(cid, monster.storage)+1)..' de '..monster.amount..' '..getCreatureName(target)..'s mortos.')
     end
     if (getPlayerStorageValue(cid, monster.storage)+1) == monster.amount then
         doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Concluido ! Você matou '..(getPlayerStorageValue(cid, monster.storage)+1)..' '..getCreatureName(target)..'s e completou a missão '..monster.tit..'.')
         setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, monster.storage) + 1)
     end
     return true
end


 

                                                                     Ajudei? De nada \o/                                            Att Rusherzin

Link para o post
Compartilhar em outros sites

CARA estou com um erro bem parecido só que em um npc  e toda vez que tento logar qualquer character no servidor ele não entra e acusa esse erro na distro: 

 

[17/7/2017 20:17:21] [Error - CreatureScript Interface] 
[17/7/2017 20:17:21] data/creaturescripts/scripts/npc_shop.lua:onLogin
[17/7/2017 20:17:21] Description: 
[17/7/2017 20:17:21] data/creaturescripts/scripts/npc_shop.lua:2: attempt to index global '_config_npc_shop' (a nil value)
[17/7/2017 20:17:21] stack traceback:
[17/7/2017 20:17:21]     data/creaturescripts/scripts/npc_shop.lua:2: in function <data/creaturescripts/scripts/npc_shop.lua:1>
[17/7/2017 20:17:21] Lyke has logged out.

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.

  • Conteúdo Similar

    • Por Jaurez
      .
    • Por Cat
      Em alguns casos, o tibia 8.60 comum não abre de jeito nenhum no map editor, mesmo desmarcando check file signatures e configurando o path corretamente.
       
      Este é o client 8.60 adaptado para o Remere's Map Editor. Resolvi postar já que ele foi removido do site oficial do RME. (ficou apenas a versão para linux lá)
      Se estiver tendo problemas para abrir a versão 8.60, tente utilizar este.
                                                                                                                     
      Baixar o Tibia Client 8.60 que funciona no Remere’s Map Editor
      Essa versão do Tibia 8.60 client resolve o erro unsupported client version ou Could not locate tibia.dat and/or tibia.spr, please navigate to your tibia 8.60 installation folder.
       
      Downloads
      https://tibiaking.com/applications/core/interface/file/attachment.php?id=47333

      Scan: https://www.virustotal.com/gui/file/333e172ac49ba2028db9eb5889994509e7d2de28ebccfa428c04e86defbe15cc
       
    • Por danilo belato
      Fala Galera To Com um problema aki 
       
      quero exporta umas sprites de um server para colocar em outro 
       
      eu clico na sprites ai aparece tds a forma delas do lado de la >>
       
      ai eu clico nela e ponho a opiçao de export mais quando salvo a sprite ela n abri 
       
      aparece isso quando tento vê-la 
       
      visualização não disponível ( no formatos png e bitmap)
       
      Agora no formato idc fala que o paint n pode ler 
       
      me ajudem ae...
    • Por Vitor Bicaleto
      Galera to com o script do addon doll aqui, quando eu digito apenas "!addon" ele aparece assim: Digite novamente, algo está errado!"
      quando digito por exemplo: "!addon citizen" ele não funciona e não da nenhum erro
       
      mesma coisa acontece com o mount doll.. 
    • Por Ayron5
      Substitui uma stone no serve, deu tudo certo fora  esse  erro ajudem  Valendo  Rep+  Grato  

      Erro: data/actions/scripts/boost.lua:557: table index is nil
       [Warning - Event::loadScript] Cannot load script (data/actions/scripts/boost.lua)

      Script:
×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo