13-04-2008, 02:23 PM
Load Player
[spoiler][/spoiler]
Save Player
[spoiler][/spoiler]
[spoiler]
Code:
Sub LoadPlayer(ByVal Index As Long, ByVal Name As String)
Dim filename As String
Dim FileName2 As String
Dim CharName As String * NAME_LENGTH
Dim i As Long
Dim N As Long
Dim f As Long
Call ClearPlayer(Index)
filename = App.Path & "\main\Accounts\" & Trim$(Name)
f = FreeFile
Open filename & "\Account.dat" For Binary As #f
Get #f, , Player(Index).Login
Get #f, , Player(Index).Password
For i = 1 To MAX_CHARS
Get #f, , CharName
FileName2 = filename & "\" & Trim$(CharName) & "\Char.dat"
If FileExist("main\Accounts\" & Trim$(Name) & "\" & Trim$(CharName) & "\Char.dat") Then
N = FreeFile
Open FileName2 For Binary As #N
Get #N, , Player(Index).Char(i)
Close #N
End If
Next i
Close #f
Exit Sub
End Sub
Save Player
[spoiler]
Code:
Sub SavePlayer(ByVal Index As Long)
Dim filename As String
Dim PlayerName As String
Dim CharName As String
Dim i As Long
Dim N As Long
Dim f As Long
PlayerName = Trim$(Player(Index).Login)
If Dir(App.Path & "\main\Accounts\" & PlayerName, vbDirectory) = "" Then MkDir App.Path & "\main\Accounts\" & PlayerName
filename = App.Path & "\main\Accounts\" & PlayerName & "\Account.dat"
f = FreeFile
Open filename For Binary As #f
Put #f, , Player(Index).Login
Put #f, , Player(Index).Password
For i = 1 To MAX_CHARS
Put #f, , Player(Index).Char(i).Name
Next i
Close #f
For i = 1 To MAX_CHARS
If Trim$(Player(Index).Char(i).Name) "" Then
CharName = Trim$(Player(Index).Char(i).Name)
filename = App.Path & "\main\Accounts\" & PlayerName & "\" & CharName
If Dir(filename, vbDirectory) = "" Then MkDir filename
filename = filename & "\Char.dat"
f = FreeFile
Open filename For Binary As #f
Put #f, , Player(Index).Char(i)
Close #f
End If
Next i
End Sub