• TibiaFace

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

    .
    demo menumenu

    Afiliados



    Votar:

    [CreatureEvents] Npc no mantiene el storage de buff

    Compartir:

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

    Morfar

    Morfar
    Miembro
    Miembro
    Descripcion escribió:Amigos buenas noches que tal nuevamente solicitando de su apoyo con este sistema que encontre el sistema funciona como tal es un npc que te da un buff temporal a tu eleccion, el problema es que al logear o morir pierdes el buff, entonces coloque el siguiente storage en creaturescripts
    Código:
    function onLogin(cid)
        if isPlayer(cid) then
            setPlayerStorageValue(cid, 77700, -1)
        end
        return true
    end
    Si mantiene el tiempo ya que no me permite pedirle al npc el buff, el problema si logeo o muero pierdo el buff que pedi pero el tiempo si me lo mantiene ya que no me deja pedirle al npc nuevamente el buff hasta pasar el tiempo ojala puedan ayudarme les adjunto el script es tfs 0.4 dev 8.6
    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

    -- Buff Config beginning --

    -- configs
    local config = {
        storage = 77700,
        value = 1,
    }
    money = 2000
    invisibleseconds = 600
    magicshieldseconds = 600
    regeseconds = 600
    speedseconds = 600
    skillsseconds = 600
    skillsupgrade = {}
    skillsupgrade['fist'] = 130
    skillsupgrade['club'] = 130
    skillsupgrade['sword'] = 130
    skillsupgrade['axe'] = 135
    skillsupgrade['distance'] = 60
    skillsupgrade['shield'] = 50
    skillsupgrade['ml'] = 10
    -- end configs

    -- Configs of buffs

    local conditionMagic = createConditionObject(CONDITION_ATTRIBUTES)
    setConditionParam(conditionMagic, CONDITION_PARAM_BUFF, true)
    setConditionParam(conditionMagic, CONDITION_PARAM_TICKS, skillsseconds * 1000)
    setConditionParam(conditionMagic, CONDITION_PARAM_STAT_MAGICLEVEL, skillsupgrade['ml'])

    local combatInvisible = createConditionObject(CONDITION_INVISIBLE)
    setConditionParam(combatInvisible, CONDITION_PARAM_BUFF, true)
    setConditionParam(combatInvisible, CONDITION_PARAM_TICKS, invisibleseconds*1000)

    local conditionMelee = createConditionObject(CONDITION_ATTRIBUTES)
    setConditionParam(conditionMelee, CONDITION_PARAM_BUFF, true)
    setConditionParam(conditionMelee, CONDITION_PARAM_TICKS, skillsseconds*5600)
    setConditionParam(conditionMelee, CONDITION_PARAM_SKILL_FIST, skillsupgrade['fist'])
    setConditionParam(conditionMelee, CONDITION_PARAM_SKILL_CLUB, skillsupgrade['club'])
    setConditionParam(conditionMelee, CONDITION_PARAM_SKILL_SWORD, skillsupgrade['sword'])
    setConditionParam(conditionMelee, CONDITION_PARAM_SKILL_AXE, skillsupgrade['axe'])

    local conditionDistance = createConditionObject(CONDITION_ATTRIBUTES)
    setConditionParam(conditionDistance, CONDITION_PARAM_BUFF, true)
    setConditionParam(conditionDistance, CONDITION_PARAM_TICKS, skillsseconds*5600)
    setConditionParam(conditionDistance, CONDITION_PARAM_SKILL_DISTANCE, skillsupgrade['distance'])

    local conditionShield = createConditionObject(CONDITION_ATTRIBUTES)
    setConditionParam(conditionShield, CONDITION_PARAM_BUFF, true)
    setConditionParam(conditionShield, CONDITION_PARAM_TICKS, skillsseconds*1000)
    setConditionParam(conditionShield, CONDITION_PARAM_SKILL_SHIELD, skillsupgrade['shield'])

    local combatUtamo = createConditionObject(CONDITION_MANASHIELD)
    setConditionParam(combatUtamo, CONDITION_PARAM_BUFF, true)
    setConditionParam(combatUtamo, CONDITION_PARAM_TICKS, magicshieldseconds*1000)

    local conditionRege = createConditionObject(CONDITION_REGENERATION)
    setConditionParam(conditionRege, CONDITION_PARAM_BUFF, true)
    setConditionParam(conditionRege, CONDITION_PARAM_TICKS, regeseconds*1000)
    setConditionParam(conditionRege, CONDITION_PARAM_HEALTHGAIN, 20)
    setConditionParam(conditionRege, CONDITION_PARAM_HEALTHTICKS, 2000)

    local conditionspeed = createConditionObject(CONDITION_HASTE)
    setConditionParam(conditionspeed, CONDITION_PARAM_BUFF, true)
    setConditionParam(conditionspeed, CONDITION_PARAM_TICKS, speedseconds*1000)
    setConditionFormula(conditionspeed, 1.0, -86, 1.0, -86)

    -- Configs of buffs

    function magicl(cid, message, keywords, parameters, node)
        local guid = getPlayerGUID(cid)

        if not npcHandler:isFocused(cid) then
            return false
        end

        if (isPlayer(cid) or isSorcerer(cid)) and getCreatureStorage(cid, config.storage) == -1 then
            if getPlayerMoney(cid) >= 50000 then
                doPlayerRemoveMoney(cid, 50000)
                doAddCondition(cid, conditionMagic)
                npcHandler:say('Your magic level has increased for 10 minutes!', cid)
                setPlayerStorageValue(cid, config.storage, config.value)     
                addEvent(db.executeQuery, skillsseconds * 1000, "UPDATE `player_storage` SET `key` = " .. config.storage .. ", `value` = -1 WHERE `player_id` = " .. guid .. " LIMIT 1;")
            else
                npcHandler:say('You don\'t have such money.', cid)
            end
        else
            npcHandler:say('You must be a druid or a sorcerer to receive this increment.', cid)
        end
    end

    function invisible(cid, message, keywords, parameters, node)
        local guid = getPlayerGUID(cid)

        if not npcHandler:isFocused(cid) then
            return false
        end

        if (isPlayer(cid) or isSorcerer(cid)) and getCreatureStorage(cid, config.storage) == -1 then
            if getPlayerMoney(cid) >= 50000 then
                doPlayerRemoveMoney(cid, 50000)
                npcHandler:say('You received invisibility for 10 minutes!', cid)
                doAddCondition(cid, combatInvisible)
                setPlayerStorageValue(cid, config.storage, config.value)     
                addEvent(db.executeQuery, invisibleseconds * 1000, "UPDATE `player_storage` SET `key` = " .. config.storage .. ", `value` = -1 WHERE `player_id` = " .. guid .. " LIMIT 1;")
            else
                npcHandler:say('You don\'t have such money.', cid)
            end
        else
            npcHandler:say('You must be a druid or a sorcerer to receive this increment.', cid)
        end
    end

    function melee(cid, message, keywords, parameters, node)
        local guid = getPlayerGUID(cid)

        if not npcHandler:isFocused(cid) then
            return false
        end

        if isPlayer(cid) and getCreatureStorage(cid, config.storage) == -1 then
            if getPlayerMoney(cid) >= 50000 then
                doPlayerRemoveMoney(cid, 50000)
                doAddCondition(cid, conditionMelee)
                npcHandler:say('Your Melee Skills has increased for 60 minutes!', cid)
                setPlayerStorageValue(cid, config.storage, config.value)     
                addEvent(db.executeQuery, skillsseconds * 1000, "UPDATE `player_storage` SET `key` = " .. config.storage .. ", `value` = -1 WHERE `player_id` = " .. guid .. " LIMIT 1;")
            else
                npcHandler:say('You don\'t have such money.', cid)
            end
        else
            npcHandler:say('You must be a knight to receive this increment.', cid)
        end
    end

    function distance(cid, message, keywords, parameters, node)
        local guid = getPlayerGUID(cid)

        if not npcHandler:isFocused(cid) then
            return false
        end

        if isPlayer(cid) and getCreatureStorage(cid, config.storage) == -1 then
            if getPlayerMoney(cid) >= 50000 then
                doPlayerRemoveMoney(cid, 50000)
                  doAddCondition(cid, conditionDistance)
                npcHandler:say('Your Distance Skill has increased for 60 minutes!', cid)
                setPlayerStorageValue(cid, config.storage, config.value)     
                addEvent(db.executeQuery, skillsseconds * 1000, "UPDATE `player_storage` SET `key` = " .. config.storage .. ", `value` = -1 WHERE `player_id` = " .. guid .. " LIMIT 1;")
            else
                npcHandler:say('You don\'t have such money.', cid)
            end
        else
            npcHandler:say('You must be a Paladin to receive this increment.', cid)
        end
    end


    function shield(cid, message, keywords, parameters, node)
        local guid = getPlayerGUID(cid)

        if not npcHandler:isFocused(cid) then
            return false
        end

        if (isPaladin(cid) or isKnight(cid)) and getCreatureStorage(cid, config.storage) == -1 then
            if getPlayerMoney(cid) >= 50000 then
                doPlayerRemoveMoney(cid, 50000)
                    doAddCondition(cid, conditionShield)
                npcHandler:say('Your Shielding Skill has increased for 10 minutes!', cid)
                setPlayerStorageValue(cid, config.storage, config.value)     
                addEvent(db.executeQuery, skillsseconds * 1000, "UPDATE `player_storage` SET `key` = " .. config.storage .. ", `value` = -1 WHERE `player_id` = " .. guid .. " LIMIT 1;")
            else
                npcHandler:say('You don\'t have such money.', cid)
            end
        else
            npcHandler:say('You must be a Paladin or a Knight to receive this increment.', cid)
        end
    end


    function magicshield(cid, message, keywords, parameters, node)
        local guid = getPlayerGUID(cid)

        if not npcHandler:isFocused(cid) then
            return false
        end

        if (isPaladin(cid) or isDruid(cid) or isSorcerer(cid) or isPlayer(cid)) and getCreatureStorage(cid, config.storage) == -1 then
            if getPlayerMoney(cid) >= 50000 then
                doPlayerRemoveMoney(cid, 50000)
                      doAddCondition(cid, combatUtamo)
                npcHandler:say('You received a Magic Shield for 10 minutes!', cid)
                setPlayerStorageValue(cid, config.storage, config.value)     
                addEvent(db.executeQuery, magicshieldseconds * 1000, "UPDATE `player_storage` SET `key` = " .. config.storage .. ", `value` = -1 WHERE `player_id` = " .. guid .. " LIMIT 1;")
            else
                npcHandler:say('You don\'t have such money.', cid)
            end
        else
            npcHandler:say('Knights can\'t receive this increment.', cid)
        end
    end


    function regener(cid, message, keywords, parameters, node)
        local guid = getPlayerGUID(cid)

        if not npcHandler:isFocused(cid) then
            return false
        end

        if isPlayer(cid) and getCreatureStorage(cid, config.storage) == -1 then
            if getPlayerMoney(cid) >= 50000 then
                doPlayerRemoveMoney(cid, 50000)
                      doAddCondition(cid, conditionRege)
                npcHandler:say('Your regeneration has increased for 10 minutes!', cid)
                setPlayerStorageValue(cid, config.storage, config.value)     
                addEvent(db.executeQuery, regeseconds * 1000, "UPDATE `player_storage` SET `key` = " .. config.storage .. ", `value` = -1 WHERE `player_id` = " .. guid .. " LIMIT 1;")
            else
                npcHandler:say('You don\'t have such money.', cid)
            end
        else
            npcHandler:say('You can\'t receive more than two increases.', cid)
        end
    end


    function speed(cid, message, keywords, parameters, node)
        local guid = getPlayerGUID(cid)

        if not npcHandler:isFocused(cid) then
            return false
        end

        if isPlayer(cid) and getCreatureStorage(cid, config.storage) == -1 then
            if getPlayerMoney(cid) >= 50000 then
                doPlayerRemoveMoney(cid, 50000)
                    doAddCondition(cid, conditionspeed)
                npcHandler:say('Your speed has increased for 10 minutes!', cid)
                setPlayerStorageValue(cid, config.storage, config.value)     
                addEvent(db.executeQuery, speedseconds * 1000, "UPDATE `player_storage` SET `key` = " .. config.storage .. ", `value` = -1 WHERE `player_id` = " .. guid .. " LIMIT 1;")
            else
                npcHandler:say('You don\'t have such money.', cid)
            end
        else
            npcHandler:say('You can\'t receive more than two increases.', cid)
        end
    end
    -- Buff Config End --

    keywordHandler:addKeyword({'help'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I can increase your {melee}, {distance}, {shielding}, {magic level}, {regeneration}, {invisibility}, {magic shield} and {speed}"})

    local node1 = keywordHandler:addKeyword({'magic level'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to increase your magic level for a certain time?'})
        node1:addChildKeyword({'yes'}, magicl, {npcHandler = npcHandler, onlyFocus = true, reset = true})
        node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back if you want an upgrade in your skills.', reset = true})

    local node2 = keywordHandler:addKeyword({'invisibility'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to be invisible for a certain time?'})
        node2:addChildKeyword({'yes'}, invisible, {npcHandler = npcHandler, onlyFocus = true, reset = true})
        node2:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back if you want an upgrade in your skills.', reset = true})

    local node3 = keywordHandler:addKeyword({'melee'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to increase your melee skills for a certain time?'})
        node3:addChildKeyword({'yes'}, melee, {npcHandler = npcHandler, onlyFocus = true, reset = true})
        node3:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back if you want an upgrade in your skills.', reset = true})

    local node4 = keywordHandler:addKeyword({'distance'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to increase your distance skills for a certain time?'})
        node4:addChildKeyword({'yes'}, distance, {npcHandler = npcHandler, onlyFocus = true, reset = true})
        node4:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back if you want an upgrade in your skills.', reset = true})

    local node5 = keywordHandler:addKeyword({'shielding'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to increase your shielding skill for a certain time?'})
        node5:addChildKeyword({'yes'}, shield, {npcHandler = npcHandler, onlyFocus = true, reset = true})
        node5:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back if you want an upgrade in your skills.', reset = true})

    local node6 = keywordHandler:addKeyword({'magic shield'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to receive a magic shield for a certain time?'})
        node6:addChildKeyword({'yes'}, magicshield, {npcHandler = npcHandler, onlyFocus = true, reset = true})
        node6:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back if you want an upgrade in your skills.', reset = true})

    local node7 = keywordHandler:addKeyword({'regeneration'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to increase your regeneration for a certain time?'})
        node7:addChildKeyword({'yes'}, regener, {npcHandler = npcHandler, onlyFocus = true, reset = true})
        node7:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back if you want an upgrade in your skills.', reset = true})

    local node8 = keywordHandler:addKeyword({'speed'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to increase your speed for a certain time?'})
        node8:addChildKeyword({'yes'}, speed, {npcHandler = npcHandler, onlyFocus = true, reset = true})
        node8:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back if you want an upgrade in your skills.', reset = true})

    npcHandler:addModule(FocusModule:new())
    Captura del Error escribió:Imagen del error: [CreatureEvents] Npc no mantiene el storage de buff Empty
    El error radica en: CreatureScript

    3 participantes

    [Admin] God Maya

    [Admin] God Maya
    Administrador
    Administrador
    tendrias que modificar por un

    Código:
      setPlayerStorageValue(cid, config.storage, config.value)

    con os.time



    [CreatureEvents] Npc no mantiene el storage de buff YNU5B25
    3 participantes
    http://www.tibiaface.com

    Morfar

    Morfar
    Miembro
    Miembro
    Eso como se hace papu disculpa? Jajaajaj

    3 participantes

    [Admin] God Maya

    [Admin] God Maya
    Administrador
    Administrador
    creo que tu sistema no serviria que le hagamos aquello ya que solo interviene npc yno un creaturescripts tendrias que usar un sistema de aura donde intervenga creaturescripts para hacer la verificacion



    [CreatureEvents] Npc no mantiene el storage de buff YNU5B25
    3 participantes
    http://www.tibiaface.com

    Josens

    Josens
    Miembro
    Miembro
    Bien, intenta con este script para tu npc:

    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

    -- configs
    local storage = 77700
    local Seconds = {
        melee = 3600,
        distance = 600,
        magicLevel = 600,
        invisible = 600,
        manaShield = 600,
        regeneration = 600,
        speed = 600,
        shield = 600
    }

    local skillsupgrade = {}
    local skillsupgrade['fist'] = 130
    local skillsupgrade['club'] = 130
    local skillsupgrade['sword'] = 130
    local skillsupgrade['axe'] = 135
    local skillsupgrade['distance'] = 60
    local skillsupgrade['shield'] = 50
    local skillsupgrade['ml'] = 10
    -- end configs

    -- Configs of buffs
    local conditionMagic = createConditionObject(CONDITION_ATTRIBUTES)
    setConditionParam(conditionMagic, CONDITION_PARAM_BUFF, true)
    setConditionParam(conditionMagic, CONDITION_PARAM_TICKS, Seconds.magicLevel * 1000)
    setConditionParam(conditionMagic, CONDITION_PARAM_STAT_MAGICLEVEL, skillsupgrade['ml'])

    local combatInvisible = createConditionObject(CONDITION_INVISIBLE)
    setConditionParam(combatInvisible, CONDITION_PARAM_BUFF, true)
    setConditionParam(combatInvisible, CONDITION_PARAM_TICKS, Seconds.invisible*1000)

    local conditionMelee = createConditionObject(CONDITION_ATTRIBUTES)
    setConditionParam(conditionMelee, CONDITION_PARAM_BUFF, true)
    setConditionParam(conditionMelee, CONDITION_PARAM_TICKS, Seconds.melee*1000)
    setConditionParam(conditionMelee, CONDITION_PARAM_SKILL_FIST, skillsupgrade['fist'])
    setConditionParam(conditionMelee, CONDITION_PARAM_SKILL_CLUB, skillsupgrade['club'])
    setConditionParam(conditionMelee, CONDITION_PARAM_SKILL_SWORD, skillsupgrade['sword'])
    setConditionParam(conditionMelee, CONDITION_PARAM_SKILL_AXE, skillsupgrade['axe'])

    local conditionDistance = createConditionObject(CONDITION_ATTRIBUTES)
    setConditionParam(conditionDistance, CONDITION_PARAM_BUFF, true)
    setConditionParam(conditionDistance, CONDITION_PARAM_TICKS, Seconds.distance*1000)
    setConditionParam(conditionDistance, CONDITION_PARAM_SKILL_DISTANCE, skillsupgrade['distance'])

    local conditionShield = createConditionObject(CONDITION_ATTRIBUTES)
    setConditionParam(conditionShield, CONDITION_PARAM_BUFF, true)
    setConditionParam(conditionShield, CONDITION_PARAM_TICKS, Seconds.shield*1000)
    setConditionParam(conditionShield, CONDITION_PARAM_SKILL_SHIELD, skillsupgrade['shield'])

    local combatUtamo = createConditionObject(CONDITION_MANASHIELD)
    setConditionParam(combatUtamo, CONDITION_PARAM_BUFF, true)
    setConditionParam(combatUtamo, CONDITION_PARAM_TICKS, Seconds.manaShield*1000)

    local conditionRege = createConditionObject(CONDITION_REGENERATION)
    setConditionParam(conditionRege, CONDITION_PARAM_BUFF, true)
    setConditionParam(conditionRege, CONDITION_PARAM_TICKS, Seconds.regeneration*1000)
    setConditionParam(conditionRege, CONDITION_PARAM_HEALTHGAIN, 20)
    setConditionParam(conditionRege, CONDITION_PARAM_HEALTHTICKS, 2000)

    local conditionspeed = createConditionObject(CONDITION_HASTE)
    setConditionParam(conditionspeed, CONDITION_PARAM_BUFF, true)
    setConditionParam(conditionspeed, CONDITION_PARAM_TICKS, Seconds.speed*1000)
    setConditionFormula(conditionspeed, 1.0, -86, 1.0, -86)

    -- Configs of buffs

    function magicl(cid, message, keywords, parameters, node)
        if not npcHandler:isFocused(cid) then return false end
        if (isPlayer(cid) or isSorcerer(cid)) and getCreatureStorage(cid, storage) == -1 then
            if getPlayerMoney(cid) >= 50000 then
                doPlayerRemoveMoney(cid, 50000)
                doAddCondition(cid, conditionMagic)
                npcHandler:say('Your magic level has increased for ' ..math.floor(Seconds.magic / 60) .. ' minute' ..(math.floor(Seconds.magic / 60) ~= 1 and "s" or "").. '!', cid)
                setPlayerStorageValue(cid, storage, os.time() + Seconds.magic)
                setPlayerStorageValue(cid, storage + 1, 1) -- No editar
            else
                npcHandler:say('You don\'t have such money.', cid)
            end
        else
            npcHandler:say('You must be a druid or a sorcerer to receive this increment.', cid)
        end
    end

    function invisible(cid, message, keywords, parameters, node)
        if not npcHandler:isFocused(cid) then return false end
        if (isPlayer(cid) or isSorcerer(cid)) and getCreatureStorage(cid, storage) == -1 then
            if getPlayerMoney(cid) >= 50000 then
                doPlayerRemoveMoney(cid, 50000)
                doAddCondition(cid, combatInvisible)
                npcHandler:say('Your invisible skill has increased for ' ..math.floor(Seconds.invisible / 60) .. ' minute' ..(math.floor(Seconds.invisible / 60) ~= 1 and "s" or "").. '!', cid)
                setPlayerStorageValue(cid, storage, os.time() + Seconds.invisible)
                setPlayerStorageValue(cid, storage + 1, 2) -- No editar
            else
                npcHandler:say('You don\'t have such money.', cid)
            end
        else
            npcHandler:say('You must be a druid or a sorcerer to receive this increment.', cid)
        end
    end

    function melee(cid, message, keywords, parameters, node)
        if not npcHandler:isFocused(cid) then return false end
        if isPlayer(cid) and getCreatureStorage(cid, storage) == -1 then
            if getPlayerMoney(cid) >= 50000 then
                doPlayerRemoveMoney(cid, 50000)
                doAddCondition(cid, conditionMelee)
                npcHandler:say('Your melee has increased for ' ..math.floor(Seconds.melee / 60) .. ' minute' ..(math.floor(Seconds.melee / 60) ~= 1 and "s" or "").. '!', cid)
                setPlayerStorageValue(cid, storage, os.time() + Seconds.melee)
                setPlayerStorageValue(cid, storage + 1, 3) -- No editar
            else
                npcHandler:say('You don\'t have such money.', cid)
            end
        else
            npcHandler:say('You must be a knight to receive this increment.', cid)
        end
    end

    function distance(cid, message, keywords, parameters, node)
        if not npcHandler:isFocused(cid) then return false end
        if isPlayer(cid) and getCreatureStorage(cid, storage) == -1 then
            if getPlayerMoney(cid) >= 50000 then
                doPlayerRemoveMoney(cid, 50000)
                doAddCondition(cid, conditionDistance)
                npcHandler:say('Your distance has increased for ' ..math.floor(Seconds.distance / 60) .. ' minute' ..(math.floor(Seconds.distance / 60) ~= 1 and "s" or "").. '!', cid)
                setPlayerStorageValue(cid, storage, os.time() + Seconds.distance)
                setPlayerStorageValue(cid, storage + 1, 4) -- No editar
            else
                npcHandler:say('You don\'t have such money.', cid)
            end
        else
            npcHandler:say('You must be a Paladin to receive this increment.', cid)
        end
    end


    function shield(cid, message, keywords, parameters, node)
        if not npcHandler:isFocused(cid) then return false end
        if (isPaladin(cid) or isKnight(cid)) and getCreatureStorage(cid, storage) == -1 then
            if getPlayerMoney(cid) >= 50000 then
                doPlayerRemoveMoney(cid, 50000)
                doAddCondition(cid, conditionShield)
                npcHandler:say('Your shielding has increased for ' ..math.floor(Seconds.shield / 60) .. ' minute' ..(math.floor(Seconds.shield / 60) ~= 1 and "s" or "").. '!', cid)
                setPlayerStorageValue(cid, storage, os.time() + Seconds.shield)
                setPlayerStorageValue(cid, storage + 1, 5) -- No editar
            else
                npcHandler:say('You don\'t have such money.', cid)
            end
        else
            npcHandler:say('You must be a Paladin or a Knight to receive this increment.', cid)
        end
    end


    function magicshield(cid, message, keywords, parameters, node)
        if not npcHandler:isFocused(cid) then return false end
        if (isPaladin(cid) or isDruid(cid) or isSorcerer(cid) or isPlayer(cid)) and getCreatureStorage(cid, storage) == -1 then
            if getPlayerMoney(cid) >= 50000 then
                doPlayerRemoveMoney(cid, 50000)
                doAddCondition(cid, combatUtamo)
                npcHandler:say('You received magic shield for ' ..math.floor(Seconds.manaShield / 60) .. ' minute' ..(math.floor(Seconds.manaShield / 60) ~= 1 and "s" or "").. '!', cid)
                setPlayerStorageValue(cid, storage, os.time() + Seconds.manaShield)
                setPlayerStorageValue(cid, storage + 1, 6) -- No editar
            else
                npcHandler:say('You don\'t have such money.', cid)
            end
        else
            npcHandler:say('Knights can\'t receive this increment.', cid)
        end
    end


    function regener(cid, message, keywords, parameters, node)
        if not npcHandler:isFocused(cid) then return false end
        if isPlayer(cid) and getCreatureStorage(cid, storage) == -1 then
            if getPlayerMoney(cid) >= 50000 then
                doPlayerRemoveMoney(cid, 50000)
                doAddCondition(cid, conditionRege)
                npcHandler:say('Your regeneration has increased for ' ..math.floor(Seconds.regeneration / 60) .. ' minute' ..(math.floor(Seconds.regeneration / 60) ~= 1 and "s" or "").. '!', cid)
                setPlayerStorageValue(cid, storage, os.time() + Seconds.regeneration)
                setPlayerStorageValue(cid, storage + 1, 7) -- No editar
            else
                npcHandler:say('You don\'t have such money.', cid)
            end
        else
            npcHandler:say('You can\'t receive more than two increases.', cid)
        end
    end


    function speed(cid, message, keywords, parameters, node)
        if not npcHandler:isFocused(cid) then return false end
        if isPlayer(cid) and getCreatureStorage(cid, storage) == -1 then
            if getPlayerMoney(cid) >= 50000 then
                doPlayerRemoveMoney(cid, 50000)
                doAddCondition(cid, conditionspeed)
                npcHandler:say('Your speed has increased for ' ..math.floor(Seconds.speed / 60) .. ' minute' ..(math.floor(Seconds.speed / 60) ~= 1 and "s" or "").. '!', cid)
                setPlayerStorageValue(cid, storage, os.time() + Seconds.speed)
                setPlayerStorageValue(cid, storage + 1,  -- No editar
            else
                npcHandler:say('You don\'t have such money.', cid)
            end
        else
            npcHandler:say('You can\'t receive more than two increases.', cid)
        end
    end
    -- Buff Config End --

    keywordHandler:addKeyword({'help'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I can increase your {melee}, {distance}, {shielding}, {magic level}, {regeneration}, {invisibility}, {magic shield} and {speed}"})

    local node1 = keywordHandler:addKeyword({'magic level'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to increase your magic level for a certain time?'})
        node1:addChildKeyword({'yes'}, magicl, {npcHandler = npcHandler, onlyFocus = true, reset = true})
        node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back if you want an upgrade in your skills.', reset = true})

    local node2 = keywordHandler:addKeyword({'invisibility'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to be invisible for a certain time?'})
        node2:addChildKeyword({'yes'}, invisible, {npcHandler = npcHandler, onlyFocus = true, reset = true})
        node2:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back if you want an upgrade in your skills.', reset = true})

    local node3 = keywordHandler:addKeyword({'melee'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to increase your melee skills for a certain time?'})
        node3:addChildKeyword({'yes'}, melee, {npcHandler = npcHandler, onlyFocus = true, reset = true})
        node3:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back if you want an upgrade in your skills.', reset = true})

    local node4 = keywordHandler:addKeyword({'distance'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to increase your distance skills for a certain time?'})
        node4:addChildKeyword({'yes'}, distance, {npcHandler = npcHandler, onlyFocus = true, reset = true})
        node4:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back if you want an upgrade in your skills.', reset = true})

    local node5 = keywordHandler:addKeyword({'shielding'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to increase your shielding skill for a certain time?'})
        node5:addChildKeyword({'yes'}, shield, {npcHandler = npcHandler, onlyFocus = true, reset = true})
        node5:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back if you want an upgrade in your skills.', reset = true})

    local node6 = keywordHandler:addKeyword({'magic shield'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to receive a magic shield for a certain time?'})
        node6:addChildKeyword({'yes'}, magicshield, {npcHandler = npcHandler, onlyFocus = true, reset = true})
        node6:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back if you want an upgrade in your skills.', reset = true})

    local node7 = keywordHandler:addKeyword({'regeneration'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to increase your regeneration for a certain time?'})
        node7:addChildKeyword({'yes'}, regener, {npcHandler = npcHandler, onlyFocus = true, reset = true})
        node7:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back if you want an upgrade in your skills.', reset = true})

    local node8 = keywordHandler:addKeyword({'speed'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to increase your speed for a certain time?'})
        node8:addChildKeyword({'yes'}, speed, {npcHandler = npcHandler, onlyFocus = true, reset = true})
        node8:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back if you want an upgrade in your skills.', reset = true})

    npcHandler:addModule(FocusModule:new())




    Ahora ve a creaturescripts.xml y agrega la siguiente linea:
    Código:
    <event type="login" name="PlayerLogin_BuffNpc" event="script" value="playerBuffs.lua"/>

    Y en data/creaturescripts/scripts crea un archivo llamado playerBuffs.lua y dentro pega esto:
    Código:
    --[[
        OJO: !!!
        Hay que asegurarse que los valores definidos en las variables de este archivo deben coincidir con la npc de los buffs.

    ]]
    local storage = 77700
    local Seconds = {
        melee = 3600,
        distance = 3600,

        magicLevel = 600,
        invisible = 600,
        manaShield = 600,
        regeneration = 600,
        speed = 600,
        shield = 600
    }

    -- Configs of buffs
    local conditionMagic = createConditionObject(CONDITION_ATTRIBUTES)
    setConditionParam(conditionMagic, CONDITION_PARAM_BUFF, true)
    setConditionParam(conditionMagic, CONDITION_PARAM_TICKS, Seconds.magicLevel * 1000)
    setConditionParam(conditionMagic, CONDITION_PARAM_STAT_MAGICLEVEL, skillsupgrade['ml'])

    local combatInvisible = createConditionObject(CONDITION_INVISIBLE)
    setConditionParam(combatInvisible, CONDITION_PARAM_BUFF, true)
    setConditionParam(combatInvisible, CONDITION_PARAM_TICKS, Seconds.invisible*1000)

    local conditionMelee = createConditionObject(CONDITION_ATTRIBUTES)
    setConditionParam(conditionMelee, CONDITION_PARAM_BUFF, true)
    setConditionParam(conditionMelee, CONDITION_PARAM_TICKS, Seconds.melee*1000)
    setConditionParam(conditionMelee, CONDITION_PARAM_SKILL_FIST, skillsupgrade['fist'])
    setConditionParam(conditionMelee, CONDITION_PARAM_SKILL_CLUB, skillsupgrade['club'])
    setConditionParam(conditionMelee, CONDITION_PARAM_SKILL_SWORD, skillsupgrade['sword'])
    setConditionParam(conditionMelee, CONDITION_PARAM_SKILL_AXE, skillsupgrade['axe'])

    local conditionDistance = createConditionObject(CONDITION_ATTRIBUTES)
    setConditionParam(conditionDistance, CONDITION_PARAM_BUFF, true)
    setConditionParam(conditionDistance, CONDITION_PARAM_TICKS, Seconds.distance*1000)
    setConditionParam(conditionDistance, CONDITION_PARAM_SKILL_DISTANCE, skillsupgrade['distance'])

    local conditionShield = createConditionObject(CONDITION_ATTRIBUTES)
    setConditionParam(conditionShield, CONDITION_PARAM_BUFF, true)
    setConditionParam(conditionShield, CONDITION_PARAM_TICKS, Seconds.shield*1000)
    setConditionParam(conditionShield, CONDITION_PARAM_SKILL_SHIELD, skillsupgrade['shield'])

    local combatUtamo = createConditionObject(CONDITION_MANASHIELD)
    setConditionParam(combatUtamo, CONDITION_PARAM_BUFF, true)
    setConditionParam(combatUtamo, CONDITION_PARAM_TICKS, Seconds.manaShield*1000)

    local conditionRege = createConditionObject(CONDITION_REGENERATION)
    setConditionParam(conditionRege, CONDITION_PARAM_BUFF, true)
    setConditionParam(conditionRege, CONDITION_PARAM_TICKS, Seconds.regeneration*1000)
    setConditionParam(conditionRege, CONDITION_PARAM_HEALTHGAIN, 20)
    setConditionParam(conditionRege, CONDITION_PARAM_HEALTHTICKS, 2000)

    local conditionspeed = createConditionObject(CONDITION_HASTE)
    setConditionParam(conditionspeed, CONDITION_PARAM_BUFF, true)
    setConditionParam(conditionspeed, CONDITION_PARAM_TICKS, Seconds.speed*1000)
    setConditionFormula(conditionspeed, 1.0, -86, 1.0, -86)


    -----------------------------------------------------------------------------------------------------------------------
    -----------------------------------------------------------------------------------------------------------------------
    -----------------------------------------------------------------------------------------------------------------------
    -----------------------------------------------------------------------------------------------------------------------
    -----------------------------------------------------------------------------------------------------------------------
    -----------------------------------------------------------------------------------------------------------------------
    -----------------------------------------------------------------------------------------------------------------------
    -----------------------------------------------------------------------------------------------------------------------

    -- No editar --
    local __skllNms = { [1] = {Seconds.magicLevel, conditionMagic}, [2] = {Seconds.invisible, conditionInvisible}, [3] = {Seconds.melee, conditionMelee}, [4] = {Seconds.distance, conditionDistance}, [5] = {Seconds.shield, conditionShield}, [6] = {Seconds.manaShield, conditionUtamo}, [7] = {Seconds.regeneration, conditionRege}, [8] = {Seconds.speed, conditionspeed}}
    ---------------

    function onLogin(cid)
        if(not isPlayer(cid))then return true end
        local a = getPlayerStorageValue(cid, storage)
        if(a > os.time())then
            local __c = __skllNms[getPlayerStorageValue(cid, storage + 1)]
            setConditionParam(__c[2], CONDITION_PARAM_TICKS, (a - os.time()) * 1000)
            doAddCondition(cid, __c[2])
            setConditionParam(__c[2], CONDITION_PARAM_TICKS, __c[1] * 1000)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have " .. (a > 60 and (math.floor(a / 60) .. " minute" .. (math.floor(a / 60) ~= 1 and "s" or "")) or (a .. " second" .. (a ~= 1 and "s" or ""))).. " remaining of your buff.")
        end
        return true
    end



    Very Happy Que te sirva [CreatureEvents] Npc no mantiene el storage de buff 2764
    3 participantes

    Morfar

    Morfar
    Miembro
    Miembro
    me arroja este error en la consola bro no aparece el npc
    Código:
    [21:16:57.097] [Error - LuaInterface::loadFile] data/npc/scripts/buffer.lua:24: unexpected symbol near '['
    [21:16:57.105] [Warning - NpcEvents::NpcEvents] Cannot load script: data/npc/scripts/buffer.lua
    [21:16:57.112] data/npc/scripts/buffer.lua:24: unexpected symbol near '['

    3 participantes

    Josens

    Josens
    Miembro
    Miembro
    Lo siento, intenta con este script para el npc:

    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

    -- configs
    local storage = 77700
    local Seconds = {
        melee = 3600,
        distance = 600,
        magicLevel = 600,
        invisible = 600,
        manaShield = 600,
        regeneration = 600,
        speed = 600,
        shield = 600
    }

    local skillsupgrade = {}
    skillsupgrade['fist'] = 130
    skillsupgrade['club'] = 130
    skillsupgrade['sword'] = 130
    skillsupgrade['axe'] = 135
    skillsupgrade['distance'] = 60
    skillsupgrade['shield'] = 50
    skillsupgrade['ml'] = 10
    -- end configs

    -- Configs of buffs
    local conditionMagic = createConditionObject(CONDITION_ATTRIBUTES)
    setConditionParam(conditionMagic, CONDITION_PARAM_BUFF, true)
    setConditionParam(conditionMagic, CONDITION_PARAM_TICKS, Seconds.magicLevel * 1000)
    setConditionParam(conditionMagic, CONDITION_PARAM_STAT_MAGICLEVEL, skillsupgrade['ml'])

    local combatInvisible = createConditionObject(CONDITION_INVISIBLE)
    setConditionParam(combatInvisible, CONDITION_PARAM_BUFF, true)
    setConditionParam(combatInvisible, CONDITION_PARAM_TICKS, Seconds.invisible*1000)

    local conditionMelee = createConditionObject(CONDITION_ATTRIBUTES)
    setConditionParam(conditionMelee, CONDITION_PARAM_BUFF, true)
    setConditionParam(conditionMelee, CONDITION_PARAM_TICKS, Seconds.melee*1000)
    setConditionParam(conditionMelee, CONDITION_PARAM_SKILL_FIST, skillsupgrade['fist'])
    setConditionParam(conditionMelee, CONDITION_PARAM_SKILL_CLUB, skillsupgrade['club'])
    setConditionParam(conditionMelee, CONDITION_PARAM_SKILL_SWORD, skillsupgrade['sword'])
    setConditionParam(conditionMelee, CONDITION_PARAM_SKILL_AXE, skillsupgrade['axe'])

    local conditionDistance = createConditionObject(CONDITION_ATTRIBUTES)
    setConditionParam(conditionDistance, CONDITION_PARAM_BUFF, true)
    setConditionParam(conditionDistance, CONDITION_PARAM_TICKS, Seconds.distance*1000)
    setConditionParam(conditionDistance, CONDITION_PARAM_SKILL_DISTANCE, skillsupgrade['distance'])

    local conditionShield = createConditionObject(CONDITION_ATTRIBUTES)
    setConditionParam(conditionShield, CONDITION_PARAM_BUFF, true)
    setConditionParam(conditionShield, CONDITION_PARAM_TICKS, Seconds.shield*1000)
    setConditionParam(conditionShield, CONDITION_PARAM_SKILL_SHIELD, skillsupgrade['shield'])

    local combatUtamo = createConditionObject(CONDITION_MANASHIELD)
    setConditionParam(combatUtamo, CONDITION_PARAM_BUFF, true)
    setConditionParam(combatUtamo, CONDITION_PARAM_TICKS, Seconds.manaShield*1000)

    local conditionRege = createConditionObject(CONDITION_REGENERATION)
    setConditionParam(conditionRege, CONDITION_PARAM_BUFF, true)
    setConditionParam(conditionRege, CONDITION_PARAM_TICKS, Seconds.regeneration*1000)
    setConditionParam(conditionRege, CONDITION_PARAM_HEALTHGAIN, 20)
    setConditionParam(conditionRege, CONDITION_PARAM_HEALTHTICKS, 2000)

    local conditionspeed = createConditionObject(CONDITION_HASTE)
    setConditionParam(conditionspeed, CONDITION_PARAM_BUFF, true)
    setConditionParam(conditionspeed, CONDITION_PARAM_TICKS, Seconds.speed*1000)
    setConditionFormula(conditionspeed, 1.0, -86, 1.0, -86)

    -- Configs of buffs

    function magicl(cid, message, keywords, parameters, node)
        if not npcHandler:isFocused(cid) then return false end
        if (isPlayer(cid) or isSorcerer(cid)) and getCreatureStorage(cid, storage) == -1 then
            if getPlayerMoney(cid) >= 50000 then
                doPlayerRemoveMoney(cid, 50000)
                doAddCondition(cid, conditionMagic)
                npcHandler:say('Your magic level has increased for ' ..math.floor(Seconds.magic / 60) .. ' minute' ..(math.floor(Seconds.magic / 60) ~= 1 and "s" or "").. '!', cid)
                setPlayerStorageValue(cid, storage, os.time() + Seconds.magic)
                setPlayerStorageValue(cid, storage + 1, 1) -- No editar
            else
                npcHandler:say('You don\'t have such money.', cid)
            end
        else
            npcHandler:say('You must be a druid or a sorcerer to receive this increment.', cid)
        end
    end

    function invisible(cid, message, keywords, parameters, node)
        if not npcHandler:isFocused(cid) then return false end
        if (isPlayer(cid) or isSorcerer(cid)) and getCreatureStorage(cid, storage) == -1 then
            if getPlayerMoney(cid) >= 50000 then
                doPlayerRemoveMoney(cid, 50000)
                doAddCondition(cid, combatInvisible)
                npcHandler:say('Your invisible skill has increased for ' ..math.floor(Seconds.invisible / 60) .. ' minute' ..(math.floor(Seconds.invisible / 60) ~= 1 and "s" or "").. '!', cid)
                setPlayerStorageValue(cid, storage, os.time() + Seconds.invisible)
                setPlayerStorageValue(cid, storage + 1, 2) -- No editar
            else
                npcHandler:say('You don\'t have such money.', cid)
            end
        else
            npcHandler:say('You must be a druid or a sorcerer to receive this increment.', cid)
        end
    end

    function melee(cid, message, keywords, parameters, node)
        if not npcHandler:isFocused(cid) then return false end
        if isPlayer(cid) and getCreatureStorage(cid, storage) == -1 then
            if getPlayerMoney(cid) >= 50000 then
                doPlayerRemoveMoney(cid, 50000)
                doAddCondition(cid, conditionMelee)
                npcHandler:say('Your melee has increased for ' ..math.floor(Seconds.melee / 60) .. ' minute' ..(math.floor(Seconds.melee / 60) ~= 1 and "s" or "").. '!', cid)
                setPlayerStorageValue(cid, storage, os.time() + Seconds.melee)
                setPlayerStorageValue(cid, storage + 1, 3) -- No editar
            else
                npcHandler:say('You don\'t have such money.', cid)
            end
        else
            npcHandler:say('You must be a knight to receive this increment.', cid)
        end
    end

    function distance(cid, message, keywords, parameters, node)
        if not npcHandler:isFocused(cid) then return false end
        if isPlayer(cid) and getCreatureStorage(cid, storage) == -1 then
            if getPlayerMoney(cid) >= 50000 then
                doPlayerRemoveMoney(cid, 50000)
                doAddCondition(cid, conditionDistance)
                npcHandler:say('Your distance has increased for ' ..math.floor(Seconds.distance / 60) .. ' minute' ..(math.floor(Seconds.distance / 60) ~= 1 and "s" or "").. '!', cid)
                setPlayerStorageValue(cid, storage, os.time() + Seconds.distance)
                setPlayerStorageValue(cid, storage + 1, 4) -- No editar
            else
                npcHandler:say('You don\'t have such money.', cid)
            end
        else
            npcHandler:say('You must be a Paladin to receive this increment.', cid)
        end
    end


    function shield(cid, message, keywords, parameters, node)
        if not npcHandler:isFocused(cid) then return false end
        if (isPaladin(cid) or isKnight(cid)) and getCreatureStorage(cid, storage) == -1 then
            if getPlayerMoney(cid) >= 50000 then
                doPlayerRemoveMoney(cid, 50000)
                doAddCondition(cid, conditionShield)
                npcHandler:say('Your shielding has increased for ' ..math.floor(Seconds.shield / 60) .. ' minute' ..(math.floor(Seconds.shield / 60) ~= 1 and "s" or "").. '!', cid)
                setPlayerStorageValue(cid, storage, os.time() + Seconds.shield)
                setPlayerStorageValue(cid, storage + 1, 5) -- No editar
            else
                npcHandler:say('You don\'t have such money.', cid)
            end
        else
            npcHandler:say('You must be a Paladin or a Knight to receive this increment.', cid)
        end
    end


    function magicshield(cid, message, keywords, parameters, node)
        if not npcHandler:isFocused(cid) then return false end
        if (isPaladin(cid) or isDruid(cid) or isSorcerer(cid) or isPlayer(cid)) and getCreatureStorage(cid, storage) == -1 then
            if getPlayerMoney(cid) >= 50000 then
                doPlayerRemoveMoney(cid, 50000)
                doAddCondition(cid, combatUtamo)
                npcHandler:say('You received magic shield for ' ..math.floor(Seconds.manaShield / 60) .. ' minute' ..(math.floor(Seconds.manaShield / 60) ~= 1 and "s" or "").. '!', cid)
                setPlayerStorageValue(cid, storage, os.time() + Seconds.manaShield)
                setPlayerStorageValue(cid, storage + 1, 6) -- No editar
            else
                npcHandler:say('You don\'t have such money.', cid)
            end
        else
            npcHandler:say('Knights can\'t receive this increment.', cid)
        end
    end


    function regener(cid, message, keywords, parameters, node)
        if not npcHandler:isFocused(cid) then return false end
        if isPlayer(cid) and getCreatureStorage(cid, storage) == -1 then
            if getPlayerMoney(cid) >= 50000 then
                doPlayerRemoveMoney(cid, 50000)
                doAddCondition(cid, conditionRege)
                npcHandler:say('Your regeneration has increased for ' ..math.floor(Seconds.regeneration / 60) .. ' minute' ..(math.floor(Seconds.regeneration / 60) ~= 1 and "s" or "").. '!', cid)
                setPlayerStorageValue(cid, storage, os.time() + Seconds.regeneration)
                setPlayerStorageValue(cid, storage + 1, 7) -- No editar
            else
                npcHandler:say('You don\'t have such money.', cid)
            end
        else
            npcHandler:say('You can\'t receive more than two increases.', cid)
        end
    end


    function speed(cid, message, keywords, parameters, node)
        if not npcHandler:isFocused(cid) then return false end
        if isPlayer(cid) and getCreatureStorage(cid, storage) == -1 then
            if getPlayerMoney(cid) >= 50000 then
                doPlayerRemoveMoney(cid, 50000)
                doAddCondition(cid, conditionspeed)
                npcHandler:say('Your speed has increased for ' ..math.floor(Seconds.speed / 60) .. ' minute' ..(math.floor(Seconds.speed / 60) ~= 1 and "s" or "").. '!', cid)
                setPlayerStorageValue(cid, storage, os.time() + Seconds.speed)
                setPlayerStorageValue(cid, storage + 1, 8) -- No editar
            else
                npcHandler:say('You don\'t have such money.', cid)
            end
        else
            npcHandler:say('You can\'t receive more than two increases.', cid)
        end
    end
    -- Buff Config End --

    keywordHandler:addKeyword({'help'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I can increase your {melee}, {distance}, {shielding}, {magic level}, {regeneration}, {invisibility}, {magic shield} and {speed}"})

    local node1 = keywordHandler:addKeyword({'magic level'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to increase your magic level for a certain time?'})
        node1:addChildKeyword({'yes'}, magicl, {npcHandler = npcHandler, onlyFocus = true, reset = true})
        node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back if you want an upgrade in your skills.', reset = true})

    local node2 = keywordHandler:addKeyword({'invisibility'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to be invisible for a certain time?'})
        node2:addChildKeyword({'yes'}, invisible, {npcHandler = npcHandler, onlyFocus = true, reset = true})
        node2:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back if you want an upgrade in your skills.', reset = true})

    local node3 = keywordHandler:addKeyword({'melee'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to increase your melee skills for a certain time?'})
        node3:addChildKeyword({'yes'}, melee, {npcHandler = npcHandler, onlyFocus = true, reset = true})
        node3:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back if you want an upgrade in your skills.', reset = true})

    local node4 = keywordHandler:addKeyword({'distance'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to increase your distance skills for a certain time?'})
        node4:addChildKeyword({'yes'}, distance, {npcHandler = npcHandler, onlyFocus = true, reset = true})
        node4:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back if you want an upgrade in your skills.', reset = true})

    local node5 = keywordHandler:addKeyword({'shielding'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to increase your shielding skill for a certain time?'})
        node5:addChildKeyword({'yes'}, shield, {npcHandler = npcHandler, onlyFocus = true, reset = true})
        node5:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back if you want an upgrade in your skills.', reset = true})

    local node6 = keywordHandler:addKeyword({'magic shield'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to receive a magic shield for a certain time?'})
        node6:addChildKeyword({'yes'}, magicshield, {npcHandler = npcHandler, onlyFocus = true, reset = true})
        node6:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back if you want an upgrade in your skills.', reset = true})

    local node7 = keywordHandler:addKeyword({'regeneration'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to increase your regeneration for a certain time?'})
        node7:addChildKeyword({'yes'}, regener, {npcHandler = npcHandler, onlyFocus = true, reset = true})
        node7:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back if you want an upgrade in your skills.', reset = true})

    local node8 = keywordHandler:addKeyword({'speed'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to increase your speed for a certain time?'})
        node8:addChildKeyword({'yes'}, speed, {npcHandler = npcHandler, onlyFocus = true, reset = true})
        node8:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back if you want an upgrade in your skills.', reset = true})

    npcHandler:addModule(FocusModule:new())



    Pd: No he testeado el script :$



    Very Happy Que te sirva [CreatureEvents] Npc no mantiene el storage de buff 2764
    3 participantes

    Morfar

    Morfar
    Miembro
    Miembro
    igual bro ahora me arroja esto
    Código:
    [21:28:06.133] [Error - NpcScript Interface]
    [21:28:06.138] data/npc/scripts/buffer.lua:onCreatureSay
    [21:28:06.144] Description:
    [21:28:06.147] data/npc/scripts/buffer.lua:84: attempt to perform arithmetic on field 'magic' (a nil value)
    [21:28:06.158] stack traceback:
    [21:28:06.161]  data/npc/scripts/buffer.lua:84: in function 'callback'
    [21:28:06.170]  data/npc/lib/npcsystem/keywordhandler.lua:40: in function 'processMessage'
    [21:28:06.177]  data/npc/lib/npcsystem/keywordhandler.lua:168: in function 'processNodeMessage'
    [21:28:06.186]  data/npc/lib/npcsystem/keywordhandler.lua:122: in function 'processMessage'
    [21:28:06.193]  data/npc/lib/npcsystem/npchandler.lua:380: in function 'onCreatureSay'
    [21:28:06.203]  data/npc/scripts/buffer.lua:7: in function <data/npc/scripts/buffer.lua:7>

    3 participantes

    Josens

    Josens
    Miembro
    Miembro
    Dime con este:

    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

    -- configs
    local storage = 77700
    local Seconds = {
        melee = 3600,
        distance = 600,
        magicLevel = 600,
        invisible = 600,
        manaShield = 600,
        regeneration = 600,
        speed = 600,
        shield = 600
    }

    local skillsupgrade = {}
    skillsupgrade['fist'] = 130
    skillsupgrade['club'] = 130
    skillsupgrade['sword'] = 130
    skillsupgrade['axe'] = 135
    skillsupgrade['distance'] = 60
    skillsupgrade['shield'] = 50
    skillsupgrade['ml'] = 10
    -- end configs

    -- Configs of buffs
    local conditionMagic = createConditionObject(CONDITION_ATTRIBUTES)
    setConditionParam(conditionMagic, CONDITION_PARAM_BUFF, true)
    setConditionParam(conditionMagic, CONDITION_PARAM_TICKS, Seconds.magicLevel * 1000)
    setConditionParam(conditionMagic, CONDITION_PARAM_STAT_MAGICLEVEL, skillsupgrade['ml'])

    local combatInvisible = createConditionObject(CONDITION_INVISIBLE)
    setConditionParam(combatInvisible, CONDITION_PARAM_BUFF, true)
    setConditionParam(combatInvisible, CONDITION_PARAM_TICKS, Seconds.invisible*1000)

    local conditionMelee = createConditionObject(CONDITION_ATTRIBUTES)
    setConditionParam(conditionMelee, CONDITION_PARAM_BUFF, true)
    setConditionParam(conditionMelee, CONDITION_PARAM_TICKS, Seconds.melee*1000)
    setConditionParam(conditionMelee, CONDITION_PARAM_SKILL_FIST, skillsupgrade['fist'])
    setConditionParam(conditionMelee, CONDITION_PARAM_SKILL_CLUB, skillsupgrade['club'])
    setConditionParam(conditionMelee, CONDITION_PARAM_SKILL_SWORD, skillsupgrade['sword'])
    setConditionParam(conditionMelee, CONDITION_PARAM_SKILL_AXE, skillsupgrade['axe'])

    local conditionDistance = createConditionObject(CONDITION_ATTRIBUTES)
    setConditionParam(conditionDistance, CONDITION_PARAM_BUFF, true)
    setConditionParam(conditionDistance, CONDITION_PARAM_TICKS, Seconds.distance*1000)
    setConditionParam(conditionDistance, CONDITION_PARAM_SKILL_DISTANCE, skillsupgrade['distance'])

    local conditionShield = createConditionObject(CONDITION_ATTRIBUTES)
    setConditionParam(conditionShield, CONDITION_PARAM_BUFF, true)
    setConditionParam(conditionShield, CONDITION_PARAM_TICKS, Seconds.shield*1000)
    setConditionParam(conditionShield, CONDITION_PARAM_SKILL_SHIELD, skillsupgrade['shield'])

    local combatUtamo = createConditionObject(CONDITION_MANASHIELD)
    setConditionParam(combatUtamo, CONDITION_PARAM_BUFF, true)
    setConditionParam(combatUtamo, CONDITION_PARAM_TICKS, Seconds.manaShield*1000)

    local conditionRege = createConditionObject(CONDITION_REGENERATION)
    setConditionParam(conditionRege, CONDITION_PARAM_BUFF, true)
    setConditionParam(conditionRege, CONDITION_PARAM_TICKS, Seconds.regeneration*1000)
    setConditionParam(conditionRege, CONDITION_PARAM_HEALTHGAIN, 20)
    setConditionParam(conditionRege, CONDITION_PARAM_HEALTHTICKS, 2000)

    local conditionspeed = createConditionObject(CONDITION_HASTE)
    setConditionParam(conditionspeed, CONDITION_PARAM_BUFF, true)
    setConditionParam(conditionspeed, CONDITION_PARAM_TICKS, Seconds.speed*1000)
    setConditionFormula(conditionspeed, 1.0, -86, 1.0, -86)

    -- Configs of buffs

    function magicl(cid, message, keywords, parameters, node)
        if not npcHandler:isFocused(cid) then return false end
        if (isPlayer(cid) or isSorcerer(cid)) and getCreatureStorage(cid, storage) == -1 then
            if getPlayerMoney(cid) >= 50000 then
                doPlayerRemoveMoney(cid, 50000)
                doAddCondition(cid, conditionMagic)
                npcHandler:say('Your magic level has increased for ' ..math.floor(Seconds.magicLevel / 60) .. ' minute' ..(math.floor(Seconds.magicLevel / 60) ~= 1 and "s" or "").. '!', cid)
                setPlayerStorageValue(cid, storage, os.time() + Seconds.magicLevel)
                setPlayerStorageValue(cid, storage + 1, 1) -- No editar
            else
                npcHandler:say('You don\'t have such money.', cid)
            end
        else
            npcHandler:say('You must be a druid or a sorcerer to receive this increment.', cid)
        end
    end

    function invisible(cid, message, keywords, parameters, node)
        if not npcHandler:isFocused(cid) then return false end
        if (isPlayer(cid) or isSorcerer(cid)) and getCreatureStorage(cid, storage) == -1 then
            if getPlayerMoney(cid) >= 50000 then
                doPlayerRemoveMoney(cid, 50000)
                doAddCondition(cid, combatInvisible)
                npcHandler:say('Your invisible skill has increased for ' ..math.floor(Seconds.invisible / 60) .. ' minute' ..(math.floor(Seconds.invisible / 60) ~= 1 and "s" or "").. '!', cid)
                setPlayerStorageValue(cid, storage, os.time() + Seconds.invisible)
                setPlayerStorageValue(cid, storage + 1, 2) -- No editar
            else
                npcHandler:say('You don\'t have such money.', cid)
            end
        else
            npcHandler:say('You must be a druid or a sorcerer to receive this increment.', cid)
        end
    end

    function melee(cid, message, keywords, parameters, node)
        if not npcHandler:isFocused(cid) then return false end
        if isPlayer(cid) and getCreatureStorage(cid, storage) == -1 then
            if getPlayerMoney(cid) >= 50000 then
                doPlayerRemoveMoney(cid, 50000)
                doAddCondition(cid, conditionMelee)
                npcHandler:say('Your melee has increased for ' ..math.floor(Seconds.melee / 60) .. ' minute' ..(math.floor(Seconds.melee / 60) ~= 1 and "s" or "").. '!', cid)
                setPlayerStorageValue(cid, storage, os.time() + Seconds.melee)
                setPlayerStorageValue(cid, storage + 1, 3) -- No editar
            else
                npcHandler:say('You don\'t have such money.', cid)
            end
        else
            npcHandler:say('You must be a knight to receive this increment.', cid)
        end
    end

    function distance(cid, message, keywords, parameters, node)
        if not npcHandler:isFocused(cid) then return false end
        if isPlayer(cid) and getCreatureStorage(cid, storage) == -1 then
            if getPlayerMoney(cid) >= 50000 then
                doPlayerRemoveMoney(cid, 50000)
                doAddCondition(cid, conditionDistance)
                npcHandler:say('Your distance has increased for ' ..math.floor(Seconds.distance / 60) .. ' minute' ..(math.floor(Seconds.distance / 60) ~= 1 and "s" or "").. '!', cid)
                setPlayerStorageValue(cid, storage, os.time() + Seconds.distance)
                setPlayerStorageValue(cid, storage + 1, 4) -- No editar
            else
                npcHandler:say('You don\'t have such money.', cid)
            end
        else
            npcHandler:say('You must be a Paladin to receive this increment.', cid)
        end
    end


    function shield(cid, message, keywords, parameters, node)
        if not npcHandler:isFocused(cid) then return false end
        if (isPaladin(cid) or isKnight(cid)) and getCreatureStorage(cid, storage) == -1 then
            if getPlayerMoney(cid) >= 50000 then
                doPlayerRemoveMoney(cid, 50000)
                doAddCondition(cid, conditionShield)
                npcHandler:say('Your shielding has increased for ' ..math.floor(Seconds.shield / 60) .. ' minute' ..(math.floor(Seconds.shield / 60) ~= 1 and "s" or "").. '!', cid)
                setPlayerStorageValue(cid, storage, os.time() + Seconds.shield)
                setPlayerStorageValue(cid, storage + 1, 5) -- No editar
            else
                npcHandler:say('You don\'t have such money.', cid)
            end
        else
            npcHandler:say('You must be a Paladin or a Knight to receive this increment.', cid)
        end
    end


    function magicshield(cid, message, keywords, parameters, node)
        if not npcHandler:isFocused(cid) then return false end
        if (isPaladin(cid) or isDruid(cid) or isSorcerer(cid) or isPlayer(cid)) and getCreatureStorage(cid, storage) == -1 then
            if getPlayerMoney(cid) >= 50000 then
                doPlayerRemoveMoney(cid, 50000)
                doAddCondition(cid, combatUtamo)
                npcHandler:say('You received magic shield for ' ..math.floor(Seconds.manaShield / 60) .. ' minute' ..(math.floor(Seconds.manaShield / 60) ~= 1 and "s" or "").. '!', cid)
                setPlayerStorageValue(cid, storage, os.time() + Seconds.manaShield)
                setPlayerStorageValue(cid, storage + 1, 6) -- No editar
            else
                npcHandler:say('You don\'t have such money.', cid)
            end
        else
            npcHandler:say('Knights can\'t receive this increment.', cid)
        end
    end


    function regener(cid, message, keywords, parameters, node)
        if not npcHandler:isFocused(cid) then return false end
        if isPlayer(cid) and getCreatureStorage(cid, storage) == -1 then
            if getPlayerMoney(cid) >= 50000 then
                doPlayerRemoveMoney(cid, 50000)
                doAddCondition(cid, conditionRege)
                npcHandler:say('Your regeneration has increased for ' ..math.floor(Seconds.regeneration / 60) .. ' minute' ..(math.floor(Seconds.regeneration / 60) ~= 1 and "s" or "").. '!', cid)
                setPlayerStorageValue(cid, storage, os.time() + Seconds.regeneration)
                setPlayerStorageValue(cid, storage + 1, 7) -- No editar
            else
                npcHandler:say('You don\'t have such money.', cid)
            end
        else
            npcHandler:say('You can\'t receive more than two increases.', cid)
        end
    end


    function speed(cid, message, keywords, parameters, node)
        if not npcHandler:isFocused(cid) then return false end
        if isPlayer(cid) and getCreatureStorage(cid, storage) == -1 then
            if getPlayerMoney(cid) >= 50000 then
                doPlayerRemoveMoney(cid, 50000)
                doAddCondition(cid, conditionspeed)
                npcHandler:say('Your speed has increased for ' ..math.floor(Seconds.speed / 60) .. ' minute' ..(math.floor(Seconds.speed / 60) ~= 1 and "s" or "").. '!', cid)
                setPlayerStorageValue(cid, storage, os.time() + Seconds.speed)
                setPlayerStorageValue(cid, storage + 1, 8) -- No editar
            else
                npcHandler:say('You don\'t have such money.', cid)
            end
        else
            npcHandler:say('You can\'t receive more than two increases.', cid)
        end
    end
    -- Buff Config End --

    keywordHandler:addKeyword({'help'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I can increase your {melee}, {distance}, {shielding}, {magic level}, {regeneration}, {invisibility}, {magic shield} and {speed}"})

    local node1 = keywordHandler:addKeyword({'magic level'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to increase your magic level for a certain time?'})
        node1:addChildKeyword({'yes'}, magicl, {npcHandler = npcHandler, onlyFocus = true, reset = true})
        node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back if you want an upgrade in your skills.', reset = true})

    local node2 = keywordHandler:addKeyword({'invisibility'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to be invisible for a certain time?'})
        node2:addChildKeyword({'yes'}, invisible, {npcHandler = npcHandler, onlyFocus = true, reset = true})
        node2:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back if you want an upgrade in your skills.', reset = true})

    local node3 = keywordHandler:addKeyword({'melee'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to increase your melee skills for a certain time?'})
        node3:addChildKeyword({'yes'}, melee, {npcHandler = npcHandler, onlyFocus = true, reset = true})
        node3:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back if you want an upgrade in your skills.', reset = true})

    local node4 = keywordHandler:addKeyword({'distance'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to increase your distance skills for a certain time?'})
        node4:addChildKeyword({'yes'}, distance, {npcHandler = npcHandler, onlyFocus = true, reset = true})
        node4:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back if you want an upgrade in your skills.', reset = true})

    local node5 = keywordHandler:addKeyword({'shielding'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to increase your shielding skill for a certain time?'})
        node5:addChildKeyword({'yes'}, shield, {npcHandler = npcHandler, onlyFocus = true, reset = true})
        node5:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back if you want an upgrade in your skills.', reset = true})

    local node6 = keywordHandler:addKeyword({'magic shield'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to receive a magic shield for a certain time?'})
        node6:addChildKeyword({'yes'}, magicshield, {npcHandler = npcHandler, onlyFocus = true, reset = true})
        node6:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back if you want an upgrade in your skills.', reset = true})

    local node7 = keywordHandler:addKeyword({'regeneration'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to increase your regeneration for a certain time?'})
        node7:addChildKeyword({'yes'}, regener, {npcHandler = npcHandler, onlyFocus = true, reset = true})
        node7:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back if you want an upgrade in your skills.', reset = true})

    local node8 = keywordHandler:addKeyword({'speed'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to increase your speed for a certain time?'})
        node8:addChildKeyword({'yes'}, speed, {npcHandler = npcHandler, onlyFocus = true, reset = true})
        node8:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back if you want an upgrade in your skills.', reset = true})

    npcHandler:addModule(FocusModule:new())



    Very Happy Que te sirva [CreatureEvents] Npc no mantiene el storage de buff 2764
    3 participantes

    Morfar

    Morfar
    Miembro
    Miembro
    disculpa por molestar tanto bro en creature me arroja esto
    Código:
    [21:36:51.262] [Error - CreatureScript Interface]
    [21:36:51.268] data/creaturescripts/scripts/playerBuffs.lua
    [21:36:51.273] Description:
    [21:36:51.275] data/creaturescripts/scripts/playerBuffs.lua:23: attempt to index global 'skillsupgrade' (a nil value)
    [21:36:51.287] [Warning - Event::loadScript] Cannot load script (data/creaturescripts/scripts/playerBuffs.lua)
    [21:36:51.295] data/creaturescripts/scripts/deathchannel.lua:1: '=' expected near 'by'
    y ya como que hay un problema en el npc no me otorga ya el buff me dice que por la vocacion

    3 participantes

    Josens

    Josens
    Miembro
    Miembro
    Bien, intenta con este script de creaturescripts:

    Código:
    --[[
        OJO: !!!
        Hay que asegurarse que los valores definidos en las variables de este archivo deben coincidir con la npc de los buffs.

    ]]
    local storage = 77700
    local Seconds = {
        melee = 3600,
        distance = 3600,

        magicLevel = 600,
        invisible = 600,
        manaShield = 600,
        regeneration = 600,
        speed = 600,
        shield = 600
    }

    local skillsupgrade = {}
    skillsupgrade['fist'] = 130
    skillsupgrade['club'] = 130
    skillsupgrade['sword'] = 130
    skillsupgrade['axe'] = 135
    skillsupgrade['distance'] = 60
    skillsupgrade['shield'] = 50
    skillsupgrade['ml'] = 10

    -- Configs of buffs
    local conditionMagic = createConditionObject(CONDITION_ATTRIBUTES)
    setConditionParam(conditionMagic, CONDITION_PARAM_BUFF, true)
    setConditionParam(conditionMagic, CONDITION_PARAM_TICKS, Seconds.magicLevel * 1000)
    setConditionParam(conditionMagic, CONDITION_PARAM_STAT_MAGICLEVEL, skillsupgrade['ml'])

    local combatInvisible = createConditionObject(CONDITION_INVISIBLE)
    setConditionParam(combatInvisible, CONDITION_PARAM_BUFF, true)
    setConditionParam(combatInvisible, CONDITION_PARAM_TICKS, Seconds.invisible*1000)

    local conditionMelee = createConditionObject(CONDITION_ATTRIBUTES)
    setConditionParam(conditionMelee, CONDITION_PARAM_BUFF, true)
    setConditionParam(conditionMelee, CONDITION_PARAM_TICKS, Seconds.melee*1000)
    setConditionParam(conditionMelee, CONDITION_PARAM_SKILL_FIST, skillsupgrade['fist'])
    setConditionParam(conditionMelee, CONDITION_PARAM_SKILL_CLUB, skillsupgrade['club'])
    setConditionParam(conditionMelee, CONDITION_PARAM_SKILL_SWORD, skillsupgrade['sword'])
    setConditionParam(conditionMelee, CONDITION_PARAM_SKILL_AXE, skillsupgrade['axe'])

    local conditionDistance = createConditionObject(CONDITION_ATTRIBUTES)
    setConditionParam(conditionDistance, CONDITION_PARAM_BUFF, true)
    setConditionParam(conditionDistance, CONDITION_PARAM_TICKS, Seconds.distance*1000)
    setConditionParam(conditionDistance, CONDITION_PARAM_SKILL_DISTANCE, skillsupgrade['distance'])

    local conditionShield = createConditionObject(CONDITION_ATTRIBUTES)
    setConditionParam(conditionShield, CONDITION_PARAM_BUFF, true)
    setConditionParam(conditionShield, CONDITION_PARAM_TICKS, Seconds.shield*1000)
    setConditionParam(conditionShield, CONDITION_PARAM_SKILL_SHIELD, skillsupgrade['shield'])

    local combatUtamo = createConditionObject(CONDITION_MANASHIELD)
    setConditionParam(combatUtamo, CONDITION_PARAM_BUFF, true)
    setConditionParam(combatUtamo, CONDITION_PARAM_TICKS, Seconds.manaShield*1000)

    local conditionRege = createConditionObject(CONDITION_REGENERATION)
    setConditionParam(conditionRege, CONDITION_PARAM_BUFF, true)
    setConditionParam(conditionRege, CONDITION_PARAM_TICKS, Seconds.regeneration*1000)
    setConditionParam(conditionRege, CONDITION_PARAM_HEALTHGAIN, 20)
    setConditionParam(conditionRege, CONDITION_PARAM_HEALTHTICKS, 2000)

    local conditionspeed = createConditionObject(CONDITION_HASTE)
    setConditionParam(conditionspeed, CONDITION_PARAM_BUFF, true)
    setConditionParam(conditionspeed, CONDITION_PARAM_TICKS, Seconds.speed*1000)
    setConditionFormula(conditionspeed, 1.0, -86, 1.0, -86)


    -----------------------------------------------------------------------------------------------------------------------
    -----------------------------------------------------------------------------------------------------------------------
    -----------------------------------------------------------------------------------------------------------------------
    -----------------------------------------------------------------------------------------------------------------------
    -----------------------------------------------------------------------------------------------------------------------
    -----------------------------------------------------------------------------------------------------------------------
    -----------------------------------------------------------------------------------------------------------------------
    -----------------------------------------------------------------------------------------------------------------------

    -- No editar --
    local __skllNms = { [1] = {Seconds.magicLevel, conditionMagic}, [2] = {Seconds.invisible, combatInvisible}, [3] = {Seconds.melee, conditionMelee}, [4] = {Seconds.distance, conditionDistance}, [5] = {Seconds.shield, conditionShield}, [6] = {Seconds.manaShield, combatUtamo}, [7] = {Seconds.regeneration, conditionRege}, [8] = {Seconds.speed, conditionspeed}}
    ---------------

    function onLogin(cid)
        if(not isPlayer(cid))then return true end
        local a = getPlayerStorageValue(cid, storage)
        if(a > os.time())then
            local __c = __skllNms[getPlayerStorageValue(cid, storage + 1)]
            setConditionParam(__c[2], CONDITION_PARAM_TICKS, (a - os.time()) * 1000)
            doAddCondition(cid, __c[2])
            setConditionParam(__c[2], CONDITION_PARAM_TICKS, __c[1] * 1000)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have " .. (a > 60 and (math.floor(a / 60) .. " minute" .. (math.floor(a / 60) ~= 1 and "s" or "")) or (a .. " second" .. (a ~= 1 and "s" or ""))).. " remaining of your buff.")
        end
        return true
    end



    Very Happy Que te sirva [CreatureEvents] Npc no mantiene el storage de buff 2764
    3 participantes

    Morfar

    Morfar
    Miembro
    Miembro
    No me aparece error en la consola bro pero no me da ningun buff me dice como si ya lo tuviera o por que no soy la vocacion

    3 participantes

    Josens

    Josens
    Miembro
    Miembro
    Bien, con este playerBuff.lua en creaturescripts deberia quedar:

    Código:
    --[[
        OJO: !!!
        Hay que asegurarse que los valores definidos en las variables de este archivo deben coincidir con la npc de los buffs.

    ]]
    local storage = 77700
    local Seconds = {
        melee = 3600,
        distance = 3600,

        magicLevel = 600,
        invisible = 600,
        manaShield = 600,
        regeneration = 600,
        speed = 600,
        shield = 600
    }

    local skillsupgrade = {}
    skillsupgrade['fist'] = 130
    skillsupgrade['club'] = 130
    skillsupgrade['sword'] = 130
    skillsupgrade['axe'] = 135
    skillsupgrade['distance'] = 60
    skillsupgrade['shield'] = 50
    skillsupgrade['ml'] = 10

    -- Configs of buffs
    local conditionMagic = createConditionObject(CONDITION_ATTRIBUTES)
    setConditionParam(conditionMagic, CONDITION_PARAM_BUFF, true)
    setConditionParam(conditionMagic, CONDITION_PARAM_TICKS, Seconds.magicLevel * 1000)
    setConditionParam(conditionMagic, CONDITION_PARAM_STAT_MAGICLEVEL, skillsupgrade['ml'])

    local combatInvisible = createConditionObject(CONDITION_INVISIBLE)
    setConditionParam(combatInvisible, CONDITION_PARAM_BUFF, true)
    setConditionParam(combatInvisible, CONDITION_PARAM_TICKS, Seconds.invisible*1000)

    local conditionMelee = createConditionObject(CONDITION_ATTRIBUTES)
    setConditionParam(conditionMelee, CONDITION_PARAM_BUFF, true)
    setConditionParam(conditionMelee, CONDITION_PARAM_TICKS, Seconds.melee*1000)
    setConditionParam(conditionMelee, CONDITION_PARAM_SKILL_FIST, skillsupgrade['fist'])
    setConditionParam(conditionMelee, CONDITION_PARAM_SKILL_CLUB, skillsupgrade['club'])
    setConditionParam(conditionMelee, CONDITION_PARAM_SKILL_SWORD, skillsupgrade['sword'])
    setConditionParam(conditionMelee, CONDITION_PARAM_SKILL_AXE, skillsupgrade['axe'])

    local conditionDistance = createConditionObject(CONDITION_ATTRIBUTES)
    setConditionParam(conditionDistance, CONDITION_PARAM_BUFF, true)
    setConditionParam(conditionDistance, CONDITION_PARAM_TICKS, Seconds.distance*1000)
    setConditionParam(conditionDistance, CONDITION_PARAM_SKILL_DISTANCE, skillsupgrade['distance'])

    local conditionShield = createConditionObject(CONDITION_ATTRIBUTES)
    setConditionParam(conditionShield, CONDITION_PARAM_BUFF, true)
    setConditionParam(conditionShield, CONDITION_PARAM_TICKS, Seconds.shield*1000)
    setConditionParam(conditionShield, CONDITION_PARAM_SKILL_SHIELD, skillsupgrade['shield'])

    local combatUtamo = createConditionObject(CONDITION_MANASHIELD)
    setConditionParam(combatUtamo, CONDITION_PARAM_BUFF, true)
    setConditionParam(combatUtamo, CONDITION_PARAM_TICKS, Seconds.manaShield*1000)

    local conditionRege = createConditionObject(CONDITION_REGENERATION)
    setConditionParam(conditionRege, CONDITION_PARAM_BUFF, true)
    setConditionParam(conditionRege, CONDITION_PARAM_TICKS, Seconds.regeneration*1000)
    setConditionParam(conditionRege, CONDITION_PARAM_HEALTHGAIN, 20)
    setConditionParam(conditionRege, CONDITION_PARAM_HEALTHTICKS, 2000)

    local conditionspeed = createConditionObject(CONDITION_HASTE)
    setConditionParam(conditionspeed, CONDITION_PARAM_BUFF, true)
    setConditionParam(conditionspeed, CONDITION_PARAM_TICKS, Seconds.speed*1000)
    setConditionFormula(conditionspeed, 1.0, -86, 1.0, -86)


    -----------------------------------------------------------------------------------------------------------------------
    -----------------------------------------------------------------------------------------------------------------------
    -----------------------------------------------------------------------------------------------------------------------
    -----------------------------------------------------------------------------------------------------------------------
    -----------------------------------------------------------------------------------------------------------------------
    -----------------------------------------------------------------------------------------------------------------------
    -----------------------------------------------------------------------------------------------------------------------
    -----------------------------------------------------------------------------------------------------------------------

    -- No editar --
    local __skllNms = { [1] = {Seconds.magicLevel, conditionMagic}, [2] = {Seconds.invisible, combatInvisible}, [3] = {Seconds.melee, conditionMelee}, [4] = {Seconds.distance, conditionDistance}, [5] = {Seconds.shield, conditionShield}, [6] = {Seconds.manaShield, combatUtamo}, [7] = {Seconds.regeneration, conditionRege}, [8] = {Seconds.speed, conditionspeed}}
    ---------------

    function onLogin(cid)
        if(not isPlayer(cid))then return true end
        local a = getPlayerStorageValue(cid, storage)
        if(a > os.time())then
            local __c = __skllNms[getPlayerStorageValue(cid, storage + 1)]
            setConditionParam(__c[2], CONDITION_PARAM_TICKS, (a - os.time()) * 1000)
            doAddCondition(cid, __c[2])
            setConditionParam(__c[2], CONDITION_PARAM_TICKS, __c[1] * 1000)
            a = a - os.time()
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have " .. (a > 60 and (math.floor(a / 60) .. " minute" .. (math.floor(a / 60) ~= 1 and "s" or "")) or (a .. " second" .. (a ~= 1 and "s" or ""))).. " remaining of your buff.")
        end
        return true
    end

    Espero te funcione bro.



    Very Happy Que te sirva [CreatureEvents] Npc no mantiene el storage de buff 2764
    3 participantes

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