1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
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);
}
}
|