summaryrefslogtreecommitdiff
path: root/sourcemod/scripting/gokz-localdb/db/set_cheater.sp
diff options
context:
space:
mode:
authornavewindre <nw@moneybot.cc>2023-12-04 18:06:10 +0100
committernavewindre <nw@moneybot.cc>2023-12-04 18:06:10 +0100
commitaef0d1c1268ab7d4bc18996c9c6b4da16a40aadc (patch)
tree43e766b51704f4ab8b383583bdc1871eeeb9c698 /sourcemod/scripting/gokz-localdb/db/set_cheater.sp
parent38f1140c11724da05a23a10385061200b907cf6e (diff)
bbbbbbbbwaaaaaaaaaaa
Diffstat (limited to 'sourcemod/scripting/gokz-localdb/db/set_cheater.sp')
-rw-r--r--sourcemod/scripting/gokz-localdb/db/set_cheater.sp64
1 files changed, 64 insertions, 0 deletions
diff --git a/sourcemod/scripting/gokz-localdb/db/set_cheater.sp b/sourcemod/scripting/gokz-localdb/db/set_cheater.sp
new file mode 100644
index 0000000..c63f161
--- /dev/null
+++ b/sourcemod/scripting/gokz-localdb/db/set_cheater.sp
@@ -0,0 +1,64 @@
+/*
+ Sets whether player is a cheater in the database.
+*/
+
+
+
+void DB_SetCheater(int cheaterClient, bool cheater)
+{
+ if (gB_Cheater[cheaterClient] == cheater)
+ {
+ return;
+ }
+
+ gB_Cheater[cheaterClient] = cheater;
+
+ DataPack data = new DataPack();
+ data.WriteCell(-1);
+ data.WriteCell(GetSteamAccountID(cheaterClient));
+ data.WriteCell(cheater);
+
+ char query[128];
+
+ Transaction txn = SQL_CreateTransaction();
+
+ FormatEx(query, sizeof(query), sql_players_set_cheater, cheater ? 1 : 0, GetSteamAccountID(cheaterClient));
+ txn.AddQuery(query);
+
+ SQL_ExecuteTransaction(gH_DB, txn, DB_TxnSuccess_SetCheater, DB_TxnFailure_Generic_DataPack, data, DBPrio_High);
+}
+
+void DB_SetCheaterSteamID(int client, int cheaterSteamID, bool cheater)
+{
+ DataPack data = new DataPack();
+ data.WriteCell(client == 0 ? -1 : GetClientUserId(client)); // -1 if called from server console
+ data.WriteCell(cheaterSteamID);
+ data.WriteCell(cheater);
+
+ char query[128];
+
+ Transaction txn = SQL_CreateTransaction();
+
+ FormatEx(query, sizeof(query), sql_players_set_cheater, cheater ? 1 : 0, cheaterSteamID);
+ txn.AddQuery(query);
+
+ SQL_ExecuteTransaction(gH_DB, txn, DB_TxnSuccess_SetCheater, DB_TxnFailure_Generic_DataPack, data, DBPrio_High);
+}
+
+public void DB_TxnSuccess_SetCheater(Handle db, DataPack data, int numQueries, Handle[] results, any[] queryData)
+{
+ data.Reset();
+ int client = GetClientOfUserId(data.ReadCell());
+ int steamID = data.ReadCell();
+ bool cheater = view_as<bool>(data.ReadCell());
+ delete data;
+
+ if (cheater)
+ {
+ GOKZ_PrintToChatAndLog(client, true, "%t", "Set Cheater", steamID & 1, steamID >> 1);
+ }
+ else
+ {
+ GOKZ_PrintToChatAndLog(client, true, "%t", "Set Not Cheater", steamID & 1, steamID >> 1);
+ }
+} \ No newline at end of file