Valhalla Legends Archive

Programming => Battle.net Bot Development => Topic started by: LizArD on March 03, 2004, 02:29 PM

Title: Database Problems
Post by: LizArD on March 03, 2004, 02:29 PM
I did not make this source, it was given to me by Voodoo[Fa], this is just the database part of it. He wont help me so I turn to these forums :) Anyway, when I add someone with any flag it seems to add fine of course, then when I reload the bot, it says "Error in database" I don't know what information you need to help me, so I just pasted the whole source for database.. Any help be great =]

Public Sub LoadDB()
   On Error Resume Next
   Dim Change As Boolean
   Dim Splt() As String
   Dim Tempa As al
   'username, rank, flags, date, time, addedby
   Open "Database.txt" For Input As #1
   Do Until EOF(1)
   Line Input #1, Item
   If Item <> "" Then
   Splt() = Split(Item, " ")
   If UBound(Splt) > 3 Or UBound(Splt) < 3 Then
       MsgBox "Error loading database", vbCritical, "Error"
       End
   End If
   If Splt(1) >= 101 Or Splt(1) < 0 Then
       MsgBox "Error loading database", vbCritical, "Error"
       End
   End If
   If UCase(Splt(2)) <> "NO" And UCase(Splt(2)) <> "S" And UCase(Splt(2)) <> "B" And UCase(Splt(2)) <> "K" Then
       MsgBox "Error loading database", vbCritical, "Error"
       End
   End If
   If Splt(1) > 0 And UCase(Splt(2)) <> "NO" Then
       MsgBox "Error loading database", vbCritical, "Error"
       End
   End If
   If UCase(Splt(6)) <> "NONE" Then
       Tempa.BMessage = Splt(3)
   Else
       Tempa.BMessage = "None"
   End If
   Tempa.Rank = Splt(1)
   Tempa.Flags = UCase(Splt(2))
   Tempa.Username = Splt(0)
   AddAccess Tempa
   End If
Ending69:
   Loop
   Close #1
   SaveAccessList
End Sub
Title: Re:Database Problems
Post by: K on March 03, 2004, 02:35 PM
Ok, so I'm anal.


Public Sub LoadDB()
   On Error Resume Next

   Dim Change As Boolean
   Dim Splt() As String
   Dim Tempa As al

   'username, rank, flags, date, time, addedby
   Open "Database.txt" For Input As #1
   
   Do Until EOF(1)



      Line Input #1, Item

      If Item <> "" Then
         Splt() = Split(Item, " ")

         If UBound(Splt) > 3 Or UBound(Splt) < 3 Then
            MsgBox "Error loading database", vbCritical, "Error"
            End
         End If

         If Splt(1) >= 101 Or Splt(1) < 0 Then
            MsgBox "Error loading database", vbCritical, "Error"
            End
            End If

         If UCase(Splt(2)) <> "NO" And UCase(Splt(2)) <> "S" _
        And UCase(Splt(2)) <> "B" And UCase(Splt(2)) <> "K" Then
            MsgBox "Error loading database", vbCritical, "Error"
            End
         End If

         If Splt(1) > 0 And UCase(Splt(2)) <> "NO" Then
            MsgBox "Error loading database", vbCritical, "Error"
            End
         End If

         If UCase(Splt(6)) <> "NONE" Then
            Tempa.BMessage = Splt(3)
         Else
            Tempa.BMessage = "None"
         End If

            Tempa.Rank = Splt(1)
            Tempa.Flags = UCase(Splt(2))
            Tempa.Username = Splt(0)
            AddAccess Tempa

      End If
   Loop

   Close #1

   SaveAccessList

End Sub
Title: Re:Database Problems
Post by: LizArD on March 03, 2004, 02:53 PM
thx for organizing it lol now lets just see if we can fix it =\
Title: Re:Database Problems
Post by: Eric on March 03, 2004, 02:57 PM
Would help to not copy directly from my open source Shadow Bot project, and when you do, copy everything you need, not just half of what you need.

You need to learn how to use dynamic arrays.
http://pscode.com/vb/

This post should be in the Visual Basic forum, not this one.

EDIT: Ew, when looking at my coding, keep in mind Shadow Bot was coded over a year and a half ago.
Title: Re:Database Problems
Post by: LizArD on March 03, 2004, 03:09 PM
I didn't code this bot, Yell at Voodoo
Title: Re:Database Problems
Post by: Kp on March 03, 2004, 06:01 PM
Without reading your code in any detail, I can say that the problem is that your LoadDB and SaveDB routines disagree on the format in which data is saved.  As a result, LoadDB gives an error when it receives an improperly formatted database.  Fix your SaveDB code. :P
Title: Re:Database Problems
Post by: LizArD on March 03, 2004, 06:48 PM
Thanks a lot, lol it actually was the save. It was reading spaces in between the seperators, and I had boxes. All fixxed now =)