Ir para conteúdo

Featured Replies

Postado

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.

  • Respostas 5
  • Visualizações 2.8k
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • function onKill(cid, target) local config = { ['troll'] = {amount = 10, storage = 21900, startstorage = 45553, startvalue = 1, tit = "Criaturas Humanoides"}, ['rotworm'] = {amount = 26, sto

  • 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 en

Postado
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

Postado
  • Autor

O que tinha de errado mano ? 

 

Vllw pela ajuda.

 

É pooq to aprendendo scripting

  Em 18/07/2017 em 18:09, 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>

Postado

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

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

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.6k

Informação Importante

Confirmação de Termo