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
|
/*
gokz-global Plugin Include
Website: https://bitbucket.org/kztimerglobalteam/gokz
*/
#if defined _gokz_global_included_
#endinput
#endif
#define _gokz_global_included_
#include <GlobalAPI>
// =====[ ENUMS ]=====
enum
{
EnforcedCVar_Cheats = 0,
EnforcedCVar_ClampUnsafeVelocities,
EnforcedCVar_DropKnifeEnable,
EnforcedCVar_AutoBunnyhopping,
EnforcedCVar_MinUpdateRate,
EnforcedCVar_MaxUpdateRate,
EnforcedCVar_MinCmdRate,
EnforcedCVar_MaxCmdRate,
EnforcedCVar_ClientCmdrateDifference,
EnforcedCVar_Turbophysics,
ENFORCEDCVAR_COUNT
};
enum
{
BannedPluginCommand_Funcommands = 0,
BannedPluginCommand_Playercommands,
BANNEDPLUGINCOMMAND_COUNT
};
enum
{
BannedPlugin_Funcommands = 0,
BannedPlugin_Playercommands,
BANNEDPLUGIN_COUNT
};
enum GlobalMode
{
GlobalMode_Invalid = -1,
GlobalMode_KZTimer = 200,
GlobalMode_KZSimple,
GlobalMode_Vanilla
}
// =====[ CONSTANTS ]=====
#define GL_SOUND_NEW_RECORD "gokz/holyshit.mp3"
#define GL_FPS_MAX_CHECK_INTERVAL 1.0
#define GL_FPS_MAX_KICK_TIMEOUT 10.0
#define GL_FPS_MAX_MIN_VALUE 120
#define GL_MYAW_MAX_VALUE 0.3
stock char gC_EnforcedCVars[ENFORCEDCVAR_COUNT][] =
{
"sv_cheats",
"sv_clamp_unsafe_velocities",
"mp_drop_knife_enable",
"sv_autobunnyhopping",
"sv_minupdaterate",
"sv_maxupdaterate",
"sv_mincmdrate",
"sv_maxcmdrate",
"sv_client_cmdrate_difference",
"sv_turbophysics"
};
stock char gC_BannedPluginCommands[BANNEDPLUGINCOMMAND_COUNT][] =
{
"sm_beacon",
"sm_slap"
};
stock char gC_BannedPlugins[BANNEDPLUGIN_COUNT][] =
{
"Fun Commands",
"Player Commands"
};
stock float gF_EnforcedCVarValues[ENFORCEDCVAR_COUNT] =
{
0.0,
0.0,
0.0,
0.0,
128.0,
128.0,
128.0,
128.0,
0.0,
0.0
};
// =====[ FORWARDS ]=====
/**
* Called when a player sets a new global top time.
*
* @param client Client index.
* @param course Course number e.g. 0=main, 1='bonus1' etc.
* @param mode Player's movement mode.
* @param timeType Time type i.e. NUB or PRO.
* @param rank Ranking within the same time type.
* @param rankOverall Overall (NUB and PRO) ranking (0 if not ranked high enough).
* @param runTime Player's end time.
*/
forward void GOKZ_GL_OnNewTopTime(int client, int course, int mode, int timeType, int rank, int rankOverall, float runTime);
// =====[ NATIVES ]=====
/**
* Prints to chat the global records for a map, course and mode.
*
* @param client Client index.
* @param map Map name or "" for current map.
* @param course Course number e.g. 0=main, 1='bonus1' etc.
* @param mode GOKZ mode.
*/
native void GOKZ_GL_PrintRecords(int client, const char[] map = "", int course, int mode, const char[] steamid = DEFAULT_STRING);
/**
* Opens up the global map top menu for a map, course and mode.
*
* @param client Client index.
* @param map Map name or "" for current map.
* @param course Course number e.g. 0=main, 1='bonus1' etc.
* @param mode GOKZ mode.
* @param timeType Type of time i.e. NUB or PRO.
*/
native void GOKZ_GL_DisplayMapTopMenu(int client, const char[] map = "", int course, int mode, int timeType);
/**
* Get the total global points of a player.
*
* @param client Client index.
* @param mode GOKZ mode.
* @param timeType Type of time i.e. NUB or PRO.
*/
native void GOKZ_GL_GetPoints(int client, int mode, int timeType);
/**
* Get the global points on the main coruse of the current map.
*
* @param client Client index.
* @param mode GOKZ mode.
* @param timeType Type of time i.e. NUB or PRO.
*/
native void GOKZ_GL_GetMapPoints(int client, int mode, int timeType);
/**
* Get the total global ranking points of a player.
*
* @param client Client index.
* @param mode GOKZ mode.
* @return The points.
*/
native int GOKZ_GL_GetRankPoints(int client, int mode);
/**
* Get the amount of maps a player finished.
*
* @param client Client index.
* @param mode GOKZ mode.
* @param timeType Type of time i.e. NUB or PRO.
*/
native void GOKZ_GL_GetFinishes(int client, int mode, int timeType);
/**
* Fetch the points a player got from the Global API.
*
* @param client Client index. -1 to update all indices.
* @param mode GOKZ mode. -1 to update all modes.
*/
native void GOKZ_GL_UpdatePoints(int client = -1, int mode = -1);
/**
* Gets whether the Global API key is valid or not for global status.
*
* @return True if the API key is valid, false otherwise or if there is no connection to the Global API.
*/
native bool GOKZ_GL_GetAPIKeyValid();
/**
* Gets whether the running plugins are valid or not for global status.
*
* @return True if the plugins are valid, false otherwise.
*/
native bool GOKZ_GL_GetPluginsValid();
/**
* Gets whether the setting enforcer is valid or not for global status.
*
* @return True if the setting enforcer is valid, false otherwise.
*/
native bool GOKZ_GL_GetSettingsEnforcerValid();
/**
* Gets whether the current map is valid or not for global status.
*
* @return True if the map is valid, false otherwise or if there is no connection to the Global API.
*/
native bool GOKZ_GL_GetMapValid();
/**
* Gets whether the current player is valid or not for global status.
*
* @param client Client index.
* @return True if the player is valid, false otherwise or if there is no connection to the Global API.
*/
native bool GOKZ_GL_GetPlayerValid(int client);
// =====[ STOCKS ]=====
/**
* Gets the global mode enumeration equivalent for the GOKZ mode.
*
* @param mode GOKZ mode.
* @return Global mode enumeration equivalent.
*/
stock GlobalMode GOKZ_GL_GetGlobalMode(int mode)
{
switch (mode)
{
case Mode_Vanilla:return GlobalMode_Vanilla;
case Mode_SimpleKZ:return GlobalMode_KZSimple;
case Mode_KZTimer:return GlobalMode_KZTimer;
}
return GlobalMode_Invalid;
}
/**
* Gets the global mode enumeration equivalent for the GOKZ mode.
*
* @param mode GOKZ mode.
* @return Global mode enumeration equivalent.
*/
stock int GOKZ_GL_FromGlobalMode(GlobalMode mode)
{
switch (mode)
{
case GlobalMode_Vanilla:return Mode_Vanilla;
case GlobalMode_KZSimple:return Mode_SimpleKZ;
case GlobalMode_KZTimer:return Mode_KZTimer;
}
return -1;
}
/**
* Gets the string representation of a mode.
*
* @param mode GOKZ mode.
* @param mode_str String version of the mode.
* @param size Max length of mode_str.
* @return True if the conversion was successful.
*/
stock bool GOKZ_GL_GetModeString(int mode, char[] mode_str, int size)
{
switch (mode)
{
case Mode_Vanilla:strcopy(mode_str, size, "kz_vanilla");
case Mode_SimpleKZ:strcopy(mode_str, size, "kz_simple");
case Mode_KZTimer:strcopy(mode_str, size, "kz_timer");
default:return false;
}
return true;
}
// =====[ DEPENDENCY ]=====
public SharedPlugin __pl_gokz_global =
{
name = "gokz-global",
file = "gokz-global.smx",
#if defined REQUIRE_PLUGIN
required = 1,
#else
required = 0,
#endif
};
#if !defined REQUIRE_PLUGIN
public void __pl_gokz_global_SetNTVOptional()
{
MarkNativeAsOptional("GOKZ_GL_PrintRecords");
MarkNativeAsOptional("GOKZ_GL_DisplayMapTopMenu");
MarkNativeAsOptional("GOKZ_GL_UpdatePoints");
MarkNativeAsOptional("GOKZ_GL_GetAPIKeyValid");
MarkNativeAsOptional("GOKZ_GL_GetPluginsValid");
MarkNativeAsOptional("GOKZ_GL_GetSettingsEnforcerValid");
MarkNativeAsOptional("GOKZ_GL_GetMapValid");
MarkNativeAsOptional("GOKZ_GL_GetPlayerValid");
MarkNativeAsOptional("GOKZ_GL_GetPoints");
MarkNativeAsOptional("GOKZ_GL_GetMapPoints");
MarkNativeAsOptional("GOKZ_GL_GetRankPoints");
MarkNativeAsOptional("GOKZ_GL_GetFinishes");
MarkNativeAsOptional("GOKZ_GL_UpdatePoints");
}
#endif
|