summaryrefslogtreecommitdiff
path: root/sourcemod/scripting/gokz-localranks/db/print_js.sp
diff options
context:
space:
mode:
Diffstat (limited to 'sourcemod/scripting/gokz-localranks/db/print_js.sp')
-rw-r--r--sourcemod/scripting/gokz-localranks/db/print_js.sp108
1 files changed, 108 insertions, 0 deletions
diff --git a/sourcemod/scripting/gokz-localranks/db/print_js.sp b/sourcemod/scripting/gokz-localranks/db/print_js.sp
new file mode 100644
index 0000000..e694a95
--- /dev/null
+++ b/sourcemod/scripting/gokz-localranks/db/print_js.sp
@@ -0,0 +1,108 @@
+/*
+ Prints the player's personal best jumps.
+*/
+
+
+
+void DisplayJumpstatRecord(int client, int jumpType, char[] jumper = "")
+{
+ int mode = GOKZ_GetCoreOption(client, Option_Mode);
+
+ int steamid;
+ char alias[33];
+ if (StrEqual(jumper, ""))
+ {
+ steamid = GetSteamAccountID(client);
+ FormatEx(alias, sizeof(alias), "%N", client);
+
+ DB_JS_OpenPlayerRecord(client, steamid, alias, jumpType, mode, 0);
+ DB_JS_OpenPlayerRecord(client, steamid, alias, jumpType, mode, 1);
+ }
+ else
+ {
+ DataPack data = new DataPack();
+ data.WriteCell(client);
+ data.WriteCell(jumpType);
+ data.WriteCell(mode);
+ data.WriteString(jumper);
+
+ DB_FindPlayer(jumper, DB_JS_TxnSuccess_LookupPlayer, data);
+ }
+}
+
+public void DB_JS_TxnSuccess_LookupPlayer(Handle db, DataPack data, int numQueries, Handle[] results, any[] queryData)
+{
+ char jumper[MAX_NAME_LENGTH];
+
+ data.Reset();
+ int client = data.ReadCell();
+ int jumpType = data.ReadCell();
+ int mode = data.ReadCell();
+ data.ReadString(jumper, sizeof(jumper));
+ delete data;
+
+ if (SQL_GetRowCount(results[0]) == 0)
+ {
+ GOKZ_PrintToChat(client, true, "%t", "Player Not Found", jumper);
+ return;
+ }
+
+ char alias[33];
+ SQL_FetchRow(results[0]);
+ int steamid = SQL_FetchInt(results[0], JumpstatDB_FindPlayer_SteamID32);
+ SQL_FetchString(results[0], JumpstatDB_FindPlayer_Alias, alias, sizeof(alias));
+
+ DB_JS_OpenPlayerRecord(client, steamid, alias, jumpType, mode, 0);
+ DB_JS_OpenPlayerRecord(client, steamid, alias, jumpType, mode, 1);
+}
+
+void DB_JS_OpenPlayerRecord(int client, int steamid, char[] alias, int jumpType, int mode, int block)
+{
+ char query[1024];
+
+ DataPack data = new DataPack();
+ data.WriteCell(client);
+ data.WriteString(alias);
+ data.WriteCell(jumpType);
+ data.WriteCell(mode);
+
+ Transaction txn = SQL_CreateTransaction();
+ FormatEx(query, sizeof(query), sql_jumpstats_getrecord, steamid, jumpType, mode, block);
+ txn.AddQuery(query);
+ SQL_ExecuteTransaction(gH_DB, txn, DB_JS_TxnSuccess_OpenPlayerRecord, DB_TxnFailure_Generic_DataPack, data, DBPrio_Low);
+}
+
+public void DB_JS_TxnSuccess_OpenPlayerRecord(Handle db, DataPack data, int numQueries, Handle[] results, any[] queryData)
+{
+ char alias[33];
+ data.Reset();
+ int client = data.ReadCell();
+ data.ReadString(alias, sizeof(alias));
+ int jumpType = data.ReadCell();
+ int mode = data.ReadCell();
+ delete data;
+
+ if (!IsValidClient(client))
+ {
+ return;
+ }
+
+ if (SQL_GetRowCount(results[0]) == 0)
+ {
+ GOKZ_PrintToChat(client, true, "%t", "No Jumpstats Found");
+ return;
+ }
+
+ SQL_FetchRow(results[0]);
+ float distance = float(SQL_FetchInt(results[0], JumpstatDB_Lookup_Distance)) / 10000;
+ int block = SQL_FetchInt(results[0], JumpstatDB_Lookup_Block);
+
+ if (block == 0)
+ {
+ GOKZ_PrintToChat(client, true, "%t", "Jump Record", gC_ModeNamesShort[mode], gC_JumpTypes[jumpType], alias, distance);
+ }
+ else
+ {
+ GOKZ_PrintToChat(client, true, "%t", "Block Jump Record", gC_ModeNamesShort[mode], gC_JumpTypes[jumpType], alias, block, distance);
+ }
+}