• TibiaFace

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

    .
    demo menumenu

    Afiliados



    Votar:

    Trainers Offline 8.6 + Sprite de estatuas de RL

    Compartir:

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

    1default Trainers Offline 8.6 + Sprite de estatuas de RL el Sáb Abr 06, 2019 11:45 pm

    Ilya-Smoke

    Ilya-Smoke
    Miembro
    Miembro
    Es la primera ves que publico algo asi en mi vida espero les funcione como me funciona ami xD suerte y espero les guste

    Empezemos

    data/actions/scripts

    copiamos cualquier archivo y renombramos por offlinetraining.lua y pegamos esto dentro:

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

    function onUse(cid, item, fromPosition, itemEx, toPosition)

    if(item.itemid == 7718) then -- sword
    doCreatureSetStorage(cid, 62669, SKILL_SWORD)
    elseif(item.itemid == 7716) then -- axe
    doCreatureSetStorage(cid, 62669, SKILL_AXE)
    elseif(item.itemid == 8615) then -- mlvl
    doCreatureSetStorage(cid, 62669, SKILL__MAGLEVEL)
    elseif(item.itemid == 7717) then -- club
    doCreatureSetStorage(cid, 62669, SKILL_CLUB)
    elseif(item.itemid == 8616) then -- distannce
    doCreatureSetStorage(cid, 62669, SKILL_DISTANCE)
    end
    if item.actionid == 1000 then
    doRemoveCreature(cid)
    end
    return

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

    luego añadimos esta tag en:

    data/actions/actions.xml

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

    <action itemid="8615" event="script" value="other/offlinetraining.lua"/>
    <action itemid="8616" event="script" value="other/offlinetraining.lua"/>
    <action itemid="7717" event="script" value="other/offlinetraining.lua"/>
    <action itemid="7718" event="script" value="other/offlinetraining.lua"/>
    <action itemid="7716" event="script" value="other/offlinetraining.lua"/>


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

    ahora nos vamos  a:

    data/creaturescripts/scripts/
    copiamos cualquier archivo y renombramos por offlinetrain_login.lua y pegamos esto dentro


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

    -- 0.4 - offline training - login.lua

    function onLogin(cid)
    OfflineTraining_initialize(cid)
    if(OfflineTraining_isTraining(cid)) then
    OfflineTraining_turnOffTraining(cid)
    -- we add skill/mlvl, we select lower value: time that player was offline OR offline training time [bar in game - 9.6]
    OfflineTraining_addTrainedSkills(cid, math.min(OfflineTraining_getTime(cid), OfflineTraining_getOfflineTime(cid)))
    -- we remove offline training time [bar in game - 9.6],
    -- if player was offline longer then his 'offline training time' it will add him time [like on RL tibia]
    -- got '3 hours offline training time', stay logged off for 8 hours, you get skills for 3 hours and on login you got '5 hours offline training time'
    OfflineTraining_setTime(cid, math.abs(OfflineTraining_getTime(cid) - OfflineTraining_getOfflineTime(cid)))
    OfflineTraining_onEndTraining(cid)
    else
    -- offline training time also regenerate when you are offline, but NOT train
    OfflineTraining_setTime(cid, OfflineTraining_getTime(cid) + OfflineTraining_getOfflineTime(cid))
    end
    return true
    end

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

    copiamos otro archivo y renombramos por offlinetrain_logout.lua y pegamos esto dentro


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

    -- 0.4 - offline training - logout.lua

    function onLogout(cid)
    if(OfflineTraining_canStartTraining(cid)) then
    OfflineTraining_turnOnTraining(cid)
    OfflineTraining_onStartTraining(cid)
    end
    OfflineTraining_setLogoutTime(cid)
    return true
    end

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

    Luego añadimos estas tag en:

    data/creaturescripts/creaturescripts.xml

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

    <event type="login" name="offtrain_PlayerLogin" event="script" value="offtrain_login.lua"/>

    <event type="logout" name="offtrain_PlayerLogout" event="script" value="offtrain_logout.lua"/>

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

    Nos vamos a:

    data/globalevents/scripts
    copiamos cualquier archivo y renombramos por offtrain_addMinutes.lua y pegamos esto dentro:

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

    function onThink(interval) -- run it with interval 60 seconds
    for _, cid in pairs(getPlayersOnline()) do
    OfflineTraining_addTime(cid, 1)
    end
    return true
    end

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

    luego añadimos esta tag en:

    data/globalevents/globalevents.xml

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

    <globalevent name="offtrain_add_minutes" interval="60000" event="script" value="offtrain_addMinutes.lua"/>

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

    Este es el ultimo paso nos vamos a:

    data/lib
    copiamos cualquier archivo y renombramos por offline-training.lua y pegamos esto dentro

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

    -- config, in percent of normal training with 2 trainers and player vocation mana regeneration [by food]
    OfflineTraining_rates = {
    [SKILL_CLUB] = 100,
    [SKILL_SWORD] = 100,
    [SKILL_AXE] = 100,
    [SKILL_DISTANCE] = 100,
    [SKILL_SHIELD] = 100,
    [SKILL__MAGLEVEL] = 100
    }
    -- function that you should edit to make it add other skill etc.
    function OfflineTraining_canStartTraining(cid) -- return bool
    return getCreatureStorage(cid, 62669) > 0
    end
    function OfflineTraining_onStartTraining(cid)
    -- maybe someone will need
    -- to save your time, this: doPlayerPopupFYI(cid, "You started offline training.")
    -- NOT WORK  
    end
    function OfflineTraining_onEndTraining(cid)
    doCreatureSetStorage(cid, 62669, 0)
    end
    function OfflineTraining_addTrainedSkills(cid, trainTime) -- time in minutes!
    local timeInSeconds = trainTime * 60
    local vocInfo = getVocationInfo(getPlayerVocation(cid))
    if(getCreatureStorage(cid, 62669) == SKILL_SWORD) then
    doPlayerAddSkillTry(cid, SKILL_SWORD, ((timeInSeconds * 1000) / vocInfo["attackSpeed"]) * OfflineTraining_rates[SKILL_SWORD] / 100, true)
    elseif(getCreatureStorage(cid, 62669) == SKILL_AXE) then
    doPlayerAddSkillTry(cid, SKILL_AXE, ((timeInSeconds * 1000) / vocInfo["attackSpeed"]) * OfflineTraining_rates[SKILL_AXE] / 100, true)
    elseif(getCreatureStorage(cid, 62669) == SKILL__MAGLEVEL) then
    doPlayerAddSpentMana(cid, ((timeInSeconds / vocInfo["manaGainTicks"]) * vocInfo["manaGain"]) * OfflineTraining_rates[SKILL__MAGLEVEL] / 100, true)
    elseif(getCreatureStorage(cid, 62669) == SKILL_CLUB) then
    doPlayerAddSkillTry(cid, SKILL_CLUB, ((timeInSeconds * 1000) / vocInfo["attackSpeed"]) * OfflineTraining_rates[SKILL_CLUB] / 100, true)
    elseif(getCreatureStorage(cid, 62669) == SKILL_DISTANCE) then
    doPlayerAddSkillTry(cid, SKILL_DISTANCE, ((timeInSeconds * 1000) / vocInfo["attackSpeed"]) * OfflineTraining_rates[SKILL_DISTANCE] / 100, true)
    end
    doPlayerAddSkillTry(cid, SKILL_SHIELD, timeInSeconds * OfflineTraining_rates[SKILL_SHIELD] / 100, true)
    end

    -- 4 functions to show right values on 'bar' in Tibia 9.6
    function OfflineTraining_getTime(cid)
    return getCreatureStorage(cid, 62666)
    end
    function OfflineTraining_setTime(cid, newTime)
    -- set values only between 0 - 720 [12 hours]
    doCreatureSetStorage(cid, 62666, math.max(0, math.min(newTime, 720)))
    -- now code to force server to send 'PlayerStats' (including Offline Time)
    -- we must change any stat: hp,mana,stamina,cap,soul,exp,level
    doPlayerAddSoul(cid, 1)
    doPlayerAddSoul(cid, -1)
    end
    function OfflineTraining_addTime(cid, addTime)
    OfflineTraining_setTime(cid, OfflineTraining_getTime(cid) + addTime)
    end
    function OfflineTraining_removeTime(cid, removeTime)
    OfflineTraining_setTime(cid, OfflineTraining_getTime(cid) - removeTime)
    end

    -- functions for library to add skills/mlvl
    function OfflineTraining_initialize(cid)
    if(OfflineTraining_getTime(cid) == -1) then
    OfflineTraining_setTime(cid, 720)
    OfflineTraining_setLogoutTime(cid) -- block problem with first login 'add time'
    end
    end
    function OfflineTraining_isTraining(cid)
    return (getCreatureStorage(cid, 62667) > 0)
    end
    function OfflineTraining_turnOnTraining(cid)
    doCreatureSetStorage(cid, 62667, 1)
    end
    function OfflineTraining_turnOffTraining(cid)
    doCreatureSetStorage(cid, 62667, 0)
    end
    function OfflineTraining_getOfflineTime(cid)
    return math.floor((os.time() - getCreatureStorage(cid, 62668)) / 60)
    end
    function OfflineTraining_setLogoutTime(cid)
    return doCreatureSetStorage(cid, 62668, os.time())
    end

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

    Link de las Estatuas echas por mi

    [Tienes que estar registrado y conectado para ver este vínculo]

    Recuerden darle ActionID: 1000
    A las estatuas con el RME cuando las coloquen

    Bueno y eso es todo.

    creditos:
    [ADMIN] Maya
    Oldscool'er
    Mythusz
    Ilya-Smoke

    Ver perfil de usuario

    [Admin] God Maya

    [Admin] God Maya
    Administrador
    Administrador
    Gracias por el aporte



    Trainers Offline 8.6 + Sprite de estatuas de RL YNU5B25
    Ver perfil de usuario https://www.tibiaface.com

    Ver el tema anterior Ver el tema siguiente Volver arriba  Mensaje (Página 1 de 1.)

    Temas similares

    -

    » Alegoria de la Justicia

    Permisos de este foro:
    No puedes responder a temas en este foro.

    Temas Recomendados×+

       

      BienvenidosTibiaFace es una comunidad de Open Tibia. Para participar debes estar registrado (click para Regístrate).