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
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
|
/*
gokz-hud Plugin Include
Website: https://bitbucket.org/kztimerglobalteam/gokz
*/
#if defined _gokz_hud_included_
#endinput
#endif
#define _gokz_hud_included_
// =====[ ENUMS ]=====
enum HUDOption:
{
HUDOPTION_INVALID = -1,
HUDOption_TPMenu,
HUDOption_InfoPanel,
HUDOption_ShowKeys,
HUDOption_TimerText,
HUDOption_TimerStyle,
HUDOption_TimerType,
HUDOption_SpeedText,
HUDOption_ShowWeapon,
HUDOption_ShowControls,
HUDOption_DeadstrafeColor,
HUDOption_ShowSpectators,
HUDOption_SpecListPosition,
HUDOption_UpdateRate,
HUDOption_DynamicMenu,
HUDOPTION_COUNT
};
enum
{
TPMenu_Disabled = 0,
TPMenu_Simple,
TPMenu_Advanced,
TPMENU_COUNT
};
enum
{
InfoPanel_Disabled = 0,
InfoPanel_Enabled,
INFOPANEL_COUNT
};
enum
{
ShowKeys_Spectating = 0,
ShowKeys_Always,
ShowKeys_Disabled,
SHOWKEYS_COUNT
};
enum
{
TimerText_Disabled = 0,
TimerText_InfoPanel,
TimerText_TPMenu,
TimerText_Bottom,
TimerText_Top,
TIMERTEXT_COUNT
};
enum
{
TimerStyle_Standard = 0,
TimerStyle_Precise,
TIMERSTYLE_COUNT
};
enum
{
TimerType_Disabled = 0,
TimerType_Enabled,
TIMERTYPE_COUNT
};
enum
{
SpeedText_Disabled = 0,
SpeedText_InfoPanel,
SpeedText_Bottom,
SPEEDTEXT_COUNT
};
enum
{
ShowWeapon_Disabled = 0,
ShowWeapon_Enabled,
SHOWWEAPON_COUNT
};
enum
{
ReplayControls_Disabled = 0,
ReplayControls_Enabled,
REPLAYCONTROLS_COUNT
};
enum
{
DeadstrafeColor_Disabled = 0,
DeadstrafeColor_Enabled,
DEADSTRAFECOLOR_COUNT
};
enum
{
ShowSpecs_Disabled = 0,
ShowSpecs_Number,
ShowSpecs_Full,
SHOWSPECS_COUNT
};
enum
{
SpecListPosition_TPMenu = 0,
SpecListPosition_InfoPanel,
SPECLISTPOSITION_COUNT
}
enum
{
UpdateRate_Slow = 0,
UpdateRate_Fast,
UPDATERATE_COUNT,
};
enum
{
DynamicMenu_Legacy = 0,
DynamicMenu_Disabled,
DynamicMenu_Enabled,
DYNAMICMENU_COUNT
};
// =====[ STRUCTS ]======
enum struct HUDInfo
{
bool TimerRunning;
int TimeType;
float Time;
bool Paused;
bool OnGround;
bool OnLadder;
bool Noclipping;
bool Ducking;
bool HitBhop;
bool IsTakeoff;
float Speed;
int ID;
bool Jumped;
bool HitPerf;
bool HitJB;
float TakeoffSpeed;
int Buttons;
int CurrentTeleport;
}
// =====[ CONSTANTS ]=====
#define HUD_OPTION_CATEGORY "HUD"
#define HUD_MAX_BHOP_GROUND_TICKS 5
#define HUD_MAX_HINT_SIZE 227
stock char gC_HUDOptionNames[HUDOPTION_COUNT][] =
{
"GOKZ HUD - Teleport Menu",
"GOKZ HUD - Centre Panel",
"GOKZ HUD - Show Keys",
"GOKZ HUD - Timer Text",
"GOKZ HUD - Timer Style",
"GOKZ HUD - Show Time Type",
"GOKZ HUD - Speed Text",
"GOKZ HUD - Show Weapon",
"GOKZ HUD - Show Controls",
"GOKZ HUD - Dead Strafe",
"GOKZ HUD - Show Spectators",
"GOKZ HUD - Spec List Pos",
"GOKZ HUD - Update Rate",
"GOKZ HUD - Dynamic Menu"
};
stock char gC_HUDOptionDescriptions[HUDOPTION_COUNT][] =
{
"Teleport Menu - 0 = Disabled, 1 = Simple, 2 = Advanced",
"Centre Information Panel - 0 = Disabled, 1 = Enabled",
"Key Press Display - 0 = Spectating, 1 = Always, 2 = Disabled",
"Timer Display - 0 = Disabled, 1 = Centre Panel, 2 = Teleport Menu, 3 = Bottom, 4 = Top",
"Timer Style - 0 = Standard, 1 = Precise",
"Timer Type - 0 = Disabled, 1 = Enabled",
"Speed Display - 0 = Disabled, 1 = Centre Panel, 2 = Bottom",
"Weapon Viewmodel - 0 = Disabled, 1 = Enabled",
"Replay Controls Display - 0 = Disbled, 1 = Enabled",
"Dead Strafe Indicator - 0 = Disabled, 1 = Enabled",
"Show Spectators - 0 = Disabled, 1 = Number Only, 2 = Number and Names",
"Spectator List Position - 0 = Teleport Menu, 2 = Center Panel",
"HUD Update Rate - 0 = Slow, 1 = Fast",
"Dynamic Menu - 0 = Legacy, 1 = Disabled, 2 = Enabled"
};
stock char gC_HUDOptionPhrases[HUDOPTION_COUNT][] =
{
"Options Menu - Teleport Menu",
"Options Menu - Info Panel",
"Options Menu - Show Keys",
"Options Menu - Timer Text",
"Options Menu - Timer Style",
"Options Menu - Timer Type",
"Options Menu - Speed Text",
"Options Menu - Show Weapon",
"Options Menu - Show Controls",
"Options Menu - Dead Strafe Indicator",
"Options Menu - Show Spectators",
"Options Menu - Spectator List Position",
"Options Menu - Update Rate",
"Options Menu - Dynamic Menu"
};
stock int gI_HUDOptionCounts[HUDOPTION_COUNT] =
{
TPMENU_COUNT,
INFOPANEL_COUNT,
SHOWKEYS_COUNT,
TIMERTEXT_COUNT,
TIMERSTYLE_COUNT,
TIMERTYPE_COUNT,
SPEEDTEXT_COUNT,
SHOWWEAPON_COUNT,
REPLAYCONTROLS_COUNT,
DEADSTRAFECOLOR_COUNT,
SHOWSPECS_COUNT,
SPECLISTPOSITION_COUNT,
UPDATERATE_COUNT,
DYNAMICMENU_COUNT
};
stock int gI_HUDOptionDefaults[HUDOPTION_COUNT] =
{
TPMenu_Advanced,
InfoPanel_Enabled,
ShowKeys_Spectating,
TimerText_InfoPanel,
TimerStyle_Standard,
TimerType_Enabled,
SpeedText_InfoPanel,
ShowWeapon_Enabled,
ReplayControls_Enabled,
DeadstrafeColor_Disabled,
ShowSpecs_Disabled,
SpecListPosition_TPMenu,
UpdateRate_Slow,
DynamicMenu_Legacy
};
stock char gC_TPMenuPhrases[TPMENU_COUNT][] =
{
"Options Menu - Disabled",
"Options Menu - Simple",
"Options Menu - Advanced"
};
stock char gC_ShowKeysPhrases[SHOWKEYS_COUNT][] =
{
"Options Menu - Spectating",
"Options Menu - Always",
"Options Menu - Disabled"
};
stock char gC_TimerTextPhrases[TIMERTEXT_COUNT][] =
{
"Options Menu - Disabled",
"Options Menu - Info Panel",
"Options Menu - Teleport Menu",
"Options Menu - Bottom",
"Options Menu - Top"
};
stock char gC_TimerTypePhrases[TIMERTYPE_COUNT][] =
{
"Options Menu - Disabled",
"Options Menu - Enabled"
};
stock char gC_SpeedTextPhrases[SPEEDTEXT_COUNT][] =
{
"Options Menu - Disabled",
"Options Menu - Info Panel",
"Options Menu - Bottom"
};
stock char gC_ShowControlsPhrases[REPLAYCONTROLS_COUNT][] =
{
"Options Menu - Disabled",
"Options Menu - Enabled"
};
stock char gC_DeadstrafeColorPhrases[DEADSTRAFECOLOR_COUNT][] =
{
"Options Menu - Disabled",
"Options Menu - Enabled"
};
stock char gC_ShowSpecsPhrases[SHOWSPECS_COUNT][] =
{
"Options Menu - Disabled",
"Options Menu - Number",
"Options Menu - Number and Names"
};
stock char gC_SpecListPositionPhrases[SPECLISTPOSITION_COUNT][] =
{
"Options Menu - Teleport Menu",
"Options Menu - Info Panel"
};
stock char gC_HUDUpdateRatePhrases[UPDATERATE_COUNT][]=
{
"Options Menu - Slow",
"Options Menu - Fast"
};
stock char gC_DynamicMenuPhrases[DYNAMICMENU_COUNT][]=
{
"Options Menu - Legacy",
"Options Menu - Disabled",
"Options Menu - Enabled"
};
// =====[ NATIVES ]=====
/**
* Returns whether the GOKZ HUD menu is showing for a client.
*
* @param client Client index.
* @return Whether the GOKZ HUD menu is showing.
*/
native bool GOKZ_HUD_GetMenuShowing(int client);
/**
* Sets whether the GOKZ HUD menu would be showing for a client.
*
* @param client Client index.
* @param value Whether the GOKZ HUD menu would be showing for a client.
*/
native void GOKZ_HUD_SetMenuShowing(int client, bool value);
/**
* Gets the spectator text for the menu. Used by GOKZ-replays.
*
* @param client Client index.
* @param value Whether the GOKZ HUD menu would be showing for a client.
*/
native void GOKZ_HUD_GetMenuSpectatorText(int client, any[] info, char[] buffer, int size);
/**
* Forces the client's TP menu to update.
*
* @param client Client index.
*/
native void GOKZ_HUD_ForceUpdateTPMenu(int client);
// =====[ STOCKS ]=====
/**
* Returns whether an option is a gokz-hud option.
*
* @param option Option name.
* @param optionEnum Variable to store enumerated gokz-hud option (if it is one).
* @return Whether option is a gokz-hud option.
*/
stock bool GOKZ_HUD_IsHUDOption(const char[] option, HUDOption &optionEnum = HUDOPTION_INVALID)
{
for (HUDOption i; i < HUDOPTION_COUNT; i++)
{
if (StrEqual(option, gC_HUDOptionNames[i]))
{
optionEnum = i;
return true;
}
}
return false;
}
/**
* Gets the current value of a player's gokz-hud option.
*
* @param client Client index.
* @param option gokz-hud option.
* @return Current value of option.
*/
stock any GOKZ_HUD_GetOption(int client, HUDOption option)
{
return GOKZ_GetOption(client, gC_HUDOptionNames[option]);
}
/**
* Sets a player's gokz-hud option's value.
*
* @param client Client index.
* @param option gokz-hud option.
* @param value New option value.
* @return Whether option was successfully set.
*/
stock bool GOKZ_HUD_SetOption(int client, HUDOption option, any value)
{
return GOKZ_SetOption(client, gC_HUDOptionNames[option], value);
}
/**
* Increment an integer-type gokz-hud option's value.
* Loops back to '0' if max value is exceeded.
*
* @param client Client index.
* @param option gokz-hud option.
* @return Whether option was successfully set.
*/
stock bool GOKZ_HUD_CycleOption(int client, HUDOption option)
{
return GOKZ_CycleOption(client, gC_HUDOptionNames[option]);
}
/**
* Represents a time float as a string e.g. 01:23.45
* and according to the client's HUD options.
*
* @param client Client index.
* @param time Time in seconds.
* @return String representation of time.
*/
stock char[] GOKZ_HUD_FormatTime(int client, float time)
{
bool precise = GOKZ_HUD_GetOption(client, HUDOption_TimerStyle) == TimerStyle_Precise;
return GOKZ_FormatTime(time, precise);
}
// =====[ DEPENDENCY ]=====
public SharedPlugin __pl_gokz_hud =
{
name = "gokz-hud",
file = "gokz-hud.smx",
#if defined REQUIRE_PLUGIN
required = 1,
#else
required = 0,
#endif
};
#if !defined REQUIRE_PLUGIN
public void __pl_gokz_hud_SetNTVOptional()
{
MarkNativeAsOptional("GOKZ_HUD_GetMenuShowing");
MarkNativeAsOptional("GOKZ_HUD_SetMenuShowing");
MarkNativeAsOptional("GOKZ_HUD_GetMenuSpectatorText");
MarkNativeAsOptional("GOKZ_HUD_ForceUpdateTPMenu");
}
#endif
|