• TibiaFace

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

    .
    demo menumenu

    Afiliados



    Votar:

    [NPC] ayuda con npc

    Compartir:

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

    1[NPC] ayuda con npc Empty [NPC] ayuda con npc Mar Sep 12, 2023 2:58 am

    akane

    akane
    Miembro
    Miembro
    Descripcion escribió:Hola a todos, necesito ayuda con el siguiente script, resulta que quiero añadirle una misión mas, la cual pida matar x cantidad de monster para que despues de un storage. El problema es que no se como hacerlo ya que probé con diferentes scripts y no me funcionó.

    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 creatureSayCallback(cid, type, msg)
       if(not npcHandler:isFocused(cid)) then
          return false
       end
       
       if getPlayerStorageValue(cid, 20039) >= 1 then
             selfSay('The door is already open, so go ahead tiger...', cid)
             return true
            end

    if (msgcontains(msg, 'yes')) then
       if getPlayerStorageValue(cid,20038) >= 1 then
             selfSay('How long do I let you through this door?... well I know it\'s dangerous, even though I don\'t know what we\'re up against... But hey, you are responsible for your actions so go ahead and good luck', cid)
             setPlayerStorageValue(cid,20039,1)
          else
             selfSay('You can not be here, Leave please.', cid)
          end
          elseif (msgcontains(msg, 'no') or msgcontains(msg, 'no') or msgcontains(msg, 'não')) then
             selfSay('Do not care about it.', cid)
          end
    end

    npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
    npcHandler:addModule(FocusModule:new())
    Imagen Explicativa escribió:Imagen Explicativa: [NPC] ayuda con npc Tibiaf10
    Version del Scripts: TFs 0.4.0

    4 participantes

    2[NPC] ayuda con npc Empty esta es Mar Sep 12, 2023 11:03 pm

    Dfsuno

    Dfsuno
    Miembro
    Miembro
    Es la parte que te pide matar las creaturas y checa si ya terminaste de matarlas, solo tienes que agregar un creature script para ver el conteo de las creaturas muertas.



    4 participantes

    3[NPC] ayuda con npc Empty Re: [NPC] ayuda con npc Mar Sep 12, 2023 11:41 pm

    akane

    akane
    Miembro
    Miembro
    el tema es que ese script es para tfs 1.x y yo uso 0.4

    4 participantes

    4[NPC] ayuda con npc Empty Re: [NPC] ayuda con npc Miér Sep 13, 2023 12:41 am

    SoyFabi

    SoyFabi
    Miembro
    Miembro
    Código:
    function onKill(cid, target)
        if isPlayer(target) or isSummon(target) then
          return true
       end
       
       local storage = 241541 -- Storage que necesita para comenzar la task
       local mon_list = {"rat", "wolf"} -- Lista de monster
       local amounts = 100 -- Cantidad que requiere para completar

       if storage then
          if isInArray(mon_list, getCreatureName(target):lower()) then
             local sto_value = getPlayerStorageValue(cid, storage)
             if sto_value < amounts then
                sto_value = sto_value + 1
                setPlayerStorageValue(cid, storage, sto_value)
                if sto_value < amounts then
                   doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, '[Normal Task] You killed ['..(sto_value)..'/'..amounts..'] '..getCreatureName(target)..'.')
                   doSendAnimatedText(cid, "Task +1", TEXTCOLOR_LIGHTGREEN)
                else
                   doSendAnimatedText("Completed", TEXTCOLOR_LIGHTGREEN)
                   doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, '[Normal Task] You already finished your task, go with Vauter for report the task.')
                end
             end
          end
       end
       
       return true
    end
    Te faltaria el npc que al pedir la task te de el storage 241541

    Esto seria un ejemplo, sinceramente lo hice rapido.
    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

    function creatureSayCallback(cid, type, msg)
        if(not(npcHandler:isFocused(cid))) then
          return false
       end
       
       local storage = 241541
       local amounts = 100

       if msgcontains(msg, "task") then
          if getPlayerStorageValue(cid, storage) >= 0 then
             npcHandler:say("Ya completastes la task?", cid)
             npcHandler.topic[cid] = 1
          else
             npcHandler:say("Quieres hacer una task de matar "..amounts.." Rat?", cid)
             npcHandler.topic[cid] = 1
          end
       elseif msgcontains(msg, "yes") then
          if npcHandler.topic[cid] == 1 then
             if getPlayerStorageValue(cid, storage) >= amounts then
                selfSay("Perfecto aqui tienes tus objetos.", cid)
                npcHandler.topic[cid] = 0
             elseif getPlayerStorageValue(cid, storage) < 0 then
                selfSay("Perfecto, necesito que mates a "..amounts.." rat y cuando la completed, vuelves de nuevo.", cid)
                npcHandler.topic[cid] = 0
                setPlayerStorageValue(cid, storage, 0) -- storage para iniciar task.
             else
                selfSay("Aun no haz completado ninguna task.", cid)
                npcHandler.topic[cid] = 0
             end
          end
       end

       return true
    end
    npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
    npcHandler:addModule(FocusModule:new())

    4 participantes

    5[NPC] ayuda con npc Empty Re: [NPC] ayuda con npc Miér Sep 13, 2023 1:47 am

    akane

    akane
    Miembro
    Miembro
    Código:
    [22:44:15.896] [Error - NpcScript Interface]
    [22:44:15.901] data/npc/scripts/crimson the gateguard.lua:onCreatureSay
    [22:44:15.913] Description:
    [22:44:15.919] data/npc/scripts/crimson the gateguard.lua:37: attempt to index field 'topic' (a nil value)
    [22:44:15.941] stack traceback:
    [22:44:15.946]  data/npc/scripts/crimson the gateguard.lua:37: in function 'callback'
    [22:44:15.956]  data/npc/lib/npcsystem/npchandler.lua:390: in function 'onCreatureSay'
    [22:44:15.966]  data/npc/scripts/crimson the gateguard.lua:8: in function <data/npc/scripts/crimson the gateguard.lua:8>


    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

    function creatureSayCallback(cid, type, msg)
        if(not(npcHandler:isFocused(cid))) then
          return false
       end
      
       local storage = 241541
       local amounts = 100

    if (msgcontains(msg, 'yes')) then
       if getPlayerStorageValue(cid,20038) >= 1 then
             selfSay('How long do I let you through this door?... well I know it\'s dangerous, even though I don\'t know what we\'re up against... But hey, you are responsible for your actions so go ahead and good luck', cid)
             setPlayerStorageValue(cid,20039,1)
          else
             selfSay('You can not be here, Leave please.', cid)
          end
          elseif (msgcontains(msg, 'no') or msgcontains(msg, 'no') or msgcontains(msg, 'não')) then
             selfSay('Do not care about it.', cid)
          end
       
       if msgcontains(msg, "task") then
          if getPlayerStorageValue(cid, storage) >= 0 then
             npcHandler:say("Ya completastes la task?", cid)
             npcHandler.topic[cid] = 1
          else
             npcHandler:say("Quieres hacer una task de matar "..amounts.." Rat?", cid)
             npcHandler.topic[cid] = 1
          end
       elseif msgcontains(msg, "maybe") then
          if npcHandler.topic[cid] == 1 then
             if getPlayerStorageValue(cid, storage) >= amounts then
                selfSay("Perfecto aqui tienes tus objetos.", cid)
                npcHandler.topic[cid] = 0
             elseif getPlayerStorageValue(cid, storage) < 0 then
                selfSay("Perfecto, necesito que mates a "..amounts.." rat y cuando la completed, vuelves de nuevo.", cid)
                npcHandler.topic[cid] = 0
                setPlayerStorageValue(cid, storage, 0) -- storage para iniciar task.
             else
                selfSay("Aun no haz completado ninguna task.", cid)
                npcHandler.topic[cid] = 0
             end
          end
       end

       return true
    end
    npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
    npcHandler:addModule(FocusModule:new())

    lo "arregle" pero al momento de matar al monster no aparece nada

    4 participantes

    6[NPC] ayuda con npc Empty Re: [NPC] ayuda con npc Miér Sep 13, 2023 7:07 pm

    GalaxyDev

    GalaxyDev
    Miembro
    Miembro
    akane escribió:
    Descripcion escribió:Hola a todos, necesito ayuda con el siguiente script, resulta que quiero añadirle una misión mas, la cual pida matar x cantidad de monster para que despues de un storage. El problema es que no se como hacerlo ya que probé con diferentes scripts y no me funcionó.

    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 creatureSayCallback(cid, type, msg)
       if(not npcHandler:isFocused(cid)) then
          return false
       end
       
       if getPlayerStorageValue(cid, 20039) >= 1 then
             selfSay('The door is already open, so go ahead tiger...', cid)
             return true
            end

    if (msgcontains(msg, 'yes')) then
       if getPlayerStorageValue(cid,20038) >= 1 then
             selfSay('How long do I let you through this door?... well I know it\'s dangerous, even though I don\'t know what we\'re up against... But hey, you are responsible for your actions so go ahead and good luck', cid)
             setPlayerStorageValue(cid,20039,1)
          else
             selfSay('You can not be here, Leave please.', cid)
          end
          elseif (msgcontains(msg, 'no') or msgcontains(msg, 'no') or msgcontains(msg, 'não')) then
             selfSay('Do not care about it.', cid)
          end
    end

    npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
    npcHandler:addModule(FocusModule:new())
    Imagen Explicativa escribió:Imagen Explicativa: [NPC] ayuda con npc Tibiaf10
    Version del Scripts: TFs 0.4.0



    Nose si funciona pero cualquier error loo publicas.

    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

    local MONSTER_QUEST_STORAGE = 50000 -- Un valor de almacenamiento único para la misión de matar monstruos
    local REQUIRED_MONSTERS = 10 -- La cantidad requerida de monstruos a matar

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

        local monsterQuestStarted = getCreatureStorage(cid, MONSTER_QUEST_STORAGE)
        local monstersKilled = getCreatureStorage(cid, MONSTER_QUEST_STORAGE + 1)

        if getPlayerStorageValue(cid, 20039) >= 1 then
            selfSay('La puerta ya está abierta, adelante, valiente...', cid)
            return true
        end

        if msgcontains(msg, 'yes') then
            if getPlayerStorageValue(cid, 20038) >= 1 then
                if monsterQuestStarted == -1 then
                    selfSay('¡Has iniciado la misión de caza de monstruos! Debes matar ' .. REQUIRED_MONSTERS .. ' monstruos para completarla.', cid)
                    setCreatureStorage(cid, MONSTER_QUEST_STORAGE, 0) -- Inicia la misión de caza de monstruos
                    setCreatureStorage(cid, MONSTER_QUEST_STORAGE + 1, 0) -- Establece el contador de monstruos a 0
                elseif monsterQuestStarted == 0 then
                    selfSay('Debes matar ' .. REQUIRED_MONSTERS - monstersKilled .. ' monstruos más para completar la misión.', cid)
                elseif monsterQuestStarted == 1 then
                    if monstersKilled >= REQUIRED_MONSTERS then
                        selfSay('¡Felicidades! Has completado la misión de caza de monstruos. Ahora puedes pasar.', cid)
                        setCreatureStorage(cid, MONSTER_QUEST_STORAGE, 2) -- Marca la misión como completada
                    else
                        selfSay('Aún no has matado suficientes monstruos para completar la misión.', cid)
                    end
                elseif monsterQuestStarted == 2 then
                    selfSay('La misión de caza de monstruos ya está completa. Puedes avanzar.', cid)
                end
            else
                selfSay('No puedes estar aquí, por favor, retírate.', cid)
            end
        elseif msgcontains(msg, 'no') then
            selfSay('No te preocupes por eso.', cid)
        end
    end

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



    [Tienes que estar registrado y conectado para ver este vínculo] Servidor 24/7 Full Animes  Smile    MI GITHUB (REVSCRIPTS TFS 1.3-1.5))
    4 participantes

    7[NPC] ayuda con npc Empty Re: [NPC] ayuda con npc Jue Sep 14, 2023 1:49 am

    akane

    akane
    Miembro
    Miembro
    ya encontré un sistema y ya lo estoy terminando de adaptar a la quest y hasta el momento funciona bien, pero gracias a todos por la ayuda Very Happy

    4 participantes

    Contenido patrocinado


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