• TibiaFace

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

    .
    demo menumenu

    Afiliados



    Votar:

    Necesito un npc para tibia 8.70 tfs 0.3.6

    Compartir:

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

    Nemesis811

    Nemesis811
    Miembro
    Miembro
    necesito un npc que las personas al llegar al nivel 100 le pidan un premio al npc y el como premio le de un items xs que uno le ponga pero que no premie a los que usen el mismo ip ni creen varios en una sola cuenta y lo suban a 100 que de premio a cada lvl 100 por ip.... si me explico mejor existirá algo así? Very Happy Smile por favor

    2 participantes

    SoyFabi

    SoyFabi
    Miembro
    Miembro
    Hice algo como esto, cada cierto lvl puedes recoger un premio diciendole al npc Premio.

    La cuestion es lo de la IP, no se como hacerlo, a ver si algun genio te puede ayudar con eso.

    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 rewards = {
        --  Level, items, count. --
        [100] = {items = 2160, count = 5},
        [200] = {items = 2160, count = 10},
        [300] = {items = 2160, count = 15}
    }

    function getNextRewardLevel(currentLevel)
        local nextLevel = nil
        for level, _ in pairs(rewards) do
            if level > currentLevel then
                if nextLevel == nil or level < nextLevel then
                    nextLevel = level
                end
            end
        end
        return nextLevel
    end

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

        local player = Player(cid)
        local storage = 100000 -- storage que se le dara al obtener el premio.

        if msgcontains(msg, "premio") then
            local level = getPlayerLevel(cid)
            local reward = rewards[level]

            if reward then
                if getPlayerStorageValue(cid, storage + level) < 1 then
                    doPlayerAddItem(cid, reward.items, reward.count)
                    setPlayerStorageValue(cid, storage + level, 1)
                    npcHandler:say("Aqui esta tu premio por alcanzar el nivel " .. level .. ".", cid)
                else
                    npcHandler:say("Lo siento, ya has recogido tu premio para este nivel.", cid)
                end
            else
                local nextLevel = getNextRewardLevel(level)
                if nextLevel then
                    npcHandler:say("Lo siento, no tienes el nivel requerido, necesitas ser nivel " .. nextLevel .. ".", cid)
                else
                    npcHandler:say("No mas premios, ya haz recogido todos.", cid)
                end
            end
        end

        return true
    end

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

    2 participantes

    3Necesito un npc para tibia 8.70 tfs 0.3.6 Empty gracias amigo Jue Feb 22, 2024 10:22 pm

    Nemesis811

    Nemesis811
    Miembro
    Miembro
    graciAS AMIGO BUENO LO PROBARE ERES MUY AMABLE

    2 participantes

    4Necesito un npc para tibia 8.70 tfs 0.3.6 Empty no funciono Vie Feb 23, 2024 9:21 pm

    Nemesis811

    Nemesis811
    Miembro
    Miembro
    no funciona amigo le digo hi premio y no me dice nada me contesta pero no me dice mas nada

    2 participantes

    5Necesito un npc para tibia 8.70 tfs 0.3.6 Empty error de consola Vie Feb 23, 2024 9:23 pm

    Nemesis811

    Nemesis811
    Miembro
    Miembro
    Sad Sad Sad Sad


    y sale esto en la consola



    [3:14:30.393] [Error - NpcScript Interface]
    [3:14:30.393] data/npc/scripts/Presents.lua:onCreatureSay
    [3:14:30.393] Description:
    [3:14:30.393] data/npc/scripts/Presents.lua:42: attempt to call global 'Player' (a nil value)
    [3:14:30.393] stack traceback:
    [3:14:30.393] data/npc/scripts/Presents.lua:42: in function 'callback'
    [3:14:30.393] data/npc/lib/npcsystem/npchandler.lua:456: in function 'onCreatureSay'
    [3:14:30.393] data/npc/scripts/Presents.lua:12: in function <data/npc/scripts/Presents.lua:11>

    2 participantes

    SoyFabi

    SoyFabi
    Miembro
    Miembro
    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 rewards = {
        --  Level, items, count. --
        [100] = {items = 2160, count = 5},
        [200] = {items = 2160, count = 10},
        [300] = {items = 2160, count = 15}
    }

    function getNextRewardLevel(currentLevel)
        local nextLevel = nil
        for level, _ in pairs(rewards) do
            if level > currentLevel then
                if nextLevel == nil or level < nextLevel then
                    nextLevel = level
                end
            end
        end
        return nextLevel
    end

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

        local storage = 100000 -- storage que se le dara al obtener el premio.

        if msgcontains(msg, "premio") then
            local level = getPlayerLevel(cid)
            local reward = rewards[level]

            if reward then
                if getPlayerStorageValue(cid, storage + level) < 1 then
                    doPlayerAddItem(cid, reward.items, reward.count)
                    setPlayerStorageValue(cid, storage + level, 1)
                    npcHandler:say("Aqui esta tu premio por alcanzar el nivel " .. level .. ".", cid)
                else
                    npcHandler:say("Lo siento, ya has recogido tu premio para este nivel.", cid)
                end
            else
                local nextLevel = getNextRewardLevel(level)
                if nextLevel then
                    npcHandler:say("Lo siento, no tienes el nivel requerido, necesitas ser nivel " .. nextLevel .. ".", cid)
                else
                    npcHandler:say("No mas premios, ya haz recogido todos.", cid)
                end
            end
        end

        return true
    end

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

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