Ranking
From VbGORE Visual Basic Online RPG Engine
Contents |
Overview
Hey this is EnternalDR here. In this guide i will show you how to do a simple and effective ranking system. This guide will only require you to edit your server and database. You may go more into the ranking system if you want. Follow the guide step by step so you won't encounter any problems.
Note: This ranking system sets users with same exp and level as the same rank.
EG. I is Level 20 with 250 exp. I is ranked 15503. U is also Level 20 with 250 exp. U is also ranked 15503 not 15504.
Credits
EnternalDR - Making this guide
Spodi - Developing vbGore
The Guide
Step 1. Editing the Database
Go to your vbgore database, right click on the users table and click on "Alter table"
You should then see a window with the options "Alter", "Advanced Properties...", "Insert", "Delete" and "Cancel" at the bottom if your using SQLyog.
There should be the following in the first five data in the tables in order. <vb> Field Name Data Type Len PK Not Null
name varchar 255 Yes ip varchar 255 Yes gm tinyint 3 Yes password varchar 255 Yes descr varchar 255 Yes inventory text Yes </vb>
Now click on "gm" colomn then click "Insert" at the bottom. An empty colomn should appear.
Insert the information provided below in empty colomn: Don't insert anything in a slot if it says <EMPTY>.
Field Name - rank
Datatype - int
Len - 3
Default - 0
Collation - <EMPTY>
PK - <UNTICK>
Not Null - <TICK>
Unsigned - <UNTICK>
Auto Incr? - <UNTICK>
Zerofill? - <UNTICK>
Comment - The user's ranking.
Step 2. Adding to the server
Now we want the server to update the ranking regularly so we must add something to the server.
Open GameServer.vbp
Open General(General.bas)
Below <vb>Private Const UpdateRate_Save As Long</vb> add
<vb>
Private Const UpdateRate_Ranking As Long = 600000
</vb>
You may change the value to whatever suits you. This default value is just 10 minutes between updates.
Below <vb>Private LastUpdate_Save As Long</vb> add
<vb>
Private LastUpdate_Ranking As Long
</vb>
Below <vb>Private UpdateNPCCounters As Byte 'Update the NPC's counters</vb> add
<vb>
Private UpdateRanking As Byte
</vb>
Now go to Public Sub Server_Update()
Under Dim UpdateNPCs As Byte add
<vb>
Dim UpdateRanks As Byte
</vb>
Under
<vb>
'Object unloading
If LastUpdate_UnloadObjs + UpdateRate_UnloadObjs < LoopStartTime Then
LastUpdate_UnloadObjs = LoopStartTime
ObjData.CheckObjUnloading
End If
</vb> add <vb>
'Update Ranking
If LastUpdate_Ranking + UpdateRate_Ranking < LoopStartTime Then
UpdateRanking = 1
LastUpdate_Ranking = LoopStartTime
UpdateRanks = 1
End If
</vb>
Now under <vb> If UpdateUsers Then Server_Update_Users </vb> add
<vb> If UpdateRanks Then Server_Update_Ranking</vb>
Now scroll all the way to the bottom of the window so you see a End Sub Under the End Sub add <vb>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 </vb>
This Ranking System?
This ranking system is just a basic 'skeleton'. You can further use this for things such as vbGoreSP, ingame ranking and other things. This system only edits the database and does't actually have anything to do ingame. You may further expand this guide if you wish just leave my name in the Credits.