• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

Advanced rank system by time

sailorv5

Member
Joined
Oct 31, 2009
Messages
82
Reaction score
17
This is a SYSTEM where players dont care killing monster.
Think in a Different way of Playing TIBIA this is it,
where a player come to your server and dont care to lv up,
only having a nice time with friends !
---------------------------------------------------------------
THE strong of a player is based on the playing time of him.
this mean after a given TIME the player will update his ( status ) RANK ( CLASS ) for exem after 1 year playing on the ot he got the last rank like GENERAL
-- names are only for title of exemple can be changed lets stop talking.


data\XML and open group.xml add the code above inside


Code:
    <group id="1001" name="Novato" flags="17213423616" customFlags="67108864" access="0" depotLimit="1000" maxVips="200"  />
    <group id="1002" name="Recruta" flags="17213423616" customFlags="67108864" access="0" depotLimit="1000" maxVips="200"  />
    <group id="1003" name="Soldado" flags="17213423616" customFlags="67108864" access="0" depotLimit="1000" maxVips="200"  />
    <group id="1004" name="Cabo" flags="17213423616" customFlags="67108864" access="0" depotLimit="1000" maxVips="200"  />


    <group id="1005" name="Terceiro Sargento" flags="17213423616" customFlags="67108864" access="0" depotLimit="1000" maxVips="200"  />
    <group id="1006" name="Segundo Sargento" flags="17213423616" customFlags="67108864" access="0" depotLimit="1000" maxVips="200"  />
    <group id="1007" name="Primeiro Sargento" flags="17213423616" customFlags="67108864" access="0" depotLimit="1000" maxVips="200"  />
    <group id="1008" name="Aspirante" flags="17213423616" customFlags="67108864" access="0" depotLimit="1000" maxVips="200"  />


    <group id="1009" name="Segundo Tenente" flags="17213423616" customFlags="67108864" access="0" depotLimit="1000" maxVips="200"  />
    <group id="1010" name="Primeiro Tenente" flags="17213423616" customFlags="67108864" access="0" depotLimit="1000" maxVips="200"  />
    <group id="1011" name="Capitão" flags="17213423616" customFlags="67108864" access="0" depotLimit="1000" maxVips="200"  />
    
    <group id="1012" name="Major" flags="17213423616" customFlags="67108864" access="0" depotLimit="1000" maxVips="200"  />
    <group id="1013" name="Tenente Coronel" flags="17213423616" customFlags="67108864" access="0" depotLimit="1000" maxVips="200"  />
    <group id="1014" name="Coronel" flags="17213423616" customFlags="67108864" access="0" depotLimit="1000" maxVips="200"  />
    <group id="1015" name="General" flags="17213423616" customFlags="67108864" access="0" depotLimit="1000" maxVips="200"  />



inside MODS folder : make a new file called as you want or RankByPlayingTime.xml



Code:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="New level System script" version="1.0" author="Willian Batista Cima" contact="" enabled="yes">
                <description>
                                Rank by Playing Time script .-.
                                special thanks to Skymagnum ( xtibia ) that helped me a little. 
                </description>
                
-----------------------------------------------------------------------
<config name="rankTimeSystem"><![CDATA[


        
        
 rankTimeSystem = { }
        
 rankTimeSetting = {
        
        storageBase = 10009000101    ,        --  SAVE THE PLAY TIME     
        
}
rankTimeSetting.storagetime = rankTimeSetting.storageBase+1
rankTimeSetting.storagelogin = rankTimeSetting.storageBase+2
--    rankTimeSetting.storagelogout = rankTimeSetting.storageBase+3


        --  speed base level  218 + ( 2*getPlayerLevel(cid) )        http://www.tibiabr.com/calc_de_velocidade
        local base_character =  {    name = "newbe"  , play_time = 0 , life=100  , mana=100  ,  spd=(  218  ) , cap=0  }
        
 rankTimeClass = {


 
    --    Novato = Inicio ( 300 vida, 200 mana, speed a velocidade normal, Cap 400 ).            os.time()    3*60*60        
 
    --    group id        name            playtime in sec
        [1001] =  {    name = "Novato"  , play_time = 1 , life=base_character.life+300  , mana=base_character.mana+200  ,  spd=base_character.spd , cap=base_character.cap+400  } ,
        [1002] =  {    name = "Recruta"  , play_time = 1*60*60 , life=base_character.life+350  , mana=base_character.mana+220  ,  spd=base_character.spd+10 , cap=base_character.cap+450  } ,        --
        [1003] =  {    name = "Soldado"  , play_time = 6*60*60 , life=base_character.life+400  , mana=base_character.mana+240  ,  spd=base_character.spd+20 , cap=base_character.cap+500  } ,        --        
        [1004] =  {    name = "Cabo"  , play_time = (1*24)*60*60 , life=base_character.life+500  , mana=base_character.mana+260  ,  spd=base_character.spd+30 , cap=base_character.cap+550  } ,


        [1005] =  {    name = "Terceiro Sargento"  , play_time = (5*24)*60*60 , life=base_character.life+600  , mana=base_character.mana+280  ,  spd=base_character.spd+40 , cap=base_character.cap+600  } ,
        [1006] =  {    name = "Segundo  Sargento"  , play_time = (9*24)*60*60 , life=base_character.life+700  , mana=base_character.mana+300  ,  spd=base_character.spd+50 , cap=base_character.cap+650  } ,
        [1007] =  {    name = "Primeiro Sargento"  , play_time = (12*24)*60*60 , life=base_character.life+800  , mana=base_character.mana+320  ,  spd=base_character.spd+60 , cap=base_character.cap+700  } ,
        
        [1008] =  {    name = "Aspirante"  , play_time = (15*24)*60*60 , life=base_character.life+900  , mana=base_character.mana+340  ,  spd=base_character.spd+70 , cap=base_character.cap+750  } ,
        [1009] =  {    name = "Segundo Tenente"  , play_time = (30*24)*60*60 , life=base_character.life+1000  , mana=base_character.mana+360  ,  spd=base_character.spd+80 , cap=base_character.cap+800  } ,
        [1010] =  {    name = "Primeiro Tenente"  , play_time = (60*24)*60*60 , life=base_character.life+1100  , mana=base_character.mana+380  ,  spd=base_character.spd+90 , cap=base_character.cap+850  } ,
        
        [1011] =  {    name = "Capitao"  , play_time = (90*24)*60*60 , life=base_character.life+1300  , mana=base_character.mana+400  ,  spd=base_character.spd+100 , cap=base_character.cap+900  } ,
        [1012] =  {    name = "Major"  , play_time = (120*24)*60*60 , life=base_character.life+1500  , mana=base_character.mana+420  ,  spd=base_character.spd+120 , cap=base_character.cap+950  } ,
        [1013] =  {    name = "Tenente Coronel"  , play_time = (150*24)*60*60 , life=base_character.life+1800  , mana=base_character.mana+440  ,  spd=base_character.spd+140 , cap=base_character.cap+1000  } ,
        
        [1014] =  {    name = "Coronel"  , play_time = (250*24)*60*60 , life=base_character.life+2000  , mana=base_character.mana+460  ,  spd=base_character.spd+160 , cap=base_character.cap+1050  } ,
        [1015] =  {    name = "General"  , play_time = (365*24)*60*60 , life=base_character.life+2300  , mana=base_character.mana+480  ,  spd=base_character.spd+180 , cap=base_character.cap+1100  } ,
        
        LAST_GROUP =  1015 ,        --    last group should alws be the last
        
        


 




}


function getPlayerMaxCap(cid)
local query = db.getResult("SELECT `cap` FROM `players` WHERE `id` = " .. getPlayerGUID(cid) .. ";")
    if query:getID() ~= -1 then
        return query:getDataInt("cap")
    end
    query:free()
    return LUA_ERROR
end




]]></config>


-----------------------------------------------------------------------
    <event type="login" name="CheckingPlayerRankLogin" event="script"><![CDATA[
    domodlib('rankTimeSystem')
    local cfg = rankTimeSetting
    local class = rankTimeClass            
    
            function onLogin(cid)
                registerCreatureEvent(cid,"CheckingPlayerRankLogout")
--                registerCreatureEvent(cid,"lifeRingSystem_think")


        if getPlayerGroupId(cid) > 1 and getPlayerGroupId(cid) < 11 or    getPlayerName(cid) == "Account Manager"    then     --        lets not change GM TUTOR ETC...
            return true         -- change to acc mng to rank time ? better not or he will alws win the 1st position ; D ( TOP rank)
        end
        




                if  getPlayerGroupId(cid) == 1 and getPlayerName(cid) ~= "Account Manager" then
                     setPlayerGroupId(cid, 1001 )
                end
                
                if   getPlayerGroupId(cid) == class.LAST_GROUP then
                     doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have the RANK of : " ..class[ getPlayerGroupId(cid) ].name ..", Congratulations . ")
                    return true
                end
                


    --            next (  )
                if     getPlayerStorageValue(cid, cfg.storagetime )  >  class[( getPlayerGroupId(cid)+1 )].play_time             then
                     setPlayerGroupId(cid, ( getPlayerGroupId(cid)+1 ) )
                        setCreatureMaxHealth(cid,  class[ getPlayerGroupId(cid) ].life       )
                        setCreatureMaxMana(cid,   class[ getPlayerGroupId(cid) ].mana    )
                            doPlayerSetMaxCapacity(cid,  -( getPlayerMaxCap(cid) or 0 )+class[ getPlayerGroupId(cid) ].cap )
                            doChangeSpeed(cid,   -getCreatureSpeed(cid)+class[ getPlayerGroupId(cid) ].spd       )        --    getPlayerStorageValue(cid, cfg.storageSped )
                            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You got a new RANK : " ..class[ getPlayerGroupId(cid) ].name ..", status has been updated . ")
                else
                    local n_t_f_n_rank = class[( getPlayerGroupId(cid)+1 )].play_time  - getPlayerStorageValue(cid, cfg.storagetime )    -- needed time for new class
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "YOU RANK IS : " ..class[ getPlayerGroupId(cid) ].name ..": time for next rank . " .. n_t_f_n_rank/60/60 .." hours." )
                end


                if(getPlayerStorageValue(cid, cfg.storageBase) > 0) then
                    setPlayerStorageValue(cid,  cfg.storagelogin , os.clock()  )        --        save the time he loggin to play
                elseif getPlayerName(cid) ~= "Account Manager" then 
                        setPlayerStorageValue(cid,  cfg.storageBase , 1 )        --    
                        setPlayerStorageValue(cid,  cfg.storagetime , 0 )        --        save the time he started to play
                end


                return true
            end
    ]]></event>
    
    
-----------------------------------------------------------------------
    <event type="logout" name="CheckingPlayerRankLogout" event="script"><![CDATA[
    domodlib('rankTimeSystem')
    local cfg = rankTimeSetting
    local class = rankTimeClass    


function onLogout(cid)


        local played_time = ( os.clock() - getPlayerStorageValue(cid,  cfg.storagelogin  )    )
        if  played_time    >      1*60        then     --        if he played more than 1 min we will save his play time.
                setPlayerStorageValue(cid,  cfg.storagetime , ( getPlayerStorageValue(cid,  cfg.storagetime  )+played_time )    )
        end
        
        return true
end
]]></event>






<talkaction words="!myinfo" event="script"><![CDATA[
    domodlib('rankTimeSystem')
    local cfg = rankTimeSetting
    local class = rankTimeClass    
    
    function onSay(cid, words, param, channel)
        if(param ~= '') then
        
            if(param == 'spd') then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, getPlayerName(cid) .. " 's spd is " .. getCreatureSpeed(cid)     )
                return true
            end
            
            if (param == 'group') then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, getPlayerName(cid) .. " 's group is : " ..  getPlayerGroupId(cid)     )
                return true
            end
            
            if (param == 'rank') then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, getPlayerName(cid) .. " 's rank is : " .. class[ getPlayerGroupId(cid) ].name     )
                return true
            end
            
            if (param == 'playertime') then
                local played_time = ( os.clock() - getPlayerStorageValue(cid,  cfg.storagelogin  )    )
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, getPlayerName(cid) .. " 's  played time is : " .. played_time     )
                return true
            end
--        CHEAT CODE        --    getPlayerAccess(cid)
            if (param == 'add/playertime') then
                local played_time = ( os.clock() - getPlayerStorageValue(cid,  cfg.storagelogin  )    )
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, getPlayerName(cid) .. " 's  played time is : " .. played_time     )
                return true
            end
            
            
            
            
        end
        
        
        doPlayerSendCancel(cid, ' param can be "playertime", spd hp sp rank cap. ')
        
        return false
    end
]]></talkaction> 




<talkaction log="yes" words="!setrank" access="5" event="script"><![CDATA[
    domodlib('rankTimeSystem')
    local cfg = rankTimeSetting
    local class = rankTimeClass    
    
    --        !setrank Sailorv , Novato        or days like 365 for last rank
    
    function onSay(cid, words, param, channel)
        if(param == '') then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command param required.")
            return false
        end
        
        local t = string.explode(param, ",")
        local pid = getCreatureByName( t[1] )
        local days = tonumber(t[2])


        if not isPlayer(pid)  then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player not found.")
            return false
        end
        if    getPlayerGroupId(pid) < 1000   then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "This Player cant get More time.")
            return false
        end


        if(not days) then
            
            for k, v in pairs(class) do 


                if string.lower(t[2]) ==     string.lower(class[ k ].name) then 
                    setPlayerStorageValue(pid,  cfg.storagetime , ( class[ k ].play_time  )  )
                    setPlayerGroupId(pid, k-1 )
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, getPlayerName(pid) .." got the RANK of " .. class[ k ].name .. " . ")
                    return true
                end
            end


            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, " Rank name not Found . ")
            return false
        end


        local played_time =     ( days*24 ) *60*60        --    ADD TIME in DAYS
        setPlayerStorageValue(pid,  cfg.storagetime , ( getPlayerStorageValue(cid,  cfg.storagetime  )+played_time )    )
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, getPlayerName(pid) .." got " .. days .. " days")
        return true


    
    end
]]></talkaction> 




</mod>

-- talkactions for GOD and player
!setrank -- para mudar a classes do jogador
!setrank Sailorv , Novato or days like 365 for last rank
!myinfo -- verificar as info do jogagor
!myinfo spd hp sp group rank etc ...


-----------
i could do with out GROUP but i used it to show OTHERS that we can MORE with tibia than we are doing !!!
Code:
 
Last edited:
Bumping this.. Can someone make this script so it actually adds the hp/mana/speed/cap bonuses for each rank? :D It would be wonderful if when rank changes it would change ONLINE aswell. I think this could be beneficial for anyones server so I hope someone takes a look see at it :D I really want this to work.. lol... Please xD

- - - Updated - - -

:( sadness
 
Thank you very much, Very good idea, great for RPG servers
 
So, what are you expect to do on the OT?
Just gonna be online? xD
 
Back
Top