vbGore Free Online RPG Engine

Revolutionizing Visual Basic ORPG Development
It is currently Sun May 19, 2013 12:51 am

All times are UTC - 8 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Rank Add on
PostPosted: Sat Mar 21, 2009 7:00 pm 
Source Code Swashbuckler

Joined: Thu Jun 12, 2008 8:06 pm
Posts: 27
Name:NexSteve
Credit:No
Feature:Rank Add on
Difficulty:Easy
Edits:Server
Details:If the previous rank is already taken the next is assigned. If Admin was created first and his level is 5 and he has 500 xp he is rank 1, then Admin2 is created he has a level of 5 and 500xp but his rank is 2 because 1 is already take by the character created first.

First use this tutorial:
http://www.vbgore.com/Ranking

Then:

Find:
Code:
Private Sub Server_Update_Ranking()
Dim i As Long
Dim EXP As Long
Dim PrevEXP As Long
Dim Level As Long
Dim PrevLevel As Long

'We need to open the database so we can update it. We will open the database in desceding order.
DB_RS.Open "SELECT * FROM users ORDER BY stat_elv DESC,stat_exp DESC"

    'We will go through all the users so loop until End of File
    Do While Not DB_RS.EOF

        'Record the current user's level and exp to compare previous user's level and exp.
        EXP = DB_RS!stat_exp
        Level = DB_RS!stat_elv

        'So the current user's level is the same as the previous's user's lets compare their exp.
        If Level = PrevLevel Then
           'The current user's exp is less than the previous user's so he is under his rank.
           If EXP < PrevEXP Then i = i + 1
        Else
        'So the current user's level is the not equal to the previous's user's. Rank him down.
           i = i + 1
        End If

        'Record user's level and exp to compare next user's.
        PrevEXP = DB_RS!stat_exp
        PrevLevel = DB_RS!stat_elv

        'Set the user's rank
        DB_RS!rank = i

        'Update Database
        DB_RS.Update

        'NEXT USER!!!!
        DB_RS.MoveNext

    Loop
DB_RS.Close

End Sub


Replace:
Code:
Private Sub Server_Update_Ranking()
Dim i As Long
Dim Rank As Long
Dim PrevRank As Long
Dim EXP As Long
Dim PrevEXP As Long
Dim Level As Long
Dim PrevLevel As Long

'We need to open the database so we can update it. We will open the database in desceding order.
DB_RS.Open "SELECT * FROM users ORDER BY stat_elv DESC,stat_exp DESC"

    'We will go through all the users so loop until End of File
    Do While Not DB_RS.EOF

        'Record the current user's level and exp to compare previous user's level and exp.
        EXP = DB_RS!stat_exp
        Level = DB_RS!stat_elv

        'So the current user's level is the same as the previous's user's lets compare their exp.
        If Level = PrevLevel Then
           'The current user's exp is less than the previous user's so he is under his rank.
           If EXP < PrevEXP Then i = i + 1
        Else
        'So the current user's level is the not equal to the previous's user's. Rank him down.
           i = i + 1
        End If
       
        If i = PrevRank Then
            i = i + 1
        End If

        'Record user's level and exp to compare next user's.
        PrevEXP = DB_RS!stat_exp
        PrevLevel = DB_RS!stat_elv

        'Set the user's rank
        DB_RS!Rank = i
       
        'PrevRank
        PrevRank = DB_RS!Rank

        'Update Database
        DB_RS.Update

        'NEXT USER!!!!
        DB_RS.MoveNext

    Loop
DB_RS.Close
End Sub


Let me know if any problems come up.


Top
 Profile  
 
 Post subject: Re: Rank Add on
PostPosted: Sat Mar 21, 2009 8:10 pm 
Slave to the BB

Joined: Sat Feb 24, 2007 11:17 pm
Posts: 2704
Location: The Aussie Land
awesome++ !


Top
 Profile  
 
 Post subject: Re: Rank Add on
PostPosted: Sun Mar 22, 2009 2:10 am 
+7 Claymore of Slaying

Joined: Thu Dec 21, 2006 6:24 pm
Posts: 594
Location: Land made of long cloud. Wait no its Land of white clouds. Actually i think its New Zealand.
Okay o.o? Isn't it mine just as good?


Last edited by Enternaldr on Sun Mar 22, 2009 2:15 am, edited 2 times in total.

Top
 Profile  
 
 Post subject: Re: Rank Add on
PostPosted: Sun Mar 22, 2009 2:14 am 
baka

Joined: Tue Jul 08, 2008 12:17 am
Posts: 2304
Location: England, UK
Enternaldr wrote:
Okay o.o? Isn't mine just as good?

Instead of setting 2 users with the same level and EXP as the same rank, NexSteve's addon sets them as different ranks, depending on who was there first.

It's a modification of your ranking system.


Top
 Profile  
 
 Post subject: Re: Rank Add on
PostPosted: Mon Mar 23, 2009 4:07 pm 
Source Code Swashbuckler

Joined: Thu Jun 12, 2008 8:06 pm
Posts: 27
Lol you have to use you rank system before this tutorial even works. :rofl:


Top
 Profile  
 
 Post subject: Re: Rank Add on
PostPosted: Tue Mar 24, 2009 2:10 am 
Slave to the BB

Joined: Sat Feb 24, 2007 11:17 pm
Posts: 2704
Location: The Aussie Land
Nice work NexSteve

Quote:
First use this tutorial:
http://www.vbgore.com/Ranking


Maybe write:
"First add EternalDr's ranking script" or "Credit to EternalDr".

to prevent this from happening in the future :D


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 8 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group