summaryrefslogtreecommitdiff
path: root/source/sourcemod/scripting/gokz-localdb/db/setup_database.sp
diff options
context:
space:
mode:
authoraura <nw@moneybot.cc>2026-02-17 23:42:09 +0100
committeraura <nw@moneybot.cc>2026-02-17 23:42:09 +0100
commit5e2eb7d67ae933b7566f1944d0bb7744da03d586 (patch)
tree054acff1113270a9cd07933df760f3768c1b6853 /source/sourcemod/scripting/gokz-localdb/db/setup_database.sp
parent341db13a008dc12bb22ceb50452d93d01476308c (diff)
move source stuff to its own folder
Diffstat (limited to 'source/sourcemod/scripting/gokz-localdb/db/setup_database.sp')
-rw-r--r--source/sourcemod/scripting/gokz-localdb/db/setup_database.sp34
1 files changed, 34 insertions, 0 deletions
diff --git a/source/sourcemod/scripting/gokz-localdb/db/setup_database.sp b/source/sourcemod/scripting/gokz-localdb/db/setup_database.sp
new file mode 100644
index 0000000..4965541
--- /dev/null
+++ b/source/sourcemod/scripting/gokz-localdb/db/setup_database.sp
@@ -0,0 +1,34 @@
+/*
+ Set up the connection to the local database.
+*/
+
+
+
+void DB_SetupDatabase()
+{
+ char error[255];
+ gH_DB = SQL_Connect("gokz", true, error, sizeof(error));
+ if (gH_DB == null)
+ {
+ SetFailState("Database connection failed. Error: \"%s\".", error);
+ }
+
+ char databaseType[8];
+ SQL_ReadDriver(gH_DB, databaseType, sizeof(databaseType));
+ if (strcmp(databaseType, "sqlite", false) == 0)
+ {
+ g_DBType = DatabaseType_SQLite;
+ }
+ else if (strcmp(databaseType, "mysql", false) == 0)
+ {
+ g_DBType = DatabaseType_MySQL;
+ }
+ else
+ {
+ SetFailState("Incompatible database driver. Use SQLite or MySQL.");
+ }
+
+ DB_CreateTables();
+
+ Call_OnDatabaseConnect();
+} \ No newline at end of file