• TibiaFace

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

    .
    demo menumenu

    Afiliados



    Votar:

    script de npc

    Compartir:

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

    1script de npc Empty script de npc Vie Mar 27, 2020 12:52 pm

    Kilombero

    Kilombero
    Nuevo Miembro
    Nuevo Miembro
    Buenas, tengo el siguiente npc:

    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

    local storage = 5000

    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, "mission") then
            if getPlayerStorageValue(cid, storage) == -1 then
                selfSay("My daughter lost her doll, I saw a monster taking it that went in this cave, but I\'m to affraid to go there, can you get it for me?", cid)
                talkState[talkUser] = 1
            elseif getPlayerStorageValue(cid, storage) == 1 then
                selfSay("Did you find the doll?", cid)
                talkState[talkUser] = 1
            else
                selfSay("Thanks again for finding the doll.", cid)
            end
        elseif msgcontains(msg, "yes") and talkState[talkUser] == 1 then
            if getPlayerStorageValue(cid, storage) == -1 then
                selfSay("Thanks alot, come back when you have it.", cid)
                setPlayerStorageValue(cid, storage, 1)
            else
                if(doPlayerRemoveItem(cid, 2110, 1)) then
                    selfSay("That's great, my daughter will be really happy, thanks.", cid)
                    doPlayerAddItem(cid, 2160, 3)
                    doPlayerAddExp(cid, 5000)
                    setPlayerStorageValue(cid, storage, 2)
                else
                    selfSay("You don't have it.", cid)
                end
            end
            talkState[talkUser] = 0
        elseif msgcontains(msg, "no") and talkState[talkUser] == 1 then
            selfSay("Ok then.", cid)
            talkState[talkUser] = 0
        end
        return true
    end

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

    es un npc que pide encontrar un objeto y luego entrega una recompensa, quisiera que alguien me ayude a agregar para que pida 3 objetos en total en vez de uno.

    2 participantes

    2script de npc Empty Re: script de npc Vie Mar 27, 2020 2:25 pm

    [Admin] God Maya

    [Admin] God Maya
    Administrador
    Administrador
    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

            local storage = 5000

            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, "mission") then
                    if getPlayerStorageValue(cid, storage) == -1 then
                        selfSay("My daughter lost her doll, I saw a monster taking it that went in this cave, but I\'m to affraid to go there, can you get it for me?", cid)
                        talkState[talkUser] = 1
                    elseif getPlayerStorageValue(cid, storage) == 1 then
                        selfSay("Did you find the doll?", cid)
                        talkState[talkUser] = 1
                    else
                        selfSay("Thanks again for finding the doll.", cid)
                    end
                elseif msgcontains(msg, "yes") and talkState[talkUser] == 1 then
                    if getPlayerStorageValue(cid, storage) == -1 then
                        selfSay("Thanks alot, come back when you have it.", cid)
                        setPlayerStorageValue(cid, storage, 1)
                    else
                        if(doPlayerRemoveItem(cid, 2110, 1) and doPlayerRemoveItem(cid, 2110, 1) and doPlayerRemoveItem(cid, 2110, 1)) then ------> ahi tiene 3 objetos que pedira modifica sus id
                            selfSay("That's great, my daughter will be really happy, thanks.", cid)
                            doPlayerAddItem(cid, 2160, 3)
                            doPlayerAddExp(cid, 5000)
                            setPlayerStorageValue(cid, storage, 2)
                        else
                            selfSay("You don't have it.", cid)
                        end
                    end
                    talkState[talkUser] = 0
                elseif msgcontains(msg, "no") and talkState[talkUser] == 1 then
                    selfSay("Ok then.", cid)
                    talkState[talkUser] = 0
                end
                return true
            end

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




    script de npc YNU5B25
    2 participantes
    http://www.tibiaface.com

    3script de npc Empty Re: script de npc Dom Mar 29, 2020 1:01 pm

    Kilombero

    Kilombero
    Nuevo Miembro
    Nuevo Miembro
    Gracias ! Resuelto

    2 participantes

    4script de npc Empty Re: script de npc Dom Mar 29, 2020 3:57 pm

    [Admin] God Maya

    [Admin] God Maya
    Administrador
    Administrador
    Tema Resuelto



    script de npc YNU5B25
    2 participantes
    http://www.tibiaface.com

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