summaryrefslogtreecommitdiff
path: root/sourcemod/scripting/gokz-localdb/db/setup_client.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 /sourcemod/scripting/gokz-localdb/db/setup_client.sp
parent341db13a008dc12bb22ceb50452d93d01476308c (diff)
move source stuff to its own folder
Diffstat (limited to 'sourcemod/scripting/gokz-localdb/db/setup_client.sp')
-rw-r--r--sourcemod/scripting/gokz-localdb/db/setup_client.sp99
1 files changed, 0 insertions, 99 deletions
diff --git a/sourcemod/scripting/gokz-localdb/db/setup_client.sp b/sourcemod/scripting/gokz-localdb/db/setup_client.sp
deleted file mode 100644
index 848be87..0000000
--- a/sourcemod/scripting/gokz-localdb/db/setup_client.sp
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- Inserts the player into the database, or else updates their information.
-*/
-
-
-
-void DB_SetupClient(int client)
-{
- if (IsFakeClient(client))
- {
- return;
- }
-
- // Setup Client Step 1 - Upsert them into Players Table
- char query[1024], name[MAX_NAME_LENGTH], nameEscaped[MAX_NAME_LENGTH * 2 + 1], clientIP[16], country[45];
-
- int steamID = GetSteamAccountID(client);
- if (!GetClientName(client, name, MAX_NAME_LENGTH))
- {
- LogMessage("Couldn't get name of %L.", client);
- name = "Unknown";
- }
- SQL_EscapeString(gH_DB, name, nameEscaped, MAX_NAME_LENGTH * 2 + 1);
- if (!GetClientIP(client, clientIP, sizeof(clientIP)))
- {
- LogMessage("Couldn't get IP of %L.", client);
- clientIP = "Unknown";
- }
- if (!GeoipCountry(clientIP, country, sizeof(country)))
- {
- LogMessage("Couldn't get country of %L (%s).", client, clientIP);
- country = "Unknown";
- }
-
- DataPack data = new DataPack();
- data.WriteCell(GetClientUserId(client));
- data.WriteCell(steamID);
-
- Transaction txn = SQL_CreateTransaction();
-
- // Insert/Update player into Players table
- switch (g_DBType)
- {
- case DatabaseType_SQLite:
- {
- // UPDATE OR IGNORE
- FormatEx(query, sizeof(query), sqlite_players_update, nameEscaped, country, clientIP, steamID);
- txn.AddQuery(query);
- // INSERT OR IGNORE
- FormatEx(query, sizeof(query), sqlite_players_insert, nameEscaped, country, clientIP, steamID);
- txn.AddQuery(query);
- }
- case DatabaseType_MySQL:
- {
- // INSERT ... ON DUPLICATE KEY ...
- FormatEx(query, sizeof(query), mysql_players_upsert, nameEscaped, country, clientIP, steamID);
- txn.AddQuery(query);
- }
- }
-
- FormatEx(query, sizeof(query), sql_players_get_cheater, steamID);
- txn.AddQuery(query);
-
- SQL_ExecuteTransaction(gH_DB, txn, DB_TxnSuccess_SetupClient, DB_TxnFailure_Generic_DataPack, data, DBPrio_High);
-}
-
-public void DB_TxnSuccess_SetupClient(Handle db, DataPack data, int numQueries, Handle[] results, any[] queryData)
-{
- data.Reset();
- int client = GetClientOfUserId(data.ReadCell());
- int steamID = data.ReadCell();
- delete data;
-
- if (client == 0 || !IsClientAuthorized(client))
- {
- return;
- }
-
- switch (g_DBType)
- {
- case DatabaseType_SQLite:
- {
- if (SQL_FetchRow(results[2]))
- {
- gB_Cheater[client] = SQL_FetchInt(results[2], 0) == 1;
- }
- }
- case DatabaseType_MySQL:
- {
- if (SQL_FetchRow(results[1]))
- {
- gB_Cheater[client] = SQL_FetchInt(results[1], 0) == 1;
- }
- }
- }
-
- gB_ClientSetUp[client] = true;
- Call_OnClientSetup(client, steamID, gB_Cheater[client]);
-} \ No newline at end of file