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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
|
#include <sourcemod>
#include <cstrike>
#include <sdktools>
#include <gokz/core>
#include <gokz/localdb>
#include <gokz/localranks>
#include <sourcemod-colors>
#undef REQUIRE_EXTENSIONS
#undef REQUIRE_PLUGIN
#include <gokz/global>
#include <gokz/jumpstats>
#include <gokz/replays>
#include <updater>
#pragma newdecls required
#pragma semicolon 1
public Plugin myinfo =
{
name = "GOKZ Local Ranks",
author = "DanZay",
description = "Extends and provides in-game functionality for local database",
version = GOKZ_VERSION,
url = GOKZ_SOURCE_URL
};
#define UPDATER_URL GOKZ_UPDATER_BASE_URL..."gokz-localranks.txt"
bool gB_GOKZGlobal;
Database gH_DB = null;
DatabaseType g_DBType = DatabaseType_None;
bool gB_RecordExistsCache[GOKZ_MAX_COURSES][MODE_COUNT][TIMETYPE_COUNT];
float gF_RecordTimesCache[GOKZ_MAX_COURSES][MODE_COUNT][TIMETYPE_COUNT];
bool gB_RecordMissed[MAXPLAYERS + 1][TIMETYPE_COUNT];
bool gB_PBExistsCache[MAXPLAYERS + 1][GOKZ_MAX_COURSES][MODE_COUNT][TIMETYPE_COUNT];
float gF_PBTimesCache[MAXPLAYERS + 1][GOKZ_MAX_COURSES][MODE_COUNT][TIMETYPE_COUNT];
bool gB_PBMissed[MAXPLAYERS + 1][TIMETYPE_COUNT];
char gC_BeatRecordSound[256];
#include "gokz-localranks/api.sp"
#include "gokz-localranks/commands.sp"
#include "gokz-localranks/misc.sp"
#include "gokz-localranks/db/sql.sp"
#include "gokz-localranks/db/helpers.sp"
#include "gokz-localranks/db/cache_pbs.sp"
#include "gokz-localranks/db/cache_records.sp"
#include "gokz-localranks/db/create_tables.sp"
#include "gokz-localranks/db/get_completion.sp"
#include "gokz-localranks/db/js_top.sp"
#include "gokz-localranks/db/map_top.sp"
#include "gokz-localranks/db/player_top.sp"
#include "gokz-localranks/db/print_average.sp"
#include "gokz-localranks/db/print_js.sp"
#include "gokz-localranks/db/print_pbs.sp"
#include "gokz-localranks/db/print_records.sp"
#include "gokz-localranks/db/process_new_time.sp"
#include "gokz-localranks/db/recent_records.sp"
#include "gokz-localranks/db/update_ranked_map_pool.sp"
#include "gokz-localranks/db/display_js.sp"
// =====[ PLUGIN EVENTS ]=====
public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
{
CreateNatives();
RegPluginLibrary("gokz-localranks");
return APLRes_Success;
}
public void OnPluginStart()
{
LoadTranslations("gokz-common.phrases");
LoadTranslations("gokz-localranks.phrases");
CreateGlobalForwards();
RegisterCommands();
}
public void OnAllPluginsLoaded()
{
if (LibraryExists("updater"))
{
Updater_AddPlugin(UPDATER_URL);
}
gB_GOKZGlobal = LibraryExists("gokz-global");
gH_DB = GOKZ_DB_GetDatabase();
if (gH_DB != null)
{
g_DBType = GOKZ_DB_GetDatabaseType();
DB_CreateTables();
CompletionMVPStarsUpdateAll();
}
if (GOKZ_DB_IsMapSetUp())
{
GOKZ_DB_OnMapSetup(GOKZ_DB_GetCurrentMapID());
}
for (int i = 1; i <= MaxClients; i++)
{
if (GOKZ_DB_IsClientSetUp(i))
{
GOKZ_DB_OnClientSetup(i, GetSteamAccountID(i), GOKZ_DB_IsCheater(i));
}
}
}
public void OnLibraryAdded(const char[] name)
{
if (StrEqual(name, "updater"))
{
Updater_AddPlugin(UPDATER_URL);
}
gB_GOKZGlobal = gB_GOKZGlobal || StrEqual(name, "gokz-global");
}
public void OnLibraryRemoved(const char[] name)
{
gB_GOKZGlobal = gB_GOKZGlobal && !StrEqual(name, "gokz-global");
}
// =====[ CLIENT EVENTS ]=====
public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3], float angles[3], int &weapon, int &subtype, int &cmdnum, int &tickcount, int &seed, int mouse[2])
{
UpdateRecordMissed(client);
UpdatePBMissed(client);
return Plugin_Continue;
}
public void GOKZ_OnTimerStart_Post(int client, int course)
{
ResetRecordMissed(client);
ResetPBMissed(client);
}
public void GOKZ_DB_OnClientSetup(int client, int steamID, bool cheater)
{
if (GOKZ_DB_IsMapSetUp())
{
DB_CachePBs(client, steamID);
CompletionMVPStarsUpdate(client);
}
}
public void GOKZ_DB_OnTimeInserted(int client, int steamID, int mapID, int course, int mode, int style, int runTimeMS, int teleportsUsed)
{
if (GOKZ_DB_IsCheater(client))
{
DB_CachePBs(client, GetSteamAccountID(client));
}
else
{
DB_ProcessNewTime(client, steamID, mapID, course, mode, style, runTimeMS, teleportsUsed);
}
}
public void GOKZ_LR_OnTimeProcessed(
int client,
int steamID,
int mapID,
int course,
int mode,
int style,
float runTime,
int teleportsUsed,
bool firstTime,
float pbDiff,
int rank,
int maxRank,
bool firstTimePro,
float pbDiffPro,
int rankPro,
int maxRankPro)
{
if (mapID != GOKZ_DB_GetCurrentMapID())
{
return;
}
AnnounceNewTime(client, course, mode, runTime, teleportsUsed, firstTime, pbDiff, rank, maxRank, firstTimePro, pbDiffPro, rankPro, maxRankPro);
if (mode == GOKZ_GetDefaultMode() && firstTimePro)
{
CompletionMVPStarsUpdate(client);
}
// If new PB, update PB cache
if (firstTime || firstTimePro || pbDiff < 0.0 || pbDiffPro < 0.0)
{
DB_CachePBs(client, GetSteamAccountID(client));
}
}
public void GOKZ_LR_OnNewRecord(int client, int steamID, int mapID, int course, int mode, int style, int recordType)
{
if (mapID != GOKZ_DB_GetCurrentMapID())
{
return;
}
AnnounceNewRecord(client, course, mode, recordType);
DB_CacheRecords(mapID);
}
public void GOKZ_LR_OnPBMissed(int client, float pbTime, int course, int mode, int style, int recordType)
{
DoPBMissedReport(client, pbTime, recordType);
}
// =====[ OTHER EVENTS ]=====
public void OnMapStart()
{
PrecacheAnnouncementSounds();
}
public void GOKZ_DB_OnDatabaseConnect(DatabaseType DBType)
{
gH_DB = GOKZ_DB_GetDatabase();
g_DBType = DBType;
DB_CreateTables();
CompletionMVPStarsUpdateAll();
}
public void GOKZ_DB_OnMapSetup(int mapID)
{
DB_CacheRecords(mapID);
for (int client = 1; client <= MaxClients; client++)
{
if (GOKZ_DB_IsClientSetUp(client))
{
DB_CachePBs(client, GetSteamAccountID(client));
}
}
}
public Action GOKZ_OnTimerEndMessage(int client, int course, float time, int teleportsUsed)
{
if (GOKZ_DB_IsCheater(client))
{
return Plugin_Continue;
}
// Block timer end messages from GOKZ Core - this plugin handles them
return Plugin_Stop;
}
|