forked from bklol/Misc-Plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
oryx-configcheck.sp
395 lines (345 loc) · 12 KB
/
oryx-configcheck.sp
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
/* Oryx AC: collects and analyzes statistics to find some cheaters in CS:S, CS:GO, and TF2 bunnyhop.
* Copyright (C) 2018 Nolan O.
* Copyright (C) 2018 shavit.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include <sourcemod>
#include <oryx>
#undef REQUIRE_PLUGIN
#include <shavit>
#pragma newdecls required
#pragma semicolon 1
#define DESC1 "Movement config"
#define DESC2 "+klook usage"
// Minimum delay in ticks from last detection until a new one triggers.
#define KLOOK_DELAY 1000
ConVar gCV_KLookDetection = null;
bool gB_KLookUsed[MAXPLAYERS+1];
int gI_LastDetection[MAXPLAYERS+1];
int gI_PerfectConfigStreak[MAXPLAYERS+1];
int gI_PerfectConfigStreakW[MAXPLAYERS+1];
int gI_PerfectConfigStreakA[MAXPLAYERS+1];
int gI_PerfectConfigStreakS[MAXPLAYERS+1];
int gI_PerfectConfigStreakD[MAXPLAYERS+1];
int gI_PerfectConfigStreakWA[MAXPLAYERS+1];
int gI_PerfectConfigStreakWD[MAXPLAYERS+1];
int gI_PerfectConfigStreakSA[MAXPLAYERS+1];
int gI_PerfectConfigStreakSD[MAXPLAYERS+1];
int gI_PreviousButtons[MAXPLAYERS+1];
int gI_JumpsFromZone[MAXPLAYERS+1];
bool gB_Shavit = false;
public Plugin myinfo =
{
name = "ORYX movement config module",
author = "Rusty, shavit",
description = "Detects movement configs (null binds, \"k120 syndrome\", +klook LJ binds).",
version = ORYX_VERSION,
url = "https://github.com/shavitush/Oryx-AC"
}
public void OnPluginStart()
{
RegAdminCmd("config_streak", Command_ConfigStreak, ADMFLAG_BAN, "Print the config stat buffer for a given player.");
gCV_KLookDetection = CreateConVar("oryx-configcheck_klook", "1", "How to treat +klook usage?\n-1 - do not.\n0 - disable +klook.\n1 - disable + alert admins and log.\n2 - kick player.", 0, true, -1.0, true, 2.0);
AutoExecConfig();
LoadTranslations("common.phrases");
gB_Shavit = LibraryExists("shavit");
}
public void OnClientPutInServer(int client)
{
gB_KLookUsed[client] = false;
gI_LastDetection[client] = 0;
gI_PerfectConfigStreak[client] = 0;
gI_PerfectConfigStreakW[client] = 0;
gI_PerfectConfigStreakA[client] = 0;
gI_PerfectConfigStreakS[client] = 0;
gI_PerfectConfigStreakD[client] = 0;
gI_PerfectConfigStreakWA[client] = 0;
gI_PerfectConfigStreakWD[client] = 0;
gI_PerfectConfigStreakSA[client] = 0;
gI_PerfectConfigStreakSD[client] = 0;
gI_JumpsFromZone[client] = 0;
}
public void OnLibraryAdded(const char[] name)
{
if(StrEqual(name, "shavit"))
{
gB_Shavit = true;
}
}
public void OnLibraryRemoved(const char[] name)
{
if(StrEqual(name, "shavit"))
{
gB_Shavit = false;
}
}
public Action Command_ConfigStreak(int client, int args)
{
if(args < 1)
{
ReplyToCommand(client, "Usage: config_streak <target>");
return Plugin_Handled;
}
char[] sArgs = new char[MAX_TARGET_LENGTH];
GetCmdArgString(sArgs, MAX_TARGET_LENGTH);
int target = FindTarget(client, sArgs);
if(target == -1)
{
return Plugin_Handled;
}
char[] sAuth = new char[32];
if(!GetClientAuthId(target, AuthId_Steam3, sAuth, 32))
{
strcopy(sAuth, 32, "ERR_GETTING_ID");
}
ReplyToCommand(client, "User \x03%N\x01 (\x05%s\x01) is on a total config streak of \x04%d\x01., W: \x04%d\x01 A: \x04%d\x01 S: \x04%d\x01 D: \x04%d\x01", target, sAuth, gI_PerfectConfigStreak[target], gI_PerfectConfigStreakW[target], gI_PerfectConfigStreakA[target], gI_PerfectConfigStreakS[target], gI_PerfectConfigStreakD[target]);
return Plugin_Handled;
}
public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3])
{
if(gB_Shavit || !IsPlayerAlive(client) || IsFakeClient(client) || !ShouldCheck(client))
{
return Plugin_Continue;
}
return SetupMove(client, buttons, vel);
}
public Action Shavit_OnUserCmdPre(int client, int &buttons, int &impulse, float vel[3], float angles[3], TimerStatus status, int track, int style)
{
return SetupMove(client, buttons, vel);
}
Action SetupMove(int client, int &buttons, float vel[3])
{
if(Oryx_CanBypass(client))
{
return Plugin_Continue;
}
int iFlags = GetEntityFlags(client);
int iDetect = gCV_KLookDetection.IntValue;
if(iDetect > -1)
{
if((iFlags & FL_ONGROUND) == 0)
{
int iLR = (buttons & (IN_MOVELEFT | IN_MOVERIGHT));
int iFB = (buttons & (IN_FORWARD | IN_BACK));
if((vel[0] == 0.0 && iFB != 0 && iFB != (IN_FORWARD | IN_BACK)) ||
(vel[1] == 0.0 && iLR != 0 && iLR != (IN_MOVELEFT | IN_MOVERIGHT)))
{
// Disable movement for the whole jump
gB_KLookUsed[client] = true;
}
}
else
{
gB_KLookUsed[client] = false;
}
if(gB_KLookUsed[client])
{
vel[0] = 0.0;
vel[1] = 0.0;
if(iDetect > 0)
{
int iTicks = GetGameTickCount();
if(iTicks - gI_LastDetection[client] >= KLOOK_DELAY)
{
Oryx_Trigger(client, (iDetect == 1)? TRIGGER_HIGH_NOKICK:TRIGGER_DEFINITIVE, DESC2);
gI_LastDetection[client] = iTicks;
}
}
return Plugin_Changed;
}
}
if(gB_Shavit)
{
if(Shavit_InsideZone(client, Zone_Start, -1))
{
gI_JumpsFromZone[client] = 0;
return Plugin_Continue;
}
if((iFlags & FL_ONGROUND) > 0 && (buttons & IN_JUMP) > 0)
{
gI_JumpsFromZone[client]++;
}
if(gI_JumpsFromZone[client] < 2)
{
return Plugin_Continue;
}
}
if(((iFlags & FL_ONGROUND) == 0) || (buttons & IN_JUMP) > 0)
{
// Check for perfect transitions in W/A/S/D.
// Check D
if((buttons & IN_MOVELEFT) == 0 && (buttons & IN_MOVERIGHT) > 0 && (gI_PreviousButtons[client] & IN_MOVERIGHT) == 0 && (gI_PreviousButtons[client] & IN_MOVELEFT) > 0)
{
PerfectTransition(client);
gI_PerfectConfigStreakD[client]++;
}
// Check A
if ((buttons & IN_MOVERIGHT) == 0 && (buttons & IN_MOVELEFT) > 0 && (gI_PreviousButtons[client] & IN_MOVELEFT) == 0 && (gI_PreviousButtons[client] & IN_MOVERIGHT) > 0)
{
PerfectTransition(client);
gI_PerfectConfigStreakA[client]++;
}
// Check S
if((buttons & IN_FORWARD) == 0 && (buttons & IN_BACK) > 0 && (gI_PreviousButtons[client] & IN_BACK) == 0 && (gI_PreviousButtons[client] & IN_FORWARD) > 0)
{
PerfectTransition(client);
gI_PerfectConfigStreakS[client]++;
}
// Check W
if((buttons & IN_BACK) == 0 && (buttons & IN_MOVELEFT) > 0 && (gI_PreviousButtons[client] & IN_FORWARD) == 0 && (gI_PreviousButtons[client] & IN_BACK) > 0)
{
PerfectTransition(client);
gI_PerfectConfigStreakW[client]++;
}
// Are both moveleft/moveright pressed?
else if((buttons & (IN_MOVELEFT | IN_MOVERIGHT) == (IN_MOVELEFT | IN_MOVERIGHT)) || (buttons & (IN_BACK | IN_FORWARD) == (IN_BACK | IN_FORWARD)))
{
gI_PerfectConfigStreak[client] = 0;
gI_PerfectConfigStreakW[client] = 0;
gI_PerfectConfigStreakA[client] = 0;
gI_PerfectConfigStreakS[client] = 0;
gI_PerfectConfigStreakD[client] = 0;
}
// Check WD
if((buttons & IN_FORWARD) > 0 && (buttons & IN_MOVERIGHT) > 0 && (gI_PreviousButtons[client] & IN_FORWARD) == 0 && (gI_PreviousButtons[client] & IN_MOVERIGHT) == 0)
{
PerfectTransition(client);
gI_PerfectConfigStreakWD[client]++;
}
// Check WA
if((buttons & IN_FORWARD) > 0 && (buttons & IN_MOVELEFT) > 0 && (gI_PreviousButtons[client] & IN_FORWARD) == 0 && (gI_PreviousButtons[client] & IN_MOVELEFT) == 0)
{
PerfectTransition(client);
gI_PerfectConfigStreakWA[client]++;
}
// Check SA
if((buttons & IN_BACK) > 0 && (buttons & IN_MOVELEFT) > 0 && (gI_PreviousButtons[client] & IN_BACK) == 0 && (gI_PreviousButtons[client] & IN_MOVELEFT) == 0)
{
PerfectTransition(client);
gI_PerfectConfigStreakSA[client]++;
}
// Check SD
if((buttons & IN_BACK) > 0 && (buttons & IN_MOVERIGHT) > 0 && (gI_PreviousButtons[client] & IN_BACK) == 0 && (gI_PreviousButtons[client] & IN_MOVERIGHT) == 0)
{
PerfectTransition(client);
gI_PerfectConfigStreakSD[client]++;
}
// I hopefully shouldn't need to check previous key presses to reset. and the config doesn't do any "nulling"
// Reset WD
// Pressed W without D
if((buttons & IN_FORWARD) > 0 && (buttons & IN_MOVERIGHT) == 0)
{
gI_PerfectConfigStreakWD[client] = 0;
}
// Reset WA
if((buttons & IN_FORWARD) > 0 && (buttons & IN_MOVELEFT) == 0)
{
gI_PerfectConfigStreakWA[client] = 0;
}
// Reset SA
if((buttons & IN_BACK) > 0 && (buttons & IN_MOVELEFT) == 0)
{
gI_PerfectConfigStreakSA[client] = 0;
}
// Reset SD
if((buttons & IN_BACK) > 0 && (buttons & IN_MOVERIGHT) == 0)
{
gI_PerfectConfigStreakSD[client] = 0;
}
}
gI_PreviousButtons[client] = buttons;
return Plugin_Continue;
}
void PerfectTransition(int client)
{
if((gI_PerfectConfigStreakW[client] == 75) || (gI_PerfectConfigStreakA[client] == 75) || (gI_PerfectConfigStreakS[client] == 75) || (gI_PerfectConfigStreakD[client] == 75))
{
Oryx_Trigger(client, TRIGGER_HIGH, DESC1);
}
if((gI_PerfectConfigStreakWD[client] == 75) || (gI_PerfectConfigStreakWA[client] == 75) || (gI_PerfectConfigStreakSD[client] == 75) || (gI_PerfectConfigStreakSA[client] == 75))
{
Oryx_Trigger(client, TRIGGER_HIGH, DESC1);
}
}
stock bool ShouldCheck(int client)
{
if(Shavit_IsPracticeMode(client))
{
return false;
}
return true;
}
/*
//-----------------------------------------------------------------------------
// Check if the player has held both A/D or W/S together for a period of time.
//-----------------------------------------------------------------------------
void checkIfSHSW(int client, int buttons)
{
static int s_LastKeys[MAXPLAYERS + 1];
static bool s_bStartedHolding[MAXPLAYERS+1][keyPair];
static int s_StartHoldTick[MAXPLAYERS+1][keyPair];
static int s_LastReleased[MAXPLAYERS+1][keyPair];
int flags = GetEntityFlags(client);
if(flags & FL_ONGROUND == 0 || buttons & IN_JUMP > 0)
{
// Check WD
if((buttons & IN_FORWARD) > 0 && (buttons & IN_MOVERIGHT) > 0 && (gI_PreviousButtons[client] & IN_FORWARD) == 0 && (gI_PreviousButtons[client] & IN_MOVERIGHT) == 0)
{
PerfectTransition(client);
fwdKeys(client, ForwardRight, ASHHook_OnPerfectKeyChange, (IN_FORWARD + IN_MOVERIGHT), g_Data[client][Current][Tick] - s_LastReleased[client][pair][0]);
}
// Check WA
if((buttons & IN_FORWARD) > 0 && (buttons & IN_MOVELEFT) > 0 && (gI_PreviousButtons[client] & IN_FORWARD) == 0 && (gI_PreviousButtons[client] & IN_MOVELEFT) == 0)
{
PerfectTransition(client);
fwdKeys(client, ForwardLeft, ASHHook_OnPerfectKeyChange, (IN_FORWARD + IN_MOVELEFT), g_Data[client][Current][Tick] - s_LastReleased[client][pair][0]);
}
// Check SA
if((buttons & IN_BACK) > 0 && (buttons & IN_MOVELEFT) > 0 && (gI_PreviousButtons[client] & IN_BACK) == 0 && (gI_PreviousButtons[client] & IN_MOVELEFT) == 0)
{
PerfectTransition(client);
fwdKeys(client, BackLeft, ASHHook_OnPerfectKeyChange, (IN_BACK + IN_MOVELEFT), g_Data[client][Current][Tick] - s_LastReleased[client][pair][0]);
}
// Check SD
if((buttons & IN_BACK) > 0 && (buttons & IN_MOVERIGHT) > 0 && (gI_PreviousButtons[client] & IN_BACK) == 0 && (gI_PreviousButtons[client] & IN_MOVERIGHT) == 0)
{
PerfectTransition(client);
fwdKeys(client, BackRight, ASHHook_OnPerfectKeyChange, (IN_BACK + IN_MOVERIGHT), g_Data[client][Current][Tick] - s_LastReleased[client][pair][0]);
}
// I hopefully shouldn't need to check previous key presses to reset. and the config doesn't do any "nulling"
// Reset WD
// Pressed W without D
if((buttons & IN_FORWARD) > 0 && (buttons & IN_MOVERIGHT) == 0)
{
gI_PerfectConfigStreakWD[client] = 0;
}
// Reset WA
if((buttons & IN_FORWARD) > 0 && (buttons & IN_MOVELEFT) == 0)
{
gI_PerfectConfigStreakWA[client] = 0;
}
// Reset SA
if((buttons & IN_BACK) > 0 && (buttons & IN_MOVELEFT) == 0)
{
gI_PerfectConfigStreakSA[client] = 0;
}
// Reset SD
if((buttons & IN_BACK) > 0 && (buttons & IN_MOVERIGHT) == 0)
{
gI_PerfectConfigStreakSD[client] = 0;
}
}
}
*/