24-01-2008, 04:33 AM
Alrighty then...as I was looking through optimizations, I stumbled upon how to clear players and such easier:
I've also stumbled upon a problem with this. For strings that are given a max length property (like Name As String * NAME_LENGTH) the value of that string is given the number of spaces the property's number is (so for Name it would be given 20 spaces, since NAME_LENGTH is 20). So now every check for If Player().Whatever = "" or vbNullString, the value will return opposite of what we want...for example:
That will always return true and won't let anybody login.
What's the best way to solve this? I know to just set them = "", but that's too tedious...there has to be another way than going through all the Clear subs and checking all the strings in the array and making sure they're set to "".
Code:
Sub ClearPlayer(ByVal Index As Long)
Dim EmptyPlayer As AccountRec
Player(Index) = EmptyPlayer
End Sub
I've also stumbled upon a problem with this. For strings that are given a max length property (like Name As String * NAME_LENGTH) the value of that string is given the number of spaces the property's number is (so for Name it would be given 20 spaces, since NAME_LENGTH is 20). So now every check for If Player().Whatever = "" or vbNullString, the value will return opposite of what we want...for example:
Code:
Function IsLoggedIn(ByVal Index As Long) As Boolean
If IsConnected(Index) And Trim$(Player(Index).Login) vbNullString Then
MsgBox Player(Index).Login
IsLoggedIn = True
Else
IsLoggedIn = False
End If
End Function
That will always return true and won't let anybody login.
What's the best way to solve this? I know to just set them = "", but that's too tedious...there has to be another way than going through all the Clear subs and checking all the strings in the array and making sure they're set to "".