• TibiaFace

    Tibiaface | Una comunidad Open Tibia donde encontras : mapas, scripts, Otserver, npc y amigos etc ...

    .
    demo menumenu

    Afiliados



    Votar:

    [NPC] problema con npc

    Compartir:

    Ver el tema anterior Ver el tema siguiente Ir abajo  Mensaje (Página 1 de 1.)

    1[NPC] problema con npc Empty [NPC] problema con npc Sáb Jul 02, 2022 1:11 am

    akane

    akane
    Miembro
    Miembro
    Descripcion escribió:hola a todos, tengo un problema con este npc, resulta que al hacer la primera mision no me da problemas, pero intenté agregarle una mision mas al script y me da el siguiente error :c

    Código:
    [Warning - NpcScript::NpcScript] Can not load script: Orc Guard Thyrus.lua
    data/npc/scripts/Orc Guard Thyrus.lua:63: 'end' expected (to close 'if' at line 17) near '<eof>'

    este es mi script

    Código:
    local keywordHandler = KeywordHandler:new()
    local npcHandler = NpcHandler:new(keywordHandler)
    NpcSystem.parseParameters(npcHandler)

    function onCreatureAppear(cid)         npcHandler:onCreatureAppear(cid)         end
    function onCreatureDisappear(cid)      npcHandler:onCreatureDisappear(cid)         end
    function onCreatureSay(cid, type, msg)      npcHandler:onCreatureSay(cid, type, msg)      end
    function onThink()            npcHandler:onThink()               end

    local function creatureSayCallback(cid, type, msg)
       if not npcHandler:isFocused(cid) then
          return false
       end

       local player = Player(cid)
       
             if(msgcontains(msg, "i need talk to the king") and getPlayerStorageValue(cid, 208) < 1) then
                if(player:getStorageValue(12116) == 3) then
                   npcHandler:say("hahaha... Do you think it is to arrive and talk to the king?", cid)
                   npcHandler.topic[cid] = 1
             else
                   npcHandler:say("Primero habla con el npc.", cid)
             end
             elseif(msgcontains(msg, "it is urgent, i must tell you what has happened")) then
                if(npcHandler.topic[cid] == 1) then
                   npcHandler:say({
                   "bah, it's always urgent... unless you bring a permit from the secretary of the kingdom, it's the only way to enter. ...",
                   "It is located on the top floor of the castle, but you will be lucky if it is given to you. ...",
                   "today he has a horrible character, so be careful."
                   }, cid)               
                   npcHandler.topic[cid] = 0
                if(getPlayerStorageValue(cid, 208) < 1) then
                   setPlayerStorageValue(cid, 208, 1)
                   player:setStorageValue(12117, 1) -- The Inquisition Questlog- "Mission 4: A Mysterious Hero is Born"
                   doSendMagicEffect(getCreaturePosition(cid), CONST_ME_HOLYAREA)
                end
             elseif(msgcontains(msg, "i need talk to the king") and getPlayerStorageValue(cid, 208) < 1) then
                if(player:getStorageValue(12117) == 1) then
                   npcHandler:say("Oh look who's back, you were lucky?.. Hahaha.", cid)
                   npcHandler.topic[cid] = 1
             else
                   npcHandler:say("Primero habla con el npc.", cid)
             end
             elseif(msgcontains(msg, "here is the permission")) then
                if(npcHandler.topic[cid] == 1) then
                   npcHandler:say({
                   "Tsk. ...",
                   "I see you got it... Hurry go talk to the king before i change my mind."
                   }, cid)               
                   npcHandler.topic[cid] = 0
                if(getPlayerStorageValue(cid, 210) < 1) then
                   setPlayerStorageValue(cid, 210, 1)
                   if(doPlayerRemoveItem(cid, 1947, 1) == TRUE) then
                   player:setStorageValue(12117, 3) -- The Inquisition Questlog- "Mission 4: A Mysterious Hero is Born"
                   doSendMagicEffect(getCreaturePosition(cid), CONST_ME_HOLYAREA)
             end
          end
       end
       return true
    end
     
    npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
    npcHandler:addModule(FocusModule:new())
    Captura del Error escribió:Imagen del error: [NPC] problema con npc Empty
    El error radica en: Npc

    3 participantes

    2[NPC] problema con npc Empty Re: [NPC] problema con npc Sáb Jul 02, 2022 6:48 am

    SoyFabi

    SoyFabi
    Miembro
    Miembro
    local keywordHandler = KeywordHandler:new()
    local npcHandler = NpcHandler:new(keywordHandler)
    NpcSystem.parseParameters(npcHandler)

    function onCreatureAppear(cid)         npcHandler:onCreatureAppear(cid)         end
    function onCreatureDisappear(cid)      npcHandler:onCreatureDisappear(cid)         end
    function onCreatureSay(cid, type, msg)      npcHandler:onCreatureSay(cid, type, msg)      end
    function onThink()            npcHandler:onThink()               end

    local function creatureSayCallback(cid, type, msg)
       if not npcHandler:isFocused(cid) then
          return false
       end

       local player = Player(cid)
       
             if(msgcontains(msg, "i need talk to the king") and getPlayerStorageValue(cid, 208) < 1) then
                if(player:getStorageValue(12116) == 3) then
                   npcHandler:say("hahaha... Do you think it is to arrive and talk to the king?", cid)
                   npcHandler.topic[cid] = 1
             else
                   npcHandler:say("Primero habla con el npc.", cid)
             end
             elseif(msgcontains(msg, "it is urgent, i must tell you what has happened")) then
                if(npcHandler.topic[cid] == 1) then
                   npcHandler:say({
                   "bah, it's always urgent... unless you bring a permit from the secretary of the kingdom, it's the only way to enter. ...",
                   "It is located on the top floor of the castle, but you will be lucky if it is given to you. ...",
                   "today he has a horrible character, so be careful."
                   }, cid)              
                   npcHandler.topic[cid] = 0
                if(getPlayerStorageValue(cid, 208) < 1) then
                   setPlayerStorageValue(cid, 208, 1)
                   player:setStorageValue(12117, 1) -- The Inquisition Questlog- "Mission 4: A Mysterious Hero is Born"
                   doSendMagicEffect(getCreaturePosition(cid), CONST_ME_HOLYAREA)
                end
             elseif(msgcontains(msg, "i need talk to the king") and getPlayerStorageValue(cid, 208) < 1) then
                if(player:getStorageValue(12117) == 1) then
                   npcHandler:say("Oh look who's back, you were lucky?.. Hahaha.", cid)
                   npcHandler.topic[cid] = 1
             else
                   npcHandler:say("Primero habla con el npc.", cid)
             end
             elseif(msgcontains(msg, "here is the permission")) then
                if(npcHandler.topic[cid] == 1) then
                   npcHandler:say({
                   "Tsk. ...",
                   "I see you got it... Hurry go talk to the king before i change my mind."
                   }, cid)              
                   npcHandler.topic[cid] = 0
                if(getPlayerStorageValue(cid, 210) < 1) then
                   setPlayerStorageValue(cid, 210, 1)
                   if(doPlayerRemoveItem(cid, 1947, 1) == TRUE) then
                   player:setStorageValue(12117, 3) -- The Inquisition Questlog- "Mission 4: A Mysterious Hero is Born"
                   doSendMagicEffect(getCreaturePosition(cid), CONST_ME_HOLYAREA)
             end
          end
       end
       return true
    end
     
    npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
    npcHandler:addModule(FocusModule:new())

    Toda aquella funcion que lleva "if" se coloca un "end" al final.

    Como aqui:
    Código:
    if(msgcontains(msg, "i need talk to the king") and getPlayerStorageValue(cid, 208) < 1) then
                if(player:getStorageValue(12116) == 3) then
                  npcHandler:say("hahaha... Do you think it is to arrive and talk to the king?", cid)
                  npcHandler.topic[cid] = 1
            else
                  npcHandler:say("Primero habla con el npc.", cid)
            end

    Solo tiene 2 if pero tiene un end solo. Deberian ser 2 end.

    3 participantes

    3[NPC] problema con npc Empty Re: [NPC] problema con npc Sáb Jul 02, 2022 8:31 pm

    akane

    akane
    Miembro
    Miembro
    volví a hacer la segunda parte otra vez y me funcionó :3

    3 participantes

    4[NPC] problema con npc Empty Re: [NPC] problema con npc Mar Jul 05, 2022 5:44 am

    [Admin] God Maya

    [Admin] God Maya
    Administrador
    Administrador
    Tema Solucionado



    [NPC] problema con npc YNU5B25
    3 participantes
    http://www.tibiaface.com

    Contenido patrocinado


    3 participantes

    Ver el tema anterior Ver el tema siguiente Volver arriba  Mensaje (Página 1 de 1.)

    Permisos de este foro:
    No puedes responder a temas en este foro.

     

    BienvenidosTibiaFace es una comunidad de Open Tibia. Para participar debes estar registrado (click para Regístrate).