• TibiaFace

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

    .
    demo menumenu

    Afiliados



    Votar:

    [Problema] problema con estructura npc

    Compartir:

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

    1[Problema] problema con estructura npc Empty [Problema] problema con estructura npc Sáb Sep 09, 2023 12:18 am

    akane

    akane
    Miembro
    Miembro
    Descripcion escribió:hola a todos, estoy tratando de crear este npc, pero al momento de decirle la palabra clave "expedition" no hace nada, ni si quiera al no tener el storage me dice la frase del else y tampoco me da error, pero al decirle por ejemplo information o no, si funciona.

    Estoy tratando de seguir otros esquemas pero al menos con este npc no me funciona.

    incluso traté colocando como elseif y tampoco funcionó

    Aqui el script:

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

    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

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

     local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
     
     if(msgcontains(msg, 'yes')) then
     selfSay('what are you looking for? ... {information} or {expedition}.', cid)
     talkState[talkUser] = 1
     elseif (msgcontains(msg, 'information') and talkState[talkUser] == 1) then
     if getPlayerStorageValue(cid,20037) >= 1 then
     selfSay('So you are looking for information?.Of course I have information, on an expedition with my comrades we saw those despicable cocoons, some infernal beasts came out of them... Recently another expedition group went, but they have not returned. Do you want to cross this wall?... Hahaha you have courage but it won\'t do you any good, it will only take you to death but since I can\'t stop you, so go and tell the doorman that you have authorization to cross that damn door... Ohh I forgot, that time we went on the expedition I marked the location of the cocoons. Please, if you have news about the group that went on the expedition, let me know. Be careful and don\'t get close to them, otherwise they will start releasing those damn monsters... Good luck, maybe we\'ll see each other soon', cid)
     setPlayerStorageValue(cid,20038,1)
     doPlayerAddItem(cid, 5956, 1)
     talkState[talkUser] = 2
     else
     selfSay('You can not be here, Leave please.', cid)
     end
     
     if (msgcontains(msg, 'expedition') and talkState[talkUser] == 2) then
     if getPlayerStorageValue(cid,21005) >= 1 and getPlayerStorageValue(cid,21006) >= 1 and getPlayerStorageValue(cid,21007) >= 1 and getPlayerStorageValue(cid,21008) >= 1 and getPlayerStorageValue(cid,21009) >= 1 then
     selfSay('I see that not everyone survived... I understand, thank you very much for your help.', cid)
     setPlayerStorageValue(cid,21010,1)
     else
     selfSay('I see you have nothing to say.', cid)
     end
     talkState[talkUser] = 0
     elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser]) == TRUE) then
     talkState[talkUser] = 0
     selfSay('Ok then.', cid)
     end
     return true
     end
     end

    npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
    npcHandler:addModule(FocusModule:new())
    Captura del Error escribió:Imagen del error: [Problema] problema con estructura npc Empty
    El error radica en: Npc

    2 participantes

    2[Problema] problema con estructura npc Empty Re: [Problema] problema con estructura npc Sáb Sep 09, 2023 9:42 am

    SoyFabi

    SoyFabi
    Miembro
    Miembro
    lo que tratas de hacer es: hi, yes, information, expedition?

    Porque en elseif de information tiene: talkState[talkUser] == 2.

    Hasta que no le digas information no le podras decir expedition.

    Si a lo que te refieres es decir: hi, yes, expedition

    Entonces tendras que cambiar:
    Código:
    if (msgcontains(msg, 'expedition') and talkState[talkUser] == 2) then
    Por
    Código:
    if (msgcontains(msg, 'expedition') and talkState[talkUser] == 1) then

    Y en caso de:
    Código:
     talkState[talkUser] = 2
    Por
    Código:
     talkState[talkUser] = 1

    2 participantes

    3[Problema] problema con estructura npc Empty Re: [Problema] problema con estructura npc Sáb Sep 09, 2023 11:05 am

    akane

    akane
    Miembro
    Miembro
    nop, si te fijas, el expedition es despues de conseguir una cantidad de storages, pero el tema es que teniendo o no teniendo los storages no dice ninguna frase, ni la del else ni tampoco la de confirmación

    2 participantes

    4[Problema] problema con estructura npc Empty Re: [Problema] problema con estructura npc Sáb Sep 09, 2023 1:03 pm

    SoyFabi

    SoyFabi
    Miembro
    Miembro
    akane escribió:nop, si te fijas, el expedition es despues de conseguir una cantidad de storages, pero el tema es que teniendo o no teniendo los storages no dice ninguna frase, ni la del else ni tampoco la de confirmación

    Exactamente no se como funciona los codigos del npc, si colocas un if, lo demas tienen que ser elseif msgcontains.

    Aqui esta:
    Código:
    local keywordHandler = KeywordHandler:new()
    local npcHandler = NpcHandler:new(keywordHandler)
    NpcSystem.parseParameters(npcHandler)
    local talkState = {}

    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

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

     local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
     
     --- Decirle Yes para luego decirle Information y luego Expedition --
     if msgcontains(msg, 'yes') then
     selfSay('what are you looking for? ... {information} or {expedition}.', cid)
     talkState[talkUser] = 1
     --- Information --
     elseif msgcontains(msg, 'information') and talkState[talkUser] == 1 then
     if getPlayerStorageValue(cid, 20037) >= 1 then
     selfSay('So you are looking for information?.Of course I have information, on an expedition with my comrades we saw those despicable cocoons, some infernal beasts came out of them... Recently another expedition group went, but they have not returned. Do you want to cross this wall?... Hahaha you have courage but it won\'t do you any good, it will only take you to death but since I can\'t stop you, so go and tell the doorman that you have authorization to cross that damn door... Ohh I forgot, that time we went on the expedition I marked the location of the cocoons. Please, if you have news about the group that went on the expedition, let me know. Be careful and don\'t get close to them, otherwise they will start releasing those damn monsters... Good luck, maybe we\'ll see each other soon', cid)
     setPlayerStorageValue(cid, 20038,1)
     doPlayerAddItem(cid, 5956, 1)
     talkState[talkUser] = 2
     else
     selfSay('You can not be here, Leave please.', cid)
     end
     
     --- Expedition --
     elseif msgcontains(msg, 'expedition') and talkState[talkUser] == 2  then
     if getPlayerStorageValue(cid, 21005) >= 1 and getPlayerStorageValue(cid, 21006) >= 1 and getPlayerStorageValue(cid, 21007) >= 1
     and getPlayerStorageValue(cid, 21008) >= 1 and getPlayerStorageValue(cid, 21009) >= 1 then
     selfSay('I see that not everyone survived... I understand, thank you very much for your help.', cid)
     setPlayerStorageValue(cid, 21010,1)
     else
     selfSay('I see you have nothing to say.', cid)
     end
     
     --- Para el NO --
     elseif msgcontains(msg, 'no') then
     talkState[talkUser] = 0
     selfSay('Ok then.', cid)
     end
     
     return true
    end

    npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
    npcHandler:addModule(FocusModule:new())

    No entiendo la razon cuando colocas el script en el foro se coloca sin espacios ni sangrias, se ve todo feo deformado.
    Aqui esta mas bonito:
    [Tienes que estar registrado y conectado para ver este vínculo]

    2 participantes

    Contenido patrocinado


    2 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).