diff options
| author | navewindre <nw@moneybot.cc> | 2023-12-04 18:06:10 +0100 |
|---|---|---|
| committer | navewindre <nw@moneybot.cc> | 2023-12-04 18:06:10 +0100 |
| commit | aef0d1c1268ab7d4bc18996c9c6b4da16a40aadc (patch) | |
| tree | 43e766b51704f4ab8b383583bdc1871eeeb9c698 /sourcemod/scripting/gokz-localdb/db/setup_database.sp | |
| parent | 38f1140c11724da05a23a10385061200b907cf6e (diff) | |
bbbbbbbbwaaaaaaaaaaa
Diffstat (limited to 'sourcemod/scripting/gokz-localdb/db/setup_database.sp')
| -rw-r--r-- | sourcemod/scripting/gokz-localdb/db/setup_database.sp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/sourcemod/scripting/gokz-localdb/db/setup_database.sp b/sourcemod/scripting/gokz-localdb/db/setup_database.sp new file mode 100644 index 0000000..4965541 --- /dev/null +++ b/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 |
