Bom, quando eu upo aparece no chat que eu estou 1 level a menos EX: Brenno subiu Top 2, sendo que estou no 1 assim sucessivamente se eu estive no 8 estaria subindo top 9.
[img][/img]
[img][/img]
- Código:
' check rank
RankPos = CheckRank(Index)
If RankPos > 0 Then
ChangeRank Index, RankPos
GlobalMsg GetPlayerName(Index) & " Subiu Top " & CheckRank(Index) & " Rank!", Green
End If
SendPlayerData Index
GanharItem Index
End If
- Código:
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
- Código:
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