summaryrefslogtreecommitdiff
path: root/sourcemod/scripting/gokz-localdb/db/cache_js.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/cache_js.sp
parent38f1140c11724da05a23a10385061200b907cf6e (diff)
bbbbbbbbwaaaaaaaaaaa
Diffstat (limited to 'sourcemod/scripting/gokz-localdb/db/cache_js.sp')
-rw-r--r--sourcemod/scripting/gokz-localdb/db/cache_js.sp67
1 files changed, 67 insertions, 0 deletions
diff --git a/sourcemod/scripting/gokz-localdb/db/cache_js.sp b/sourcemod/scripting/gokz-localdb/db/cache_js.sp
new file mode 100644
index 0000000..b0df708
--- /dev/null
+++ b/sourcemod/scripting/gokz-localdb/db/cache_js.sp
@@ -0,0 +1,67 @@
+/*
+ Caches the player's personal best jumpstats.
+*/
+
+
+
+void DB_CacheJSPBs(int client, int steamID)
+{
+ ClearCache(client);
+
+ char query[1024];
+
+ Transaction txn = SQL_CreateTransaction();
+
+ FormatEx(query, sizeof(query), sql_jumpstats_getpbs, steamID);
+ txn.AddQuery(query);
+
+ FormatEx(query, sizeof(query), sql_jumpstats_getblockpbs, steamID, steamID);
+ txn.AddQuery(query);
+
+ SQL_ExecuteTransaction(gH_DB, txn, DB_TxnSuccess_CacheJSPBs, DB_TxnFailure_Generic, GetClientUserId(client), DBPrio_High);
+}
+
+public void DB_TxnSuccess_CacheJSPBs(Handle db, int userID, int numQueries, Handle[] results, any[] queryData)
+{
+ int client = GetClientOfUserId(userID);
+ if (client < 1 || client > MaxClients || !IsClientAuthorized(client) || IsFakeClient(client))
+ {
+ return;
+ }
+
+ int distance, mode, jumpType, block;
+
+ while (SQL_FetchRow(results[0]))
+ {
+ distance = SQL_FetchInt(results[0], 0);
+ mode = SQL_FetchInt(results[0], 1);
+ jumpType = SQL_FetchInt(results[0], 2);
+
+ gI_PBJSCache[client][mode][jumpType][JumpstatDB_Cache_Distance] = block;
+ }
+
+ while (SQL_FetchRow(results[1]))
+ {
+ distance = SQL_FetchInt(results[1], 0);
+ mode = SQL_FetchInt(results[1], 1);
+ jumpType = SQL_FetchInt(results[1], 2);
+ block = SQL_FetchInt(results[1], 3);
+
+ gI_PBJSCache[client][mode][jumpType][JumpstatDB_Cache_BlockDistance] = distance;
+ gI_PBJSCache[client][mode][jumpType][JumpstatDB_Cache_Block] = block;
+ }
+}
+
+void ClearCache(int client)
+{
+ for (int mode = 0; mode < MODE_COUNT; mode += 1)
+ {
+ for (int type = 0; type < JUMPTYPE_COUNT; type += 1)
+ {
+ for (int cache = 0; cache < JUMPSTATDB_CACHE_COUNT; cache += 1)
+ {
+ gI_PBJSCache[client][mode][type][cache] = 0;
+ }
+ }
+ }
+} \ No newline at end of file