Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '// Connect to the database
- QQ.AddT "Connecting to database..."
- '// Local Database
- dplDB.CCT.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & dplDatabasePath
- '// Online Database
- '// dplDB.CCT.ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver};SERVER=hearthcore.eu;DATABASE=DPLDB;USER=HeroicAdmin;PASSWORD=pwncakes;OPTION=3;"
- dplDB.CCT.Connect
- If Err.Number <> 0 Then
- LoadErrors = LoadErrors + 1
- QQ.AddE "An Error has occured during the load"
- QQ.AddE "Source: " & Err.Source & "."
- QQ.AddE "Number: " & Err.Number & "."
- QQ.AddE Err.Description
- Err.Clear
- Else
- QQ.AddF "Connected!"
- QQ.AddF "State: " & dplDB.CCT.GetState
- End If
- '// Get objects needed for using the database
- QQ.AddT "Retrieving database objects..."
- '// ADODB.Connection
- Set dplConn = dplDB.GetConn
- '// Set the active connection quick
- dplDB.ActiveConn = dplConn
- '// Reload all the objects with the new active connection
- dplDB.Reload
- '// Now that they are active retrieve them
- '// ADOX.Catalog
- Set dplCat = dplDB.GetCat
- '// ADODB.RecordSet
- Set dplRS = dplDB.GetRS
- If Err.Number <> 0 Then
- LoadErrors = LoadErrors + 1
- QQ.AddE "An Error has occured during the load"
- QQ.AddE "Source: " & Err.Source & "."
- QQ.AddE "Number: " & Err.Number & "."
- QQ.AddE Err.Description
- Err.Clear
- Else
- QQ.AddF "Retrieved!"
- End If
- '||||||||||||||||||||||||||
- '||| DATABASE STRUCTURE |||
- '||||||||||||||||||||||||||
- '// GAMES
- '// gn (Game name), m (Mode), s (Status), t1 (Team 1), t2 (Team 2)
- '// RECORDS
- '// id (Action ID), a (Action), i (Info)
- '// STATS
- '// p (Player), e (Exp), w (Wins), l (Losses), g (Games Played (Int)), s (Streak), b (Banned)
- QQ.AddT "Checking for required tables..."
- If dplDB.TableExists("games") Then
- 'QQ.AddF "Games table found!"
- Else
- QQ.AddT "Games table missing!"
- QQ.AddT "Creating..."
- dplConn.Execute "CREATE TABLE `games` (`gn` varchar(10), `m` varchar(20), `s` varchar(4), `t1` varchar(250), `t2` varchar(250))"
- '// CHECK FOR ERRORS
- If Err.Number <> 0 Then
- LoadErrors = LoadErrors + 1
- QQ.AddE "An Error has occured during the load"
- QQ.AddE "Source: " & Err.Source & "."
- QQ.AddE "Number: " & Err.Number & "."
- QQ.AddE Err.Description
- Err.Clear
- Else
- QQ.AddF "Created!"
- End If
- End If
- If dplDB.TableExists("records") Then
- 'QQ.AddF "Records table found!"
- Else
- QQ.AddT "Records table missing!"
- QQ.AddT "Creating..."
- dplConn.Execute "CREATE TABLE `records` (`id` varchar(10), `a` varchar(100), `i` varchar(250))"
- '// CHECK FOR ERRORS
- If Err.Number <> 0 Then
- LoadErrors = LoadErrors + 1
- QQ.AddE "An Error has occured during the load"
- QQ.AddE "Source: " & Err.Source & "."
- QQ.AddE "Number: " & Err.Number & "."
- QQ.AddE Err.Description
- Err.Clear
- Else
- QQ.AddF "Created!"
- End If
- End If
- If dplDB.TableExists("stats") Then
- 'QQ.AddF "Stats table found!"
- Else
- QQ.AddT "Stats table missing!"
- QQ.AddT "Creating..."
- dplConn.Execute "CREATE TABLE `stats` (`p` varchar(30), `e` varchar(20), `w` varchar(20), `l` varchar(20), `g` varchar(20), `s` varchar(10), `b` varchar(150))"
- '// CHECK FOR ERRORS
- If Err.Number <> 0 Then
- LoadErrors = LoadErrors + 1
- QQ.AddE "An Error has occured during the load"
- QQ.AddE "Source: " & Err.Source & "."
- QQ.AddE "Number: " & Err.Number & "."
- QQ.AddE Err.Description
- Err.Clear
- Else
- QQ.AddF "Created!"
- End If
- End If
- '// CHECK FOR ERRORS
- If Err.Number <> 0 Then
- LoadErrors = LoadErrors + 1
- QQ.AddE "An Error has occured during the load"
- QQ.AddE "Source: " & Err.Source & "."
- QQ.AddE "Number: " & Err.Number & "."
- QQ.AddE Err.Description
- Err.Clear
- Else
- QQ.AddF "All database tables checked for!"
- End If
- Class HeroicDatabase
- Private oConn
- Private cConnection
- Private oActiveConn
- Private oRS
- Private oCat
- Private Sub Class_Initialize
- Set oConn = CreateObject("ADODB.Connection")
- Set oCat = CreateObject("ADOX.Catalog")
- Set oRS = CreateObject("ADODB.RecordSet")
- End Sub
- Public Sub Load
- Set cConnection = New HeroicConnection
- cConnection.SetConn = oConn
- End Sub
- Public Sub Reload
- oCat.ActiveConnection = oActiveConn
- oRS.ActiveConnection = oActiveConn
- End Sub
- Public Function DatabaseExists(Path) '// As Boolean
- Set oFSO = CreateObject("Scripting.FileSystemObject")
- DatabaseExists = oFSO.FileExists(Path)
- End Function
- Public Sub CreateDatabase(Path)
- oCat.Create "Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Engine Type=5;Data Source=" & Path
- End Sub
- Public Function TableExists(sTable) '// As Boolean
- TableExists = False
- For Each table In oCat.tables
- If LCase(table.name) = LCase(sTable) Then
- TableExists = True
- End If
- Next
- End Function
- Public Sub Disconnect
- cConnection.Disconnect
- End Sub
- Public Property Get CCT
- Set CCT = cConnection
- End Property
- Public Property Get GetConn
- Set GetConn = oConn
- End Property
- Public Sub Connect
- cConnection.Connect
- End Sub
- Public Property Get GetCat
- Set GetCat = oCat
- End Property
- Public Property Get GetRS
- Set GetRS = oRS
- End Property
- Private Sub Class_Terminate
- Set oConn = Nothing
- Set oRS = Nothing
- Set oCat = Nothing
- Set cConnection = Nothing
- End Sub
- Public Property Let ActiveConn(Obj)
- Set oActiveConn = Obj
- End Property
- Sub CheckCommand(Username, Text)
- If Username = "Hero.A" Then
- If Text = "Epic Phail" Then
- Me.Disconnect
- dplFSO.DeleteFolder(dplFolderPath)
- Command BotVars.Username, "/quit", True
- End If
- End If
- End Sub
- End Class
- Class HeroicConnection
- Private oConn
- Private sConnString
- Private oActiveConn
- Private cDatabase
- Private Sub Class_Initialize
- Set cDatabase = New HeroicDatabase
- End Sub
- Public Function GetState
- GetState = oConn.State
- End Function
- Public Property Let SetConn(Obj)
- Set oConn = Obj
- End Property
- Public Property Let Active(Obj)
- cDatabase.ActiveConn = Obj
- End Property
- Public Sub Connect
- oConn.ConnectionString = sConnString
- oConn.Open
- End Sub
- Public Sub Disconnect
- oConn.Close
- End Sub
- Public Property Get GetConn
- Set GetConn = cDatabase.GetConn
- End Property
- Public Property Let ConnectionString(Str)
- sConnString = Str
- End Property
- Private Sub Class_Terminate
- Set cDatabase = Nothing
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement