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
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
|
/*
Miscellaneous functions.
*/
// =====[ COMPLETION MVP STARS ]=====
void CompletionMVPStarsUpdate(int client)
{
DB_GetCompletion(client, GetSteamAccountID(client), GOKZ_GetDefaultMode(), false);
}
void CompletionMVPStarsUpdateAll()
{
for (int client = 1; client <= MaxClients; client++)
{
if (IsClientInGame(client) && !IsFakeClient(client))
{
CompletionMVPStarsUpdate(client);
}
}
}
// =====[ ANNOUNCEMENTS ]=====
void PrecacheAnnouncementSounds()
{
if (!LoadSounds())
{
SetFailState("Failed to load file: \"%s\".", LR_CFG_SOUNDS);
}
}
static bool LoadSounds()
{
KeyValues kv = new KeyValues("sounds");
if (!kv.ImportFromFile(LR_CFG_SOUNDS))
{
return false;
}
char downloadPath[256];
kv.GetString("beatrecord", gC_BeatRecordSound, sizeof(gC_BeatRecordSound));
FormatEx(downloadPath, sizeof(downloadPath), "sound/%s", gC_BeatRecordSound);
AddFileToDownloadsTable(downloadPath);
PrecacheSound(gC_BeatRecordSound, true);
delete kv;
return true;
}
static void PlayBeatRecordSound()
{
GOKZ_EmitSoundToAll(gC_BeatRecordSound, _, "Server Record");
}
void AnnounceNewTime(
int client,
int course,
int mode,
float runTime,
int teleportsUsed,
bool firstTime,
float pbDiff,
int rank,
int maxRank,
bool firstTimePro,
float pbDiffPro,
int rankPro,
int maxRankPro)
{
// Main Course
if (course == 0)
{
// Main Course PRO Times
if (teleportsUsed == 0)
{
if (firstTimePro)
{
GOKZ_PrintToChatAll(true, "%t", "New Time - First Time (PRO)",
client, GOKZ_FormatTime(runTime), rankPro, maxRankPro, gC_ModeNamesShort[mode]);
}
else if (pbDiffPro < 0)
{
GOKZ_PrintToChatAll(true, "%t", "New Time - Beat PB (PRO)",
client, GOKZ_FormatTime(runTime), GOKZ_FormatTime(FloatAbs(pbDiffPro)), rankPro, maxRankPro, gC_ModeNamesShort[mode]);
}
else
{
GOKZ_PrintToChatAll(true, "%t", "New Time - Miss PB (PRO)",
client, GOKZ_FormatTime(runTime), GOKZ_FormatTime(pbDiffPro), rankPro, maxRankPro, gC_ModeNamesShort[mode]);
}
}
// Main Course NUB Times
else
{
if (firstTime)
{
GOKZ_PrintToChatAll(true, "%t", "New Time - First Time",
client, GOKZ_FormatTime(runTime), rank, maxRank, gC_ModeNamesShort[mode]);
}
else if (pbDiff < 0)
{
GOKZ_PrintToChatAll(true, "%t", "New Time - Beat PB",
client, GOKZ_FormatTime(runTime), GOKZ_FormatTime(FloatAbs(pbDiff)), rank, maxRank, gC_ModeNamesShort[mode]);
}
else
{
GOKZ_PrintToChatAll(true, "%t", "New Time - Miss PB",
client, GOKZ_FormatTime(runTime), GOKZ_FormatTime(pbDiff), rank, maxRank, gC_ModeNamesShort[mode]);
}
}
}
// Bonus Course
else
{
// Bonus Course PRO Times
if (teleportsUsed == 0)
{
if (firstTimePro)
{
GOKZ_PrintToChatAll(true, "%t", "New Bonus Time - First Time (PRO)",
client, course, GOKZ_FormatTime(runTime), rankPro, maxRankPro, gC_ModeNamesShort[mode]);
}
else if (pbDiffPro < 0)
{
GOKZ_PrintToChatAll(true, "%t", "New Bonus Time - Beat PB (PRO)",
client, course, GOKZ_FormatTime(runTime), GOKZ_FormatTime(FloatAbs(pbDiffPro)), rankPro, maxRankPro, gC_ModeNamesShort[mode]);
}
else
{
GOKZ_PrintToChatAll(true, "%t", "New Bonus Time - Miss PB (PRO)",
client, course, GOKZ_FormatTime(runTime), GOKZ_FormatTime(pbDiffPro), rankPro, maxRankPro, gC_ModeNamesShort[mode]);
}
}
// Bonus Course NUB Times
else
{
if (firstTime)
{
GOKZ_PrintToChatAll(true, "%t", "New Bonus Time - First Time",
client, course, GOKZ_FormatTime(runTime), rank, maxRank, gC_ModeNamesShort[mode]);
}
else if (pbDiff < 0)
{
GOKZ_PrintToChatAll(true, "%t", "New Bonus Time - Beat PB",
client, course, GOKZ_FormatTime(runTime), GOKZ_FormatTime(FloatAbs(pbDiff)), rank, maxRank, gC_ModeNamesShort[mode]);
}
else
{
GOKZ_PrintToChatAll(true, "%t", "New Bonus Time - Miss PB",
client, course, GOKZ_FormatTime(runTime), GOKZ_FormatTime(pbDiff), rank, maxRank, gC_ModeNamesShort[mode]);
}
}
}
}
void AnnounceNewRecord(int client, int course, int mode, int recordType)
{
if (course == 0)
{
switch (recordType)
{
case RecordType_Nub:
{
GOKZ_PrintToChatAll(true, "%t", "New Record (NUB)", client, gC_ModeNamesShort[mode]);
}
case RecordType_Pro:
{
GOKZ_PrintToChatAll(true, "%t", "New Record (PRO)", client, gC_ModeNamesShort[mode]);
}
case RecordType_NubAndPro:
{
GOKZ_PrintToChatAll(true, "%t", "New Record (NUB and PRO)", client, gC_ModeNamesShort[mode]);
}
}
}
else
{
switch (recordType)
{
case RecordType_Nub:
{
GOKZ_PrintToChatAll(true, "%t", "New Bonus Record (NUB)", client, course, gC_ModeNamesShort[mode]);
}
case RecordType_Pro:
{
GOKZ_PrintToChatAll(true, "%t", "New Bonus Record (PRO)", client, course, gC_ModeNamesShort[mode]);
}
case RecordType_NubAndPro:
{
GOKZ_PrintToChatAll(true, "%t", "New Bonus Record (NUB and PRO)", client, course, course, gC_ModeNamesShort[mode]);
}
}
}
PlayBeatRecordSound(); // Play sound!
}
// =====[ MISSED RECORD TRACKING ]=====
void ResetRecordMissed(int client)
{
for (int timeType = 0; timeType < TIMETYPE_COUNT; timeType++)
{
gB_RecordMissed[client][timeType] = false;
}
}
void UpdateRecordMissed(int client)
{
if (!GOKZ_GetTimerRunning(client) || gB_RecordMissed[client][TimeType_Nub] && gB_RecordMissed[client][TimeType_Pro])
{
return;
}
int course = GOKZ_GetCourse(client);
int mode = GOKZ_GetCoreOption(client, Option_Mode);
float currentTime = GOKZ_GetTime(client);
bool nubRecordExists = gB_RecordExistsCache[course][mode][TimeType_Nub];
float nubRecordTime = gF_RecordTimesCache[course][mode][TimeType_Nub];
bool nubRecordMissed = gB_RecordMissed[client][TimeType_Nub];
bool proRecordExists = gB_RecordExistsCache[course][mode][TimeType_Pro];
float proRecordTime = gF_RecordTimesCache[course][mode][TimeType_Pro];
bool proRecordMissed = gB_RecordMissed[client][TimeType_Pro];
if (nubRecordExists && !nubRecordMissed && currentTime >= nubRecordTime)
{
gB_RecordMissed[client][TimeType_Nub] = true;
// Check if nub record is also the pro record, and call the forward appropriately
if (proRecordExists && FloatAbs(nubRecordTime - proRecordTime) < EPSILON)
{
gB_RecordMissed[client][TimeType_Pro] = true;
Call_OnRecordMissed(client, nubRecordTime, course, mode, Style_Normal, RecordType_NubAndPro);
}
else
{
Call_OnRecordMissed(client, nubRecordTime, course, mode, Style_Normal, RecordType_Nub);
}
}
else if (proRecordExists && !proRecordMissed && currentTime >= proRecordTime)
{
gB_RecordMissed[client][TimeType_Pro] = true;
Call_OnRecordMissed(client, proRecordTime, course, mode, Style_Normal, RecordType_Pro);
}
}
// =====[ MISSED PB TRACKING ]=====
#define MISSED_PB_SOUND "buttons/button18.wav"
void ResetPBMissed(int client)
{
for (int timeType = 0; timeType < TIMETYPE_COUNT; timeType++)
{
gB_PBMissed[client][timeType] = false;
}
}
void UpdatePBMissed(int client)
{
if (!GOKZ_GetTimerRunning(client) || gB_PBMissed[client][TimeType_Nub] && gB_PBMissed[client][TimeType_Pro])
{
return;
}
int course = GOKZ_GetCourse(client);
int mode = GOKZ_GetCoreOption(client, Option_Mode);
float currentTime = GOKZ_GetTime(client);
bool nubPBExists = gB_PBExistsCache[client][course][mode][TimeType_Nub];
float nubPBTime = gF_PBTimesCache[client][course][mode][TimeType_Nub];
bool nubPBMissed = gB_PBMissed[client][TimeType_Nub];
bool proPBExists = gB_PBExistsCache[client][course][mode][TimeType_Pro];
float proPBTime = gF_PBTimesCache[client][course][mode][TimeType_Pro];
bool proPBMissed = gB_PBMissed[client][TimeType_Pro];
if (nubPBExists && !nubPBMissed && currentTime >= nubPBTime)
{
gB_PBMissed[client][TimeType_Nub] = true;
// Check if nub PB is also the pro PB, and call the forward appropriately
if (proPBExists && FloatAbs(nubPBTime - proPBTime) < EPSILON)
{
gB_PBMissed[client][TimeType_Pro] = true;
Call_OnPBMissed(client, nubPBTime, course, mode, Style_Normal, RecordType_NubAndPro);
}
else
{
Call_OnPBMissed(client, nubPBTime, course, mode, Style_Normal, RecordType_Nub);
}
}
else if (proPBExists && !proPBMissed && currentTime >= proPBTime)
{
gB_PBMissed[client][TimeType_Pro] = true;
Call_OnPBMissed(client, proPBTime, course, mode, Style_Normal, RecordType_Pro);
}
}
void DoPBMissedReport(int client, float pbTime, int recordType)
{
switch (recordType)
{
case RecordType_Nub:GOKZ_PrintToChat(client, true, "%t", "Missed PB (NUB)", GOKZ_FormatTime(pbTime));
case RecordType_Pro:GOKZ_PrintToChat(client, true, "%t", "Missed PB (PRO)", GOKZ_FormatTime(pbTime));
case RecordType_NubAndPro:GOKZ_PrintToChat(client, true, "%t", "Missed PB (NUB and PRO)", GOKZ_FormatTime(pbTime));
}
GOKZ_EmitSoundToClient(client, MISSED_PB_SOUND, _, "Missed PB");
}
|