Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Rank Level System - 100% Functional


Valentine90
 Share

Recommended Posts

**Sorry my english**

Hello friends, I think we all know how a system of rank, something essential for a true MMORPG, know that there are some systems rank around and perhaps many of you already have, but this is a simple and complete do- so, system fully tested and approved.

**Open Client**

**1 -** In frmMain, create a Picturebox called **picRank**

![](http://img824.imageshack.us/img824/4513/57744486.png)

**2 -** Within the picRank create a ListBox called **lstRank**

![](http://img811.imageshack.us/img811/9121/60970805.png)

**3 -** Create a button called **cmdRefresh**

![](http://img543.imageshack.us/img543/7374/54104775.png)

**Obs.:** It should stay like this:

![](http://img5.imageshack.us/img5/3637/imgahp.png)

**4 -** Select the Option Visible False in the picRank

![](http://img442.imageshack.us/img442/3285/69569137.png)

**5 -** In same button **cmdRefresh**, double-click and replace:

```
Private Sub cmdRefresh_Click()

End Sub
```
**6 -** By:

```
Private Sub cmdRefresh_Click()

' If debug mode, handle error then exit out

If Options.Debug = 1 Then On Error GoTo errorhandler

SendRequestRank

' Error handler

Exit Sub

errorhandler:

HandleError "cmdRefresh_Click", "frmMain", Err.Number, Err.Description, Err.Source, Err.HelpContext

Err.Clear

Exit Sub

End Sub
```
**7 -** In **modConstants**, search for:

```
Public Const MAX_PARTY_MEMBERS As Long = 4
```
**8 -** Below add:

```
Public Const MAX_RANK As Long = 10
```
**9 -** At the end of **modClientTCP**, add:

```
Public Sub SendRequestRank()

Dim Buffer As clsBuffer

' If debug mode, handle error then exit out

If Options.Debug = 1 Then On Error GoTo errorhandler

Set Buffer = New clsBuffer

Buffer.WriteLong CRequestRank

SendData Buffer.ToArray()

Set Buffer = Nothing

' Error handler

Exit Sub

errorhandler:

HandleError "SendRequestRank", "modClientTCP", Err.Number, Err.Description, Err.Source, Err.HelpContext

Err.Clear

Exit Sub

End Sub
```
**10 -** In **modEnumerations**, search for:

```
' Make sure CMSG_COUNT is below everything else
```
**11 -** Above this line and below of:

```
CPartyLeave
```
**12 -** Add:

```
CRequestRank
```
**Obs.:**It should stay like this:

![](http://img826.imageshack.us/img826/4250/27115231.png)

**13 -** Still in **modEnumerations**, search for:

```
' Make sure SMSG_COUNT is below everything else
```
**14 -** Above this line and below of:

```
SPartyVitals
```
**15 -** Add:

```
SRankUpdate
```
**16 -** In **modHandleData**, search for:

```
HandleDataSub(SPartyVitals) = GetAddress(AddressOf HandlePartyVitals)
```
**17 -** Below add:

```
HandleDataSub(SRankUpdate) = GetAddress(AddressOf HandleRankUpdate)
```
**18 -** At the end of **modHandleData**, add:

```
Private Sub HandleRankUpdate(ByVal Index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)

Dim Buffer As clsBuffer, i As Byte

' If debug mode, handle error then exit out

If Options.Debug = 1 Then On Error GoTo errorhandler

Set Buffer = New clsBuffer

Buffer.WriteBytes Data()

frmMain.lstRank.Clear

For i = 1 To MAX_RANK

frmMain.lstRank.AddItem i & ":Level: " & Buffer.ReadLong & ", Name: " & Trim$(Buffer.ReadString)

Next i

Set Buffer = Nothing

' Error handler

Exit Sub

errorhandler:

HandleError "HandleRankUpdate", "modHandleData", Err.Number, Err.Description, Err.Source, Err.HelpContext

Err.Clear

Exit Sub

End Sub
```
**19 -** In **modInput**, search for:

```
' Whos Online

Case "/who"

SendWhosOnline
```
**20 -** Below add:

```
' Request Rank

Case "/rank"

SendRequestRank

frmMain.picRank.Visible = Not frmMain.picRank.Visible
```
**21 -** In **modGeneral**, search for:

```
frmMain.picParty.Visible = False
```
**22 -** Below add:

```
frmMain.picRank.Visible = False
```

**Open Server**

**1 -** In **modConstants**, search for:

```
Public Const MAX_PARTY_MEMBERS As Long = 4
```
**2 -** Below add:

```
Public Const MAX_RANK As Long = 10
```
**3 -** In **modEnumerations**,search for:

```
' Make sure SMSG_COUNT is below everything else
```
**4 -** Above this line and below of:

```
SPartyVitals
```
**5 -** Add:

```
SRankUpdate
```
**6 -** Still in **modEnumerations**, search for:

```
' Make sure CMSG_COUNT is below everything else
```
**7 -** Above this line and below of:

```
CPartyLeave
```
**8 -** Add:

```
CRequestRank
```
**9 -** In **modHandleData**, search for:

```
HandleDataSub(CPartyLeave) = GetAddress(AddressOf HandlePartyLeave)
```
**10** - Below Add:

```
HandleDataSub(CRequestRank) = GetAddress(AddressOf HandleRequestRank)
```
**11 -** At the end of **modHandleData**, add:

```
Sub HandleRequestRank(ByVal index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)

SendRankUpdate index

End Sub
```
**12 -** At the end of **modServerTCP**, add:

```
Sub SendRankUpdate(ByVal index As Long)

Dim i As Byte

Dim Buffer As clsBuffer

Set Buffer = New clsBuffer

Buffer.WriteLong SRankUpdate

For i = 1 To MAX_RANK

Buffer.WriteLong Rank(i).Level

Buffer.WriteString Trim$(Rank(i).Name)

Next i

SendDataTo index, Buffer.ToArray()

Set Buffer = Nothing

End Sub
```
**13 -** In **modPlayer**, search for

```
Sub CheckPlayerLevelUp(ByVal index As Long)
```
**14 -** Beneath of:

```
Dim level_count As Long
```
**15 -** Add:

```
Dim RankPos As Byte
```
**16 -** Beneath of:

```
SendPlayerData index
```
**17 -** Add:

```
' check rank

RankPos = CheckRank(index)

If RankPos > 0 Then

ChangeRank index, RankPos

End If
```
**18 -** At the end of **modPlayer**, add:

```
Private Function CheckRank(ByVal index As Long) As Byte

Dim i As Byte

For i = 1 To MAX_RANK

If GetPlayerLevel(index) > Rank(i).Level Then

CheckRank = i

Exit Function

End If

Next i

End Function

Private Sub ChangeRank(ByVal index As Long, RankPos As Byte)

Dim i As Long, ClearPos As Byte

' if not change position in rank

If GetPlayerName(index) = Trim$(Rank(RankPos).Name) Then

Rank(RankPos).Level = GetPlayerLevel(index)

SaveRank

Exit Sub

End If

' search player in rank

For i = 1 To MAX_RANK

If GetPlayerName(index) = Trim$(Rank(i).Name) Then

Rank(i).Name = vbNullString

Rank(i).Level = 0

ClearPos = i

Exit For

End If

Next i

' down clear position

If ClearPos > 0 Then

For i = ClearPos To MAX_RANK

If i = MAX_RANK Then

Rank(i).Name = vbNullString

Rank(i).Level = 0

Else

Rank(i).Name = Rank(i + 1).Name

Rank(i).Level = Rank(i + 1).Level

End If

Next i

End If

' open space in rank to player

For i = MAX_RANK To RankPos Step -1

If i > RankPos Then

Rank(i).Name = Rank(i - 1).Name

Rank(i).Level = Rank(i - 1).Level

End If

Next i

' put player in rank

Rank(RankPos).Name = GetPlayerName(index)

Rank(RankPos).Level = GetPlayerLevel(index)

SaveRank

End Sub
```
**19 -** At the end of **modDatabase**, add:

```
Public Sub SaveRank()

Dim filename As String, i As Byte

filename = App.Path & "\data\rank.ini"

For i = 1 To MAX_RANK

PutVar filename, "RANK", "Name" & i, Trim$(Rank(i).Name)

PutVar filename, "RANK", "Level" & i, Val(Rank(i).Level)

Next i

End Sub

Public Sub LoadRank()

Dim filename As String, i As Byte

filename = App.Path & "\data\rank.ini"

If FileExist(filename, True) Then

For i = 1 To MAX_RANK

Rank(i).Name = GetVar(filename, "RANK", "Name" & i)

Rank(i).Level = Val(GetVar(filename, "RANK", "Level" & i))

Next i

Else

SaveRank

End If

End Sub
```
**20 -** In **modTypes**, search for:

```
Public Party(1 To MAX_PARTYS) As PartyRec
```
**21 -** Below add:

```
Public Rank(1 To MAX_RANK) As RankRec
```
**22 -** Beneath of:

```
Private Type OptionsRec

Game_Name As String

MOTD As String

Port As Long

Website As String

End Type
```
**23 -** Add:

```
Private Type RankRec

Name As String * ACCOUNT_LENGTH

Level As Long

End Type
```
**24 -** In **modPlayer**, search for:

```
' Send Resource cache

For i = 0 To ResourceCache(GetPlayerMap(index)).Resource_Count

SendResourceCacheTo index, i

Next
```
**25 -** Below add:

```
' Check Rank

For i = 1 To MAX_RANK

If Trim$(Rank(i).Name) = GetPlayerName(index) Then

Exit For

End If

If GetPlayerLevel(index) > Rank(i).Level Then

Rank(i).Name = GetPlayerName(index)

Rank(i).Level = GetPlayerLevel(index)

SaveRank

Exit For

End If

Next i
```
**26 -**In **modGeneral**,search for:

```
Call SetStatus("Loading animations...")

Call LoadAnimations
```
**27 -** Below Add:

```
Call SetStatus("Loading rank...")

Call LoadRank
```

**Credits:**

Valentine
Link to comment
Share on other sites

> can you explain what this kind of rank system is? different ways you can look at it.

I agree I was looking at the code and guessing its something to do with party ranks…. maybe???

or maybe like after your reach a level you will be come called something else???

Example

at level 1 your a Noob

at level 100 your an EPIC
Link to comment
Share on other sites

> my rank system is completely different from this x3
>
> Mine uses a point system. and when you complete a mission, it gives you points.

That's kinda irrelevant here.

This is a ranking list of the highest levels in the game using words like Noob > Pro > God. Hopefully that's clear.

I was actually going to make this once I release my game but this will save me time. Thanks for the submission.
Link to comment
Share on other sites

  • 1 year later...
> what is the use from * ACCOUNT_LENGTH ?

To make sure that the String have defined length when saving.. I don't know how to explain it since i'm not english person, my grammar always mess up so.. i'll just say it in a simple way

You need to define the length of a string before saving it on a file or a text (This answer is base on my experience, probably wrong or correct.. )
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...