├── LICENSE
├── README.md
├── include
├── bash2.inc
└── sendproxy.inc
├── shavit-bash2-discord.sp
└── shavit-bash2.sp
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # BASH 2.0
2 |
3 | ## Commands
4 |
5 | ```
6 | bash2_stats - Show strafe stats
7 | bash2_admin - toggle admin mode, lets you enable/disable printing of bash logs into the chat.
8 | bash2_test - trigger a test message so you can know if webhooks are working :)
9 | ```
10 |
11 | ## ConVars
12 |
13 | ### shavit-bash.sp
14 |
15 | ```
16 | bash_antinull - lets you disable or enable null kicking
17 | bash_banlength - lets you set banlength
18 | bash_autoban - disable/enable automatic banning.
19 | bash_persistent_data - Saves and reload strafe stats on player rejoin.
20 | ```
21 |
22 | ### shavit-bash-discord.sp
23 |
24 | ```
25 | bash_discord_webhook - The url for the Discord webhook.
26 | bash_discord_only_bans - Only send ban messages and no logs.
27 | bash_discord_ignore_nulls - Don't send null logs.
28 | bash_discord_use_embeds - Send embed messages.
29 | ```
30 |
31 | ## Depencenies
32 |
33 | * [REST in Pawn](https://forums.alliedmods.net/showthread.php?t=298024) (only needed for shavit-bash-discord.sp)
34 |
35 | ## Anticheat bypass
36 |
37 | If you are using bhoptimer, you can add "bash_bypass" to a styles special string to disable detection for this style.
38 |
39 |
40 | 
41 |
--------------------------------------------------------------------------------
/include/bash2.inc:
--------------------------------------------------------------------------------
1 | #if defined _bash_included
2 | #endinput
3 | #endif
4 | #define _bash_included
5 |
6 | /**
7 | * Called when BASH logs a cheat detection/indicator.
8 | *
9 | * @param client Client index.
10 | * @param buffer Log content.
11 | * @noreturn
12 | */
13 | forward void Bash_OnDetection(int client, char[] buffer);
14 |
15 | /**
16 | * Called when BASH bans a client.
17 | *
18 | * @param client Client index.
19 | * @noreturn
20 | */
21 | forward void Bash_OnClientBanned(int client);
22 |
23 | public SharedPlugin __pl_bash =
24 | {
25 | name = "shavit-bash2",
26 | file = "shavit-bash2.smx",
27 | #if defined REQUIRE_PLUGIN
28 | required = 1,
29 | #else
30 | required = 0,
31 | #endif
32 | };
33 |
--------------------------------------------------------------------------------
/include/sendproxy.inc:
--------------------------------------------------------------------------------
1 | #if !defined _SENDPROXYMANAGER_INC_
2 | #define _SENDPROXYMANAGER_INC_
3 |
4 |
5 |
6 | enum SendPropType {
7 | Prop_Int = 0,
8 | Prop_Float = 1,
9 | Prop_String = 2,
10 | //Prop_Array = 3,
11 | Prop_Vector = 4,
12 | Prop_Max
13 | };
14 |
15 | typeset SendProxyCallback
16 | {
17 | function Action (int entity, const char[] PropName, int &iValue, int element); //Prop_Int
18 | function Action (int entity, const char[] PropName, float &flValue, int element); //Prop_Float
19 | function Action (int entity, const char[] PropName, char modifiedValue[4096], int element); //Prop_String
20 | function Action (int entity, const char[] PropName, float vecValues[3], int element); //Prop_Vector
21 | };
22 |
23 | typeset SendProxyCallbackGamerules
24 | {
25 | function Action (const char[] PropName, int &iValue, int element); //Prop_Int
26 | function Action (const char[] PropName, float &flValue, int element); //Prop_Float
27 | function Action (const char[] PropName, char modifiedValue[4096], int element); //Prop_String
28 | function Action (const char[] PropName, float vecValues[3], int element); //Prop_Vector
29 | };
30 |
31 | typeset PropChangedCallback
32 | {
33 | function void(int entity, const char[] PropName, const char[] oldValue, const char[] newValue);
34 | };
35 |
36 | typeset GameRulesPropChangedCallback
37 | {
38 | function void(const char[] PropName, const char[] oldValue, const char[] newValue);
39 | };
40 |
41 | //Returns true upon success, false upon failure
42 | native bool SendProxy_Hook(int entity, char[] propname, SendPropType proptype, SendProxyCallback callback);
43 | native bool SendProxy_HookGameRules(char[] propname, SendPropType proptype, SendProxyCallbackGamerules callback);
44 | native bool SendProxy_HookArrayProp(int entity, const char[] name, int element, SendPropType: ype, SendProxyCallback callback);
45 | native bool SendProxy_UnhookArrayProp(int entity, const char[] name, int element, SendPropType type, SendProxyCallback callback);
46 | native bool SendProxy_Unhook(int entity, char[] propname, SendProxyCallback callback);
47 | native bool SendProxy_UnhookGameRules(char[] propname, SendProxyCallbackGamerules callback);
48 | native bool SendProxy_IsHooked(int entity, char[] propname);
49 | native bool SendProxy_IsHookedGameRules(char[] propname);
50 |
51 | native bool SendProxy_HookPropChange(entity, const char[] name, PropChangedCallback callback);
52 | native bool SendProxy_HookPropChangeGameRules(const char[] name, GameRulesPropChangedCallback callback);
53 | native void SendProxy_UnhookPropChange(entity, const char[] name, PropChangedCallback callback);
54 | native void SendProxy_UnhookPropChangeGameRules(const char[] name, GameRulesPropChangedCallback callback);
55 |
56 | #if !defined REQUIRE_EXTENSIONS
57 | public __ext_sendproxymanager_SetNTVOptional()
58 | {
59 | MarkNativeAsOptional("SendProxy_Hook");
60 | MarkNativeAsOptional("SendProxy_HookArrayProp");
61 | MarkNativeAsOptional("SendProxy_Unhook");
62 | MarkNativeAsOptional("SendProxy_IsHooked");
63 | MarkNativeAsOptional("SendProxy_HookPropChange");
64 | MarkNativeAsOptional("SendProxy_UnhookPropChange");
65 | }
66 | #endif
67 |
68 | public Extension __ext_sendproxymanager =
69 | {
70 | name = "SendProxy Manager",
71 | file = "sendproxy.ext",
72 | #if defined AUTOLOAD_EXTENSIONS
73 | autoload = 1,
74 | #else
75 | autoload = 0,
76 | #endif
77 | #if defined REQUIRE_EXTENSIONS
78 | required = 1,
79 | #else
80 | required = 0,
81 | #endif
82 | };
83 |
84 | #endif
--------------------------------------------------------------------------------
/shavit-bash2-discord.sp:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | #include
4 | #include
5 |
6 | #pragma newdecls required
7 | #pragma semicolon 1
8 |
9 | ConVar gCV_Webhook;
10 | ConVar gCV_OnlyBans;
11 | ConVar gCV_IgnoreNulls;
12 | ConVar gCV_UseEmbeds;
13 |
14 | public Plugin myinfo =
15 | {
16 | name = "[BASH] Discord",
17 | author = "Eric",
18 | description = "",
19 | version = "1.0.0",
20 | url = "https://github.com/hermansimensen/bash2"
21 | };
22 |
23 | public void OnPluginStart()
24 | {
25 | gCV_Webhook = CreateConVar("bash_discord_webhook", "", "Discord webhook.", FCVAR_PROTECTED);
26 | gCV_OnlyBans = CreateConVar("bash_discord_only_bans", "0", "Only send ban messages and no logs.", _, true, 0.0, true, 1.0);
27 | gCV_IgnoreNulls = CreateConVar("bash_discord_ignore_nulls", "1", "Don't send null logs.", _, true, 0.0, true, 1.0);
28 | gCV_UseEmbeds = CreateConVar("bash_discord_use_embeds", "1", "Send embed messages.", _, true, 0.0, true, 1.0);
29 | AutoExecConfig(true, "bash-discord", "sourcemod");
30 | }
31 |
32 | public void Bash_OnDetection(int client, char[] buffer)
33 | {
34 | if (gCV_OnlyBans.BoolValue)
35 | {
36 | return;
37 | }
38 |
39 | if (gCV_IgnoreNulls.BoolValue && StrContains(buffer, "nullPct") != -1)
40 | {
41 | return;
42 | }
43 |
44 | if (gCV_UseEmbeds.BoolValue)
45 | {
46 | FormatEmbedMessage(client, buffer);
47 | }
48 | else
49 | {
50 | FormatMessage(client, buffer);
51 | }
52 | }
53 |
54 | public void Bash_OnClientBanned(int client)
55 | {
56 | if (gCV_UseEmbeds.BoolValue)
57 | {
58 | FormatEmbedMessage(client, "Banned for cheating.");
59 | }
60 | else
61 | {
62 | FormatMessage(client, "Banned for cheating.");
63 | }
64 | }
65 |
66 | void FormatEmbedMessage(int client, char[] buffer)
67 | {
68 | char hostname[128];
69 | FindConVar("hostname").GetString(hostname, sizeof(hostname));
70 |
71 | char steamId[32];
72 | GetClientAuthId(client, AuthId_SteamID64, steamId, sizeof(steamId));
73 |
74 | char name[MAX_NAME_LENGTH];
75 | GetClientName(client, name, sizeof(name));
76 | SanitizeName(name);
77 |
78 | char player[512];
79 | Format(player, sizeof(player), "[%s](http://www.steamcommunity.com/profiles/%s)", name, steamId);
80 |
81 | // https://discord.com/developers/docs/resources/channel#embed-object
82 | // https://discord.com/developers/docs/resources/channel#embed-object-embed-field-structure
83 | // https://discord.com/developers/docs/resources/webhook#webhook-object-jsonform-params
84 | JSONObject playerField = new JSONObject();
85 | playerField.SetString("name", "Player");
86 | playerField.SetString("value", player);
87 | playerField.SetBool("inline", true);
88 |
89 | JSONObject eventField = new JSONObject();
90 | eventField.SetString("name", "Event");
91 | eventField.SetString("value", buffer);
92 | eventField.SetBool("inline", true);
93 |
94 | JSONArray fields = new JSONArray();
95 | fields.Push(playerField);
96 | fields.Push(eventField);
97 |
98 | JSONObject embed = new JSONObject();
99 | embed.SetString("title", hostname);
100 | embed.SetString("color", "16720418");
101 | embed.Set("fields", fields);
102 |
103 | JSONArray embeds = new JSONArray();
104 | embeds.Push(embed);
105 |
106 | JSONObject json = new JSONObject();
107 | json.SetString("username", "BASH 2.0");
108 | json.Set("embeds", embeds);
109 |
110 | SendMessage(json);
111 |
112 | delete playerField;
113 | delete eventField;
114 | delete fields;
115 | delete embed;
116 | delete embeds;
117 | delete json;
118 | }
119 |
120 | void FormatMessage(int client, char[] buffer)
121 | {
122 | char hostname[128];
123 | FindConVar("hostname").GetString(hostname, sizeof(hostname));
124 |
125 | char steamId[32];
126 | GetClientAuthId(client, AuthId_SteamID64, steamId, sizeof(steamId));
127 |
128 | char name[MAX_NAME_LENGTH];
129 | GetClientName(client, name, sizeof(name));
130 | SanitizeName(name);
131 |
132 | char content[1024];
133 | Format(content, sizeof(content), "[%s](http://www.steamcommunity.com/profiles/%s) %s", name, steamId, buffer);
134 |
135 | // Suppress Discord mentions and embeds.
136 | // https://discord.com/developers/docs/resources/channel#allowed-mentions-object
137 | // https://discord.com/developers/docs/resources/channel#message-object-message-flags
138 | JSONArray parse = new JSONArray();
139 | JSONObject allowedMentions = new JSONObject();
140 | allowedMentions.Set("parse", parse);
141 |
142 | JSONObject json = new JSONObject();
143 | json.SetString("username", hostname);
144 | json.SetString("content", content);
145 | json.Set("allowed_mentions", allowedMentions);
146 | json.SetInt("flags", 4);
147 |
148 | SendMessage(json);
149 |
150 | delete parse;
151 | delete allowedMentions;
152 | delete json;
153 | }
154 |
155 | void SendMessage(JSONObject json)
156 | {
157 | char webhook[256];
158 | gCV_Webhook.GetString(webhook, sizeof(webhook));
159 |
160 | if (webhook[0] == '\0')
161 | {
162 | LogError("Discord webhook is not set.");
163 | return;
164 | }
165 |
166 | HTTPRequest request = new HTTPRequest(webhook);
167 | request.Post(json, OnMessageSent);
168 | }
169 |
170 | public void OnMessageSent(HTTPResponse response, any value, const char[] error)
171 | {
172 | if (response.Status != HTTPStatus_NoContent)
173 | {
174 | LogError("Failed to send message to Discord. Response status: %d.", response.Status);
175 | }
176 | }
177 |
178 | void SanitizeName(char[] name)
179 | {
180 | ReplaceString(name, MAX_NAME_LENGTH, "(", "", false);
181 | ReplaceString(name, MAX_NAME_LENGTH, ")", "", false);
182 | ReplaceString(name, MAX_NAME_LENGTH, "]", "", false);
183 | ReplaceString(name, MAX_NAME_LENGTH, "[", "", false);
184 | }
185 |
--------------------------------------------------------------------------------
/shavit-bash2.sp:
--------------------------------------------------------------------------------
1 | #define TIMER
2 |
3 | #include
4 | #include
5 | #include
6 | #include
7 |
8 | #if defined TIMER
9 | #include
10 | #endif
11 |
12 | #undef REQUIRE_EXTENSIONS
13 | #include
14 | #include
15 |
16 | #pragma newdecls required
17 |
18 | #define BAN_LENGTH "0"
19 | #define IDENTICAL_STRAFE_MIN 20
20 |
21 | public Plugin myinfo =
22 | {
23 | name = "[BASH] (Blacky's Anti-Strafehack)",
24 | author = "Blacky, edited by carnifex",
25 | description = "Detects strafe hackers",
26 | version = "2.0",
27 | url = "https://github.com/hermansimensen/bash2"
28 | };
29 |
30 | // Definitions
31 | #define Button_Forward 0
32 | #define Button_Back 1
33 | #define Button_Left 2
34 | #define Button_Right 3
35 |
36 | #define BT_Move 0
37 | #define BT_Key 1
38 |
39 | #define Moving_Forward 0
40 | #define Moving_Back 1
41 | #define Moving_Left 2
42 | #define Moving_Right 3
43 |
44 | #define Turn_Left 0
45 | #define Turn_Right 1
46 |
47 | // Start/End Strafe Data
48 | #define StrafeData_Button 0
49 | #define StrafeData_TurnDirection 1
50 | #define StrafeData_MoveDirection 2
51 | #define StrafeData_Difference 3
52 | #define StrafeData_Tick 4
53 | #define StrafeData_IsTiming 5
54 |
55 | // Key switch data
56 | #define KeySwitchData_Button 0
57 | #define KeySwitchData_Difference 1
58 | #define KeySwitchData_IsTiming 2
59 |
60 | // Detection reasons
61 | #define DR_StartStrafe_LowDeviation (1 << 0) // < 1.0 very likely strafe hacks (Warn admins)
62 | #define DR_StartStrafe_AlwaysPositive (1 << 1) // Might not be strafe hacking but a good indicator of someone trying to bypass anticheat (Warn admins)
63 | #define DR_EndStrafe_LowDeviation (1 << 2) // < 1.0 very likely strafe hacks (Warn admins)
64 | #define DR_EndStrafe_AlwaysPositive (1 << 3) // Might not be strafe hacking but a good indicator of someone trying to bypass anticheat (Warn admins)
65 | #define DR_StartStrafeMatchesEndStrafe (1 << 4) // A way to catch an angle delay hack (Do nothing)
66 | #define DR_KeySwitchesTooPerfect (1 << 5) // Could be movement config or anti ghosting keyboard (Warn admins)
67 | #define DR_FailedManualAngleTest (1 << 6) // Almost definitely strafe hacking (Ban)
68 | #define DR_ButtonsAndSideMoveDontMatch (1 << 7) // Could be caused by lag but can be made to detect strafe hacks perfectly (Ban/Warn based on severity)
69 | #define DR_ImpossibleSideMove (1 << 8) // Could be +strafe or controller but most likely strafe hack (Warn admins/Stop player movements)
70 | #define DR_FailedManualMOTDTest (1 << 9) // Almost definitely strafe hacking (Ban)
71 | #define DR_AngleDelay (1 << 10) // Player freezes their angles for 1 or more ticks after they press a button until the angle changes again
72 | #define DR_ImpossibleGains (1 << 11) // < 85% probably strafe hacks
73 | #define DR_WiggleHack (1 << 12) // Almost definitely strafe hack. Check for IN_LEFT/IN_RIGHT
74 | #define DR_TurningInfraction (1 << 13) // Client turns at impossible speeds
75 |
76 | EngineVersion g_Engine;
77 | int g_iRealButtons[MAXPLAYERS + 1];
78 | int g_iButtons[MAXPLAYERS + 1][2];
79 | int g_iLastButtons[MAXPLAYERS + 1][2];
80 | int g_iLastPressTick[MAXPLAYERS + 1][4][2];
81 | int g_iLastPressTick_Recorded[MAXPLAYERS + 1][4][2];
82 | int g_iLastPressTick_Recorded_KS[MAXPLAYERS + 1][4][2];
83 | int g_iKeyPressesThisStrafe[MAXPLAYERS + 1][2];
84 | int g_iLastReleaseTick[MAXPLAYERS + 1][4][2];
85 | int g_iLastReleaseTick_Recorded[MAXPLAYERS + 1][4][2];
86 | int g_iLastReleaseTick_Recorded_KS[MAXPLAYERS + 1][4][2];
87 | float g_fLastMove[MAXPLAYERS + 1][3];
88 | int g_iLastTurnDir[MAXPLAYERS + 1];
89 | int g_iLastTurnTick[MAXPLAYERS + 1];
90 | int g_iLastTurnTick_Recorded_StartStrafe[MAXPLAYERS + 1];
91 | int g_iLastTurnTick_Recorded_EndStrafe[MAXPLAYERS + 1];
92 | int g_iLastStopTurnTick[MAXPLAYERS + 1];
93 | bool g_bIsTurning[MAXPLAYERS + 1];
94 | int g_iReleaseTickAtLastEndStrafe[MAXPLAYERS + 1][4];
95 | float g_fLastAngles[MAXPLAYERS + 1][3];
96 | int g_InvalidButtonSidemoveCount[MAXPLAYERS + 1];
97 | int g_iCmdNum[MAXPLAYERS + 1];
98 | float g_fLastPosition[MAXPLAYERS + 1][3];
99 | int g_iLastTeleportTick[MAXPLAYERS + 1];
100 | float g_fAngleDifference[MAXPLAYERS + 1][2];
101 | float g_fLastAngleDifference[MAXPLAYERS + 1][2];
102 |
103 | // Gain calculation
104 | int g_strafeTick[MAXPLAYERS + 1];
105 | float g_flRawGain[MAXPLAYERS + 1];
106 | bool g_bTouchesWall[MAXPLAYERS + 1];
107 | int g_iJump[MAXPLAYERS + 1];
108 | int g_iTicksOnGround[MAXPLAYERS + 1];
109 | float g_iYawSpeed[MAXPLAYERS + 1];
110 | int g_iYawTickCount[MAXPLAYERS + 1];
111 | int g_iTimingTickCount[MAXPLAYERS + 1];
112 | int g_iStrafesDone[MAXPLAYERS + 1];
113 | bool g_bFirstSixJumps[MAXPLAYERS + 1];
114 | #define BHOP_TIME 15
115 |
116 | // Optimizer detection
117 | bool g_bTouchesFuncRotating[MAXPLAYERS + 1];
118 |
119 | // Mouse cvars
120 | float g_mYaw[MAXPLAYERS + 1]; int g_mYawChangedCount[MAXPLAYERS + 1]; int g_mYawCheckedCount[MAXPLAYERS + 1];
121 | bool g_mFilter[MAXPLAYERS + 1]; int g_mFilterChangedCount[MAXPLAYERS + 1]; int g_mFilterCheckedCount[MAXPLAYERS + 1];
122 | int g_mCustomAccel[MAXPLAYERS + 1]; int g_mCustomAccelChangedCount[MAXPLAYERS + 1]; int g_mCustomAccelCheckedCount[MAXPLAYERS + 1];
123 | float g_mCustomAccelMax[MAXPLAYERS + 1]; int g_mCustomAccelMaxChangedCount[MAXPLAYERS + 1]; int g_mCustomAccelMaxCheckedCount[MAXPLAYERS + 1];
124 | float g_mCustomAccelScale[MAXPLAYERS + 1]; int g_mCustomAccelScaleChangedCount[MAXPLAYERS + 1]; int g_mCustomAccelScaleCheckedCount[MAXPLAYERS + 1];
125 | float g_mCustomAccelExponent[MAXPLAYERS + 1]; int g_mCustomAccelExponentChangedCount[MAXPLAYERS + 1]; int g_mCustomAccelExponentCheckedCount[MAXPLAYERS + 1];
126 | bool g_mRawInput[MAXPLAYERS + 1]; int g_mRawInputChangedCount[MAXPLAYERS + 1]; int g_mRawInputCheckedCount[MAXPLAYERS + 1];
127 | float g_Sensitivity[MAXPLAYERS + 1]; int g_SensitivityChangedCount[MAXPLAYERS + 1]; int g_SensitivityCheckedCount[MAXPLAYERS + 1];
128 | float g_JoySensitivity[MAXPLAYERS + 1]; int g_JoySensitivityChangedCount[MAXPLAYERS + 1]; int g_JoySensitivityCheckedCount[MAXPLAYERS + 1];
129 | float g_ZoomSensitivity[MAXPLAYERS + 1]; int g_ZoomSensitivityChangedCount[MAXPLAYERS + 1]; int g_ZoomSensitivityCheckedCount[MAXPLAYERS + 1];
130 | bool g_JoyStick[MAXPLAYERS + 1]; int g_JoyStickChangedCount[MAXPLAYERS + 1]; int g_JoyStickCheckedCount[MAXPLAYERS + 1];
131 |
132 | // Recorded data to analyze
133 | #define MAX_FRAMES 50
134 | #define MAX_FRAMES_KEYSWITCH 50
135 | int g_iStartStrafe_CurrentFrame[MAXPLAYERS + 1];
136 | any g_iStartStrafe_Stats[MAXPLAYERS + 1][7][MAX_FRAMES];
137 | int g_iStartStrafe_LastRecordedTick[MAXPLAYERS + 1];
138 | int g_iStartStrafe_LastTickDifference[MAXPLAYERS + 1];
139 | bool g_bStartStrafe_IsRecorded[MAXPLAYERS + 1][MAX_FRAMES];
140 | int g_iStartStrafe_IdenticalCount[MAXPLAYERS + 1];
141 | int g_iEndStrafe_CurrentFrame[MAXPLAYERS + 1];
142 | any g_iEndStrafe_Stats[MAXPLAYERS + 1][7][MAX_FRAMES];
143 | int g_iEndStrafe_LastRecordedTick[MAXPLAYERS + 1];
144 | int g_iEndStrafe_LastTickDifference[MAXPLAYERS + 1];
145 | bool g_bEndStrafe_IsRecorded[MAXPLAYERS + 1][MAX_FRAMES];
146 | int g_iEndStrafe_IdenticalCount[MAXPLAYERS + 1];
147 | int g_iKeySwitch_CurrentFrame[MAXPLAYERS + 1][2];
148 | any g_iKeySwitch_Stats[MAXPLAYERS + 1][3][2][MAX_FRAMES_KEYSWITCH];
149 | bool g_bKeySwitch_IsRecorded[MAXPLAYERS + 1][2][MAX_FRAMES_KEYSWITCH];
150 | int g_iKeySwitch_LastRecordedTick[MAXPLAYERS + 1][2];
151 | bool g_iIllegalTurn[MAXPLAYERS + 1][MAX_FRAMES];
152 | int g_iIllegalTurn_CurrentFrame[MAXPLAYERS + 1];
153 | bool g_iIllegalTurn_IsTiming[MAXPLAYERS + 1][MAX_FRAMES];
154 | int g_iLastIllegalReason[MAXPLAYERS + 1];
155 | int g_iIllegalSidemoveCount[MAXPLAYERS + 1];
156 | int g_iLastIllegalSidemoveCount[MAXPLAYERS + 1];
157 | int g_iLastInvalidButtonCount[MAXPLAYERS + 1];
158 | int g_iYawChangeCount[MAXPLAYERS + 1];
159 |
160 | //bool g_bTasLoaded;
161 | bool g_bCheckedYet[MAXPLAYERS + 1];
162 | float g_MOTDTestAngles[MAXPLAYERS + 1][3];
163 | bool g_bMOTDTest[MAXPLAYERS + 1];
164 | int g_iTarget[MAXPLAYERS + 1];
165 |
166 | // this is like 5600+ bytes xd
167 | enum struct fuck_sourcemod
168 | {
169 | int accountid;
170 |
171 | int g_iRealButtons;
172 | int g_iButtons[2];
173 | int g_iLastButtons[2];
174 |
175 | //int g_iLastPressTick[4][2];
176 | int g_iLastPressTick_0[2];
177 | int g_iLastPressTick_1[2];
178 | int g_iLastPressTick_2[2];
179 | int g_iLastPressTick_3[2];
180 |
181 | //int g_iLastPressTick_Recorded[4][2];
182 | int g_iLastPressTick_Recorded_0[2];
183 | int g_iLastPressTick_Recorded_1[2];
184 | int g_iLastPressTick_Recorded_2[2];
185 | int g_iLastPressTick_Recorded_3[2];
186 |
187 | //int g_iLastPressTick_Recorded_KS[4][2];
188 | int g_iLastPressTick_Recorded_KS_0[2];
189 | int g_iLastPressTick_Recorded_KS_1[2];
190 | int g_iLastPressTick_Recorded_KS_2[2];
191 | int g_iLastPressTick_Recorded_KS_3[2];
192 |
193 | int g_iKeyPressesThisStrafe[2];
194 |
195 | //int g_iLastReleaseTick[4][2];
196 | int g_iLastReleaseTick_0[2];
197 | int g_iLastReleaseTick_1[2];
198 | int g_iLastReleaseTick_2[2];
199 | int g_iLastReleaseTick_3[2];
200 |
201 | //int g_iLastReleaseTick_Recorded[4][2];
202 | int g_iLastReleaseTick_Recorded_0[2];
203 | int g_iLastReleaseTick_Recorded_1[2];
204 | int g_iLastReleaseTick_Recorded_2[2];
205 | int g_iLastReleaseTick_Recorded_3[2];
206 |
207 | //int g_iLastReleaseTick_Recorded_KS[4][2];
208 | int g_iLastReleaseTick_Recorded_KS_0[2];
209 | int g_iLastReleaseTick_Recorded_KS_1[2];
210 | int g_iLastReleaseTick_Recorded_KS_2[2];
211 | int g_iLastReleaseTick_Recorded_KS_3[2];
212 |
213 | float g_fLastMove[3];
214 | int g_iLastTurnDir;
215 | int g_iLastTurnTick;
216 | int g_iLastTurnTick_Recorded_StartStrafe;
217 | int g_iLastTurnTick_Recorded_EndStrafe;
218 | int g_iLastStopTurnTick;
219 | bool g_bIsTurning;
220 | int g_iReleaseTickAtLastEndStrafe[4];
221 | float g_fLastAngles[3];
222 | int g_InvalidButtonSidemoveCount;
223 | int g_iCmdNum;
224 | float g_fLastPosition[3];
225 | int g_iLastTeleportTick;
226 | float g_fAngleDifference[2];
227 | float g_fLastAngleDifference[2];
228 |
229 | int g_strafeTick;
230 | float g_flRawGain;
231 | bool g_bTouchesWall;
232 | int g_iJump;
233 | int g_iTicksOnGround;
234 | float g_iYawSpeed;
235 | int g_iYawTickCount;
236 | int g_iTimingTickCount;
237 | int g_iStrafesDone;
238 | bool g_bFirstSixJumps;
239 |
240 | int g_iStartStrafe_CurrentFrame;
241 |
242 | //any g_iStartStrafe_Stats[7][MAX_FRAMES];
243 | any g_iStartStrafe_Stats_0[MAX_FRAMES];
244 | any g_iStartStrafe_Stats_1[MAX_FRAMES];
245 | any g_iStartStrafe_Stats_2[MAX_FRAMES];
246 | any g_iStartStrafe_Stats_3[MAX_FRAMES];
247 | any g_iStartStrafe_Stats_4[MAX_FRAMES];
248 | any g_iStartStrafe_Stats_5[MAX_FRAMES];
249 | any g_iStartStrafe_Stats_6[MAX_FRAMES];
250 |
251 | int g_iStartStrafe_LastRecordedTick;
252 | int g_iStartStrafe_LastTickDifference;
253 | bool g_bStartStrafe_IsRecorded[MAX_FRAMES];
254 | int g_iStartStrafe_IdenticalCount;
255 | int g_iEndStrafe_CurrentFrame;
256 |
257 | //any g_iEndStrafe_Stats[7][MAX_FRAMES];
258 | any g_iEndStrafe_Stats_0[MAX_FRAMES];
259 | any g_iEndStrafe_Stats_1[MAX_FRAMES];
260 | any g_iEndStrafe_Stats_2[MAX_FRAMES];
261 | any g_iEndStrafe_Stats_3[MAX_FRAMES];
262 | any g_iEndStrafe_Stats_4[MAX_FRAMES];
263 | any g_iEndStrafe_Stats_5[MAX_FRAMES];
264 | any g_iEndStrafe_Stats_6[MAX_FRAMES];
265 |
266 | int g_iEndStrafe_LastRecordedTick;
267 | int g_iEndStrafe_LastTickDifference;
268 | bool g_bEndStrafe_IsRecorded[MAX_FRAMES];
269 | int g_iEndStrafe_IdenticalCount;
270 | int g_iKeySwitch_CurrentFrame[2];
271 |
272 | //any g_iKeySwitch_Stats[3][2][MAX_FRAMES_KEYSWITCH];
273 | any g_iKeySwitch_Stats_0_0[MAX_FRAMES_KEYSWITCH];
274 | any g_iKeySwitch_Stats_0_1[MAX_FRAMES_KEYSWITCH];
275 | any g_iKeySwitch_Stats_1_0[MAX_FRAMES_KEYSWITCH];
276 | any g_iKeySwitch_Stats_1_1[MAX_FRAMES_KEYSWITCH];
277 | any g_iKeySwitch_Stats_2_0[MAX_FRAMES_KEYSWITCH];
278 | any g_iKeySwitch_Stats_2_1[MAX_FRAMES_KEYSWITCH];
279 |
280 | //bool g_bKeySwitch_IsRecorded[2][MAX_FRAMES_KEYSWITCH];
281 | bool g_bKeySwitch_IsRecorded_0[MAX_FRAMES_KEYSWITCH];
282 | bool g_bKeySwitch_IsRecorded_1[MAX_FRAMES_KEYSWITCH];
283 |
284 | int g_iKeySwitch_LastRecordedTick[2];
285 | bool g_iIllegalTurn[MAX_FRAMES];
286 | int g_iIllegalTurn_CurrentFrame;
287 | bool g_iIllegalTurn_IsTiming[MAX_FRAMES];
288 | int g_iLastIllegalReason;
289 | int g_iIllegalSidemoveCount;
290 | int g_iLastIllegalSidemoveCount;
291 | int g_iLastInvalidButtonCount;
292 | int g_iYawChangeCount;
293 | }
294 |
295 | bool g_bLateLoad;
296 |
297 | Handle g_hTeleport;
298 | bool g_bDhooksLoaded;
299 | #if defined TIMER
300 | bool g_bSendProxyLoaded;
301 | #endif
302 |
303 | Handle g_fwdOnDetection;
304 | Handle g_fwdOnClientBanned;
305 |
306 | ConVar g_hBanLength;
307 | char g_sBanLength[32];
308 | ConVar g_hAntiNull;
309 | ConVar g_hPrintNullLogs;
310 | ConVar g_hAutoban;
311 | bool g_bAdminMode[MAXPLAYERS + 1];
312 | ConVar g_hQueryRate;
313 | ConVar g_hPersistentData;
314 |
315 | char g_aclogfile[PLATFORM_MAX_PATH];
316 | char g_sPlayerIp[MAXPLAYERS + 1][16];
317 |
318 | //shavit
319 |
320 | #if defined TIMER
321 | stylestrings_t g_sStyleStrings[STYLE_LIMIT];
322 | bool g_bIsBeingTimed[MAXPLAYERS +1];
323 | #endif
324 |
325 | ArrayList g_aPersistentData = null;
326 |
327 | public void OnPluginStart()
328 | {
329 | char sDate[64];
330 | FormatTime(sDate, sizeof(sDate), "%y%m%d", GetTime());
331 |
332 | BuildPath(Path_SM, g_aclogfile, PLATFORM_MAX_PATH, "logs/ac_%s.txt", sDate);
333 |
334 | UserMsg umVGUIMenu = GetUserMessageId("VGUIMenu");
335 | if (umVGUIMenu == INVALID_MESSAGE_ID)
336 | SetFailState("UserMsg `umVGUIMenu` not found!");
337 |
338 | g_hBanLength = CreateConVar("bash_banlength", "0", "Ban length for the automated bans", _, true, 0.0);
339 | g_hAutoban = CreateConVar("bash_autoban", "1", "Auto ban players who are detected", _, true, 0.0, true, 1.0);
340 | HookConVarChange(g_hBanLength, OnBanLengthChanged);
341 | g_hAntiNull = CreateConVar("bash_antinull", "0", "Punish for null movement stats", _, true, 0.0, true, 1.0);
342 | g_hPrintNullLogs = CreateConVar("bash_print_null_logs", "0", "Should null logs be print to chat?", _, true, 0.0, true, 1.0);
343 | g_hQueryRate = CreateConVar("bash_query_rate", "0.2", "How often will convars be queried from the client?", _, true, 0.1, true, 2.0);
344 | g_hPersistentData = CreateConVar("bash_persistent_data", "1", "Whether to save and reload strafe stats on a map for players when they disconnect.\nThis is useful to prevent people from frequently rejoining to wipe their strafe stats.", _, true, 0.0, true, 1.0);
345 | AutoExecConfig(true, "bash", "sourcemod");
346 |
347 | g_fwdOnDetection = CreateGlobalForward("Bash_OnDetection", ET_Event, Param_Cell, Param_String);
348 | g_fwdOnClientBanned = CreateGlobalForward("Bash_OnClientBanned", ET_Event, Param_Cell);
349 |
350 | //HookUserMessage(umVGUIMenu, OnVGUIMenu, true);
351 |
352 | g_Engine = GetEngineVersion();
353 | RegAdminCmd("bash2_stats", Bash_Stats, ADMFLAG_RCON, "Check a player's strafe stats");
354 | RegAdminCmd("bash2_admin", Bash_AdminMode, ADMFLAG_RCON, "Opt in/out of admin mode (Prints bash info into chat).");
355 | RegAdminCmd("bash2_test", Bash_Test, ADMFLAG_RCON, "trigger a test message so you can know if webhooks are working :)");
356 |
357 | HookEvent("player_jump", Event_PlayerJump);
358 |
359 | RequestFrame(CheckLag);
360 | }
361 |
362 | public void OnConfigsExecuted()
363 | {
364 | GetConVarString(g_hBanLength, g_sBanLength, sizeof(g_sBanLength));
365 | }
366 |
367 | public void OnBanLengthChanged(ConVar convar, const char[] oldValue, const char[] newValue)
368 | {
369 | strcopy(g_sBanLength, sizeof(g_sBanLength), newValue);
370 | }
371 |
372 | public void OnAllPluginsLoaded()
373 | {
374 | //g_bTasLoaded = LibraryExists("tas");
375 |
376 | if(g_hTeleport == INVALID_HANDLE && LibraryExists("dhooks"))
377 | {
378 | Initialize();
379 | g_bDhooksLoaded = true;
380 | }
381 |
382 | #if defined TIMER
383 | g_bSendProxyLoaded = LibraryExists("sendproxy");
384 | #endif
385 | }
386 |
387 | public void OnLibraryAdded(const char[] name)
388 | {
389 | if(StrEqual(name, "tas"))
390 | {
391 | //g_bTasLoaded = true;
392 | }
393 | else if(StrEqual(name, "dhooks") && g_hTeleport == INVALID_HANDLE)
394 | {
395 | Initialize();
396 | g_bDhooksLoaded = true;
397 | }
398 | #if defined TIMER
399 | else if(StrEqual(name, "sendproxy"))
400 | {
401 | g_bSendProxyLoaded = true;
402 | }
403 | #endif
404 | }
405 |
406 | public void OnLibraryRemoved(const char[] name)
407 | {
408 | if(StrEqual(name, "tas"))
409 | {
410 | //g_bTasLoaded = false;
411 | }
412 | else if(StrEqual(name, "dhooks"))
413 | {
414 | g_bDhooksLoaded = false;
415 | }
416 | #if defined TIMER
417 | else if(StrEqual(name, "sendproxy"))
418 | {
419 | g_bSendProxyLoaded = false;
420 | }
421 | #endif
422 | }
423 |
424 | stock void PrintToAdmins(const char[] msg, any...)
425 | {
426 | char buffer[300];
427 | VFormat(buffer, sizeof(buffer), msg, 2);
428 |
429 | for (int i = 1; i <= MaxClients; i++)
430 | {
431 | if (CheckCommandAccess(i, "bash2_chat_log", ADMFLAG_RCON))
432 | {
433 | if(g_bAdminMode[i]) {
434 | PrintToChat(i, buffer);
435 | }
436 | }
437 | }
438 | }
439 |
440 | void Initialize()
441 | {
442 | Handle hGameData = LoadGameConfigFile("sdktools.games");
443 | if(hGameData == INVALID_HANDLE)
444 | return;
445 |
446 | int iOffset = GameConfGetOffset(hGameData, "Teleport");
447 |
448 | CloseHandle(hGameData);
449 |
450 | if(iOffset == -1)
451 | return;
452 |
453 | g_hTeleport = DHookCreate(iOffset, HookType_Entity, ReturnType_Void, ThisPointer_CBaseEntity, Hook_DHooks_Teleport);
454 |
455 | if(g_hTeleport == INVALID_HANDLE){
456 | PrintToServer("\n!! g_hTeleport -> INVALID_HANDLE !!\n");
457 | return;
458 | }
459 |
460 | DHookAddParam(g_hTeleport, HookParamType_VectorPtr);
461 | DHookAddParam(g_hTeleport, HookParamType_ObjectPtr);
462 | DHookAddParam(g_hTeleport, HookParamType_VectorPtr);
463 |
464 | if(g_Engine == Engine_CSGO)
465 | DHookAddParam(g_hTeleport, HookParamType_Bool); // CS:GO only
466 | }
467 |
468 | public MRESReturn Hook_DHooks_Teleport(int client, Handle hParams)
469 | {
470 | if(!IsClientConnected(client) || IsFakeClient(client) || !IsPlayerAlive(client))
471 | return MRES_Ignored;
472 |
473 | g_iLastTeleportTick[client] = g_iCmdNum[client];
474 |
475 | return MRES_Ignored;
476 | }
477 |
478 | void AutoBanPlayer(int client)
479 | {
480 | if(g_hAutoban.BoolValue && IsClientInGame(client) && !IsClientInKickQueue(client))
481 | {
482 | ServerCommand("sm_ban #%d %s Cheating", GetClientUserId(client), g_sBanLength);
483 |
484 | Call_StartForward(g_fwdOnClientBanned);
485 | Call_PushCell(client);
486 | Call_Finish();
487 | }
488 | }
489 |
490 | float g_fLag_LastCheckTime;
491 | //float g_fLastLagTime;
492 |
493 | public void CheckLag(any data)
494 | {
495 | if(GetEngineTime() - g_fLag_LastCheckTime > 0.02)
496 | {
497 | //g_fLastLagTime = GetEngineTime();
498 | }
499 |
500 | g_fLag_LastCheckTime = GetEngineTime();
501 |
502 | RequestFrame(CheckLag);
503 | }
504 |
505 | void SaveOldLogs()
506 | {
507 | char sDate[64];
508 | FormatTime(sDate, sizeof(sDate), "%y%m%d", GetTime() - (60 * 60 * 24)); // Save logs from day before to new file
509 | char sPath[PLATFORM_MAX_PATH];
510 | BuildPath(Path_SM, sPath, sizeof(sPath), "logs/ac_%s.txt", sDate);
511 |
512 | if(!FileExists(sPath))
513 | {
514 | return;
515 | }
516 |
517 | char sNewPath[PLATFORM_MAX_PATH];
518 | BuildPath(Path_SM, sNewPath, sizeof(sNewPath), "logs/bash.txt");
519 |
520 | File hOld = OpenFile(sPath, "r");
521 | File hNew = OpenFile(sNewPath, "a");
522 |
523 | if(hOld == INVALID_HANDLE)
524 | {
525 | LogError("Couldn't open '%s'", sPath);
526 | return;
527 | }
528 |
529 | if(hNew == INVALID_HANDLE)
530 | {
531 | LogError("Couldn't open '%s'", sNewPath);
532 | return;
533 | }
534 |
535 | char sDateFormatted[64];
536 | FormatTime(sDateFormatted, sizeof(sDateFormatted), "%y-%m-%d", GetTime() - (60 * 60 * 24));
537 | WriteFileLine(hNew, "\n***** ------------ Logs from %s ------------ *****", sDateFormatted);
538 |
539 | char sLine[256];
540 | while(!IsEndOfFile(hOld))
541 | {
542 | if(ReadFileLine(hOld, sLine, sizeof(sLine)))
543 | {
544 | ReplaceString(sLine, sizeof(sLine), "\n", "");
545 | WriteFileLine(hNew, sLine);
546 | }
547 | }
548 |
549 | delete hOld;
550 | delete hNew;
551 | DeleteFile(sPath);
552 | }
553 |
554 | stock bool AnticheatLog(int client, const char[] log, any ...)
555 | {
556 | char buffer[1024];
557 | VFormat(buffer, sizeof(buffer), log, 3);
558 |
559 | Call_StartForward(g_fwdOnDetection);
560 | Call_PushCell(client);
561 | Call_PushString(buffer);
562 | Call_Finish();
563 |
564 | LogToFile(g_aclogfile, "%L<%s> %s", client, g_sPlayerIp[client], buffer);
565 |
566 | if (!g_hPrintNullLogs.BoolValue && StrContains(buffer, "nullPct") != -1)
567 | {
568 | return;
569 | }
570 |
571 | PrintToAdmins("%N %s", client, buffer);
572 | }
573 |
574 | public Action Event_PlayerJump(Event event, const char[] name, bool dontBroadcast)
575 | {
576 | int iclient = GetClientOfUserId(GetEventInt(event, "userid"));
577 |
578 | if(++g_iJump[iclient] == 6)
579 | {
580 | float gainPct = GetGainPercent(iclient);
581 | float yawPct = (float(g_iYawTickCount[iclient]) / float(g_strafeTick[iclient])) * 100.0;
582 | float timingPct = (float(g_iTimingTickCount[iclient]) / float(g_strafeTick[iclient])) * 100.0;
583 |
584 | float spj;
585 | if(g_bFirstSixJumps[iclient])
586 | spj = g_iStrafesDone[iclient] / 5.0;
587 | else
588 | spj = g_iStrafesDone[iclient] / 6.0;
589 |
590 | if(g_strafeTick[iclient] > 300)
591 | {
592 | if(gainPct > 85.0 && yawPct < 60.0)
593 | {
594 | AnticheatLog(iclient, "has %.2f% gains (Yawing %.1f%, Timing: %.1f%, SPJ: %.1f)", gainPct, yawPct, timingPct, spj);
595 |
596 | if(gainPct == 100.0 && timingPct == 100.0)
597 | {
598 | AutoBanPlayer(iclient);
599 | }
600 | }
601 | }
602 |
603 | g_iJump[iclient] = 0;
604 | g_flRawGain[iclient] = 0.0;
605 | g_strafeTick[iclient] = 0;
606 | g_iYawTickCount[iclient] = 0;
607 | g_iTimingTickCount[iclient] = 0;
608 | g_iStrafesDone[iclient] = 0;
609 | g_bFirstSixJumps[iclient] = false;
610 | }
611 | }
612 |
613 | public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
614 | {
615 | RegPluginLibrary("shavit-bash2");
616 |
617 | g_bLateLoad = late;
618 |
619 | return APLRes_Success;
620 | }
621 |
622 | public Action OnVGUIMenu(UserMsg msg_id, Protobuf msg, const int[] players, int playersNum, bool reliable, bool init)
623 | {
624 | int iclient = players[0];
625 |
626 | if(g_bMOTDTest[iclient])
627 | {
628 | GetClientEyeAngles(iclient, g_MOTDTestAngles[iclient]);
629 | CreateTimer(0.1, Timer_MOTD, GetClientUserId(iclient));
630 | }
631 | }
632 |
633 | public Action Timer_MOTD(Handle timer, any data)
634 | {
635 | int iclient = GetClientOfUserId(data);
636 |
637 | if(iclient != 0)
638 | {
639 | float vAng[3];
640 | GetClientEyeAngles(iclient, vAng);
641 | if(FloatAbs(g_MOTDTestAngles[iclient][1] - vAng[1]) > 50.0)
642 | {
643 | PrintToAdmins("%N is strafe hacking", iclient);
644 | }
645 | g_bMOTDTest[iclient] = false;
646 | }
647 | }
648 |
649 | public void OnMapStart()
650 | {
651 | delete g_aPersistentData;
652 | g_aPersistentData = new ArrayList(sizeof(fuck_sourcemod));
653 |
654 | CreateTimer(g_hQueryRate.FloatValue, Timer_UpdateYaw, _, TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
655 |
656 | if(g_bLateLoad)
657 | {
658 | for(int iclient = 1; iclient <= MaxClients; iclient++)
659 | {
660 | if(IsClientInGame(iclient))
661 | {
662 | OnClientConnected(iclient);
663 | OnClientPutInServer(iclient);
664 | }
665 | }
666 | }
667 |
668 | SaveOldLogs();
669 | }
670 |
671 | public Action Timer_UpdateYaw(Handle timer, any data)
672 | {
673 | for(int iclient = 1; iclient <= MaxClients; iclient++)
674 | {
675 | if(IsClientInGame(iclient) && !IsFakeClient(iclient))
676 | {
677 | QueryForCvars(iclient);
678 | }
679 | }
680 | }
681 |
682 | public void OnClientConnected(int client)
683 | {
684 | if(IsFakeClient(client))
685 | return;
686 |
687 | GetClientIP(client, g_sPlayerIp[client], 16);
688 |
689 | for(int idx; idx < MAX_FRAMES; idx++)
690 | {
691 | g_bStartStrafe_IsRecorded[client][idx] = false;
692 | g_bEndStrafe_IsRecorded[client][idx] = false;
693 | }
694 |
695 | for(int idx; idx < MAX_FRAMES_KEYSWITCH; idx++)
696 | {
697 | g_bKeySwitch_IsRecorded[client][BT_Key][idx] = false;
698 | g_bKeySwitch_IsRecorded[client][BT_Move][idx] = false;
699 | }
700 |
701 | g_iStartStrafe_CurrentFrame[client] = 0;
702 | g_iEndStrafe_CurrentFrame[client] = 0;
703 | g_iKeySwitch_CurrentFrame[client][BT_Key] = 0;
704 | g_iKeySwitch_CurrentFrame[client][BT_Move] = 0;
705 | g_bCheckedYet[client] = false;
706 | g_iStartStrafe_LastTickDifference[client] = 0;
707 | g_iEndStrafe_LastTickDifference[client] = 0;
708 | g_iStartStrafe_IdenticalCount[client] = 0;
709 | g_iEndStrafe_IdenticalCount[client] = 0;
710 |
711 | g_iYawSpeed[client] = 210.0;
712 | g_mYaw[client] = 0.0;
713 | g_mYawChangedCount[client] = 0;
714 | g_mYawCheckedCount[client] = 0;
715 | g_mFilter[client] = false;
716 | g_mFilterChangedCount[client] = 0;
717 | g_mFilterCheckedCount[client] = 0;
718 | g_mRawInput[client] = true;
719 | g_mRawInputChangedCount[client] = 0;
720 | g_mRawInputCheckedCount[client] = 0;
721 | g_mCustomAccel[client] = 0;
722 | g_mCustomAccelChangedCount[client] = 0;
723 | g_mCustomAccelCheckedCount[client] = 0;
724 | g_mCustomAccelMax[client] = 0.0;
725 | g_mCustomAccelMaxChangedCount[client] = 0;
726 | g_mCustomAccelMaxCheckedCount[client] = 0;
727 | g_mCustomAccelScale[client] = 0.0;
728 | g_mCustomAccelScaleChangedCount[client] = 0;
729 | g_mCustomAccelScaleCheckedCount[client] = 0;
730 | g_mCustomAccelExponent[client] = 0.0;
731 | g_mCustomAccelExponentChangedCount[client] = 0;
732 | g_mCustomAccelExponentCheckedCount[client] = 0;
733 | g_Sensitivity[client] = 0.0;
734 | g_SensitivityChangedCount[client] = 0;
735 | g_SensitivityCheckedCount[client] = 0;
736 | g_JoySensitivity[client] = 0.0;
737 | g_JoySensitivityChangedCount[client] = 0;
738 | g_JoySensitivityCheckedCount[client] = 0;
739 | g_ZoomSensitivity[client] = 0.0;
740 | g_ZoomSensitivityChangedCount[client] = 0;
741 | g_ZoomSensitivityCheckedCount[client] = 0;
742 |
743 | g_iLastInvalidButtonCount[client] = 0;
744 |
745 | g_JoyStick[client] = false;
746 | g_JoyStickChangedCount[client] = 0;
747 | }
748 |
749 | public void OnClientPostAdminCheck(int client)
750 | {
751 | if (CheckCommandAccess(client, "bash2_chat_log", ADMFLAG_RCON))
752 | {
753 | g_bAdminMode[client] = true;
754 | }
755 |
756 | if(IsFakeClient(client))
757 | return;
758 |
759 | if (!g_hPersistentData.BoolValue)
760 | return;
761 |
762 | int index = g_aPersistentData.FindValue(GetSteamAccountID(client));
763 |
764 | if (index != -1)
765 | {
766 | fuck_sourcemod x;
767 | g_aPersistentData.GetArray(index, x);
768 | g_aPersistentData.Erase(index);
769 |
770 | g_iRealButtons[client] = x.g_iRealButtons;
771 | g_iButtons[client] = x.g_iButtons;
772 | g_iLastButtons[client] = x.g_iLastButtons;
773 |
774 | g_iLastPressTick[client][0] = x.g_iLastPressTick_0;
775 | g_iLastPressTick[client][1] = x.g_iLastPressTick_1;
776 | g_iLastPressTick[client][2] = x.g_iLastPressTick_2;
777 | g_iLastPressTick[client][3] = x.g_iLastPressTick_3;
778 |
779 | g_iLastPressTick_Recorded[client][0] = x.g_iLastPressTick_Recorded_0;
780 | g_iLastPressTick_Recorded[client][1] = x.g_iLastPressTick_Recorded_1;
781 | g_iLastPressTick_Recorded[client][2] = x.g_iLastPressTick_Recorded_2;
782 | g_iLastPressTick_Recorded[client][3] = x.g_iLastPressTick_Recorded_3;
783 |
784 | g_iLastPressTick_Recorded_KS[client][0] = x.g_iLastPressTick_Recorded_KS_0;
785 | g_iLastPressTick_Recorded_KS[client][1] = x.g_iLastPressTick_Recorded_KS_1;
786 | g_iLastPressTick_Recorded_KS[client][3] = x.g_iLastPressTick_Recorded_KS_2;
787 | g_iLastPressTick_Recorded_KS[client][3] = x.g_iLastPressTick_Recorded_KS_3;
788 |
789 | g_iKeyPressesThisStrafe[client] = x.g_iKeyPressesThisStrafe;
790 |
791 | g_iLastReleaseTick[client][0] = x.g_iLastReleaseTick_0;
792 | g_iLastReleaseTick[client][1] = x.g_iLastReleaseTick_1;
793 | g_iLastReleaseTick[client][2] = x.g_iLastReleaseTick_2;
794 | g_iLastReleaseTick[client][3] = x.g_iLastReleaseTick_3;
795 |
796 | g_iLastReleaseTick_Recorded[client][0] = x.g_iLastReleaseTick_Recorded_0;
797 | g_iLastReleaseTick_Recorded[client][1] = x.g_iLastReleaseTick_Recorded_1;
798 | g_iLastReleaseTick_Recorded[client][2] = x.g_iLastReleaseTick_Recorded_2;
799 | g_iLastReleaseTick_Recorded[client][3] = x.g_iLastReleaseTick_Recorded_3;
800 |
801 | g_iLastReleaseTick_Recorded_KS[client][0] = x.g_iLastReleaseTick_Recorded_KS_0;
802 | g_iLastReleaseTick_Recorded_KS[client][1] = x.g_iLastReleaseTick_Recorded_KS_1;
803 | g_iLastReleaseTick_Recorded_KS[client][2] = x.g_iLastReleaseTick_Recorded_KS_2;
804 | g_iLastReleaseTick_Recorded_KS[client][3] = x.g_iLastReleaseTick_Recorded_KS_3;
805 |
806 | g_fLastMove[client] = x.g_fLastMove;
807 | g_iLastTurnDir[client] = x.g_iLastTurnDir;
808 | g_iLastTurnTick[client] = x.g_iLastTurnTick;
809 | g_iLastTurnTick_Recorded_StartStrafe[client] = x.g_iLastTurnTick_Recorded_StartStrafe;
810 | g_iLastTurnTick_Recorded_EndStrafe[client] = x.g_iLastTurnTick_Recorded_EndStrafe;
811 | g_iLastStopTurnTick[client] = x.g_iLastStopTurnTick;
812 | //g_bIsTurning[client] = x.g_bIsTurning;
813 | g_iReleaseTickAtLastEndStrafe[client] = x.g_iReleaseTickAtLastEndStrafe;
814 | g_fLastAngles[client] = x.g_fLastAngles;
815 | g_InvalidButtonSidemoveCount[client] = x.g_InvalidButtonSidemoveCount;
816 | g_iCmdNum[client] = x.g_iCmdNum;
817 | g_fLastPosition[client] = x.g_fLastPosition;
818 | //g_iLastTeleportTick[client] = x.g_iLastTeleportTick;
819 | g_fAngleDifference[client] = x.g_fAngleDifference;
820 | g_fLastAngleDifference[client] = x.g_fLastAngleDifference;
821 |
822 | g_strafeTick[client] = x.g_strafeTick;
823 | g_flRawGain[client] = x.g_flRawGain;
824 | g_bTouchesWall[client] = x.g_bTouchesWall;
825 | g_iJump[client] = x.g_iJump;
826 | g_iTicksOnGround[client] = x.g_iTicksOnGround;
827 | g_iYawSpeed[client] = x.g_iYawSpeed;
828 | g_iYawTickCount[client] = x.g_iYawTickCount;
829 | g_iTimingTickCount[client] = x.g_iTimingTickCount;
830 | g_iStrafesDone[client] = x.g_iStrafesDone;
831 | g_bFirstSixJumps[client] = x.g_bFirstSixJumps;
832 |
833 | g_iStartStrafe_CurrentFrame[client] = x.g_iStartStrafe_CurrentFrame;
834 |
835 | g_iStartStrafe_Stats[client][0] = x.g_iStartStrafe_Stats_0;
836 | g_iStartStrafe_Stats[client][1] = x.g_iStartStrafe_Stats_1;
837 | g_iStartStrafe_Stats[client][2] = x.g_iStartStrafe_Stats_2;
838 | g_iStartStrafe_Stats[client][3] = x.g_iStartStrafe_Stats_3;
839 | g_iStartStrafe_Stats[client][4] = x.g_iStartStrafe_Stats_4;
840 | g_iStartStrafe_Stats[client][5] = x.g_iStartStrafe_Stats_5;
841 | g_iStartStrafe_Stats[client][6] = x.g_iStartStrafe_Stats_6;
842 |
843 | g_iStartStrafe_LastRecordedTick[client] = x.g_iStartStrafe_LastRecordedTick;
844 | g_iStartStrafe_LastTickDifference[client] = x.g_iStartStrafe_LastTickDifference;
845 | g_bStartStrafe_IsRecorded[client] = x.g_bStartStrafe_IsRecorded;
846 | g_iStartStrafe_IdenticalCount[client] = x.g_iStartStrafe_IdenticalCount;
847 |
848 | g_iEndStrafe_CurrentFrame[client] = x.g_iEndStrafe_CurrentFrame;
849 |
850 | g_iEndStrafe_Stats[client][0] = x.g_iEndStrafe_Stats_0;
851 | g_iEndStrafe_Stats[client][1] = x.g_iEndStrafe_Stats_1;
852 | g_iEndStrafe_Stats[client][2] = x.g_iEndStrafe_Stats_2;
853 | g_iEndStrafe_Stats[client][3] = x.g_iEndStrafe_Stats_3;
854 | g_iEndStrafe_Stats[client][4] = x.g_iEndStrafe_Stats_4;
855 | g_iEndStrafe_Stats[client][5] = x.g_iEndStrafe_Stats_5;
856 | g_iEndStrafe_Stats[client][6] = x.g_iEndStrafe_Stats_6;
857 |
858 | g_iEndStrafe_LastRecordedTick[client] = x.g_iEndStrafe_LastRecordedTick;
859 | g_iEndStrafe_LastTickDifference[client] = x.g_iEndStrafe_LastTickDifference;
860 | g_bEndStrafe_IsRecorded[client] = x.g_bEndStrafe_IsRecorded;
861 | g_iEndStrafe_IdenticalCount[client] = x.g_iEndStrafe_IdenticalCount;
862 | g_iKeySwitch_CurrentFrame[client] = x.g_iKeySwitch_CurrentFrame;
863 |
864 | g_iKeySwitch_Stats[client][0][0] = x.g_iKeySwitch_Stats_0_0;
865 | g_iKeySwitch_Stats[client][0][1] = x.g_iKeySwitch_Stats_0_1;
866 | g_iKeySwitch_Stats[client][1][0] = x.g_iKeySwitch_Stats_1_0;
867 | g_iKeySwitch_Stats[client][1][1] = x.g_iKeySwitch_Stats_1_1;
868 | g_iKeySwitch_Stats[client][2][0] = x.g_iKeySwitch_Stats_2_0;
869 | g_iKeySwitch_Stats[client][2][1] = x.g_iKeySwitch_Stats_2_1;
870 |
871 | g_bKeySwitch_IsRecorded[client][0] = x.g_bKeySwitch_IsRecorded_0;
872 | g_bKeySwitch_IsRecorded[client][1] = x.g_bKeySwitch_IsRecorded_1;
873 |
874 | g_iKeySwitch_LastRecordedTick[client] = x.g_iKeySwitch_LastRecordedTick;
875 | g_iIllegalTurn[client] = x.g_iIllegalTurn;
876 | g_iIllegalTurn_CurrentFrame[client] = x.g_iIllegalTurn_CurrentFrame;
877 | g_iIllegalTurn_IsTiming[client] = x.g_iIllegalTurn_IsTiming;
878 | g_iLastIllegalReason[client] = x.g_iLastIllegalReason;
879 | g_iIllegalSidemoveCount[client] = x.g_iIllegalSidemoveCount;
880 | g_iLastIllegalSidemoveCount[client] = x.g_iLastIllegalSidemoveCount;
881 | g_iLastInvalidButtonCount[client] = x.g_iLastInvalidButtonCount;
882 | g_iYawChangeCount[client] = x.g_iYawChangeCount;
883 | }
884 | }
885 |
886 | public void OnClientPutInServer(int client)
887 | {
888 | if(IsFakeClient(client))
889 | return;
890 |
891 | SDKHook(client, SDKHook_Touch, Hook_OnTouch);
892 |
893 | if(g_bDhooksLoaded)
894 | {
895 | DHookEntity(g_hTeleport, false, client);
896 | }
897 |
898 | #if defined TIMER
899 | if(g_bSendProxyLoaded)
900 | {
901 | SendProxy_Hook(client, "m_fFlags", Prop_Int, Hook_GroundFlags);
902 | }
903 | #endif
904 |
905 | QueryForCvars(client);
906 | }
907 |
908 | public void OnClientDisconnect(int client)
909 | {
910 | if (GetSteamAccountID(client) != 0 && g_hPersistentData.BoolValue)
911 | {
912 | fuck_sourcemod x;
913 | x.accountid = GetSteamAccountID(client);
914 |
915 | x.g_iRealButtons = g_iRealButtons[client];
916 | x.g_iButtons = g_iButtons[client];
917 | x.g_iLastButtons = g_iButtons[client];
918 |
919 | x.g_iLastPressTick_0 = g_iLastPressTick[client][0];
920 | x.g_iLastPressTick_1 = g_iLastPressTick[client][1];
921 | x.g_iLastPressTick_2 = g_iLastPressTick[client][2];
922 | x.g_iLastPressTick_3 = g_iLastPressTick[client][3];
923 |
924 | x.g_iLastPressTick_Recorded_0 = g_iLastPressTick_Recorded[client][0];
925 | x.g_iLastPressTick_Recorded_1 = g_iLastPressTick_Recorded[client][1];
926 | x.g_iLastPressTick_Recorded_2 = g_iLastPressTick_Recorded[client][2];
927 | x.g_iLastPressTick_Recorded_3 = g_iLastPressTick_Recorded[client][3];
928 |
929 | x.g_iLastPressTick_Recorded_KS_0 = g_iLastPressTick_Recorded_KS[client][0];
930 | x.g_iLastPressTick_Recorded_KS_1 = g_iLastPressTick_Recorded_KS[client][1];
931 | x.g_iLastPressTick_Recorded_KS_2 = g_iLastPressTick_Recorded_KS[client][2];
932 | x.g_iLastPressTick_Recorded_KS_3 = g_iLastPressTick_Recorded_KS[client][3];
933 |
934 | x.g_iKeyPressesThisStrafe = g_iKeyPressesThisStrafe[client];
935 |
936 | x.g_iLastReleaseTick_0 = g_iLastReleaseTick[client][0];
937 | x.g_iLastReleaseTick_1 = g_iLastReleaseTick[client][1];
938 | x.g_iLastReleaseTick_2 = g_iLastReleaseTick[client][2];
939 | x.g_iLastReleaseTick_3 = g_iLastReleaseTick[client][3];
940 |
941 | x.g_iLastReleaseTick_Recorded_0 = g_iLastReleaseTick_Recorded[client][0];
942 | x.g_iLastReleaseTick_Recorded_1 = g_iLastReleaseTick_Recorded[client][1];
943 | x.g_iLastReleaseTick_Recorded_2 = g_iLastReleaseTick_Recorded[client][2];
944 | x.g_iLastReleaseTick_Recorded_3 = g_iLastReleaseTick_Recorded[client][3];
945 |
946 | x.g_iLastReleaseTick_Recorded_KS_0 = g_iLastReleaseTick_Recorded_KS[client][0];
947 | x.g_iLastReleaseTick_Recorded_KS_1 = g_iLastReleaseTick_Recorded_KS[client][1];
948 | x.g_iLastReleaseTick_Recorded_KS_2 = g_iLastReleaseTick_Recorded_KS[client][2];
949 | x.g_iLastReleaseTick_Recorded_KS_3 = g_iLastReleaseTick_Recorded_KS[client][3];
950 |
951 | x.g_fLastMove = g_fLastMove[client];
952 | x.g_iLastTurnDir = g_iLastTurnDir[client];
953 | x.g_iLastTurnTick = g_iLastTurnTick[client];
954 | x.g_iLastTurnTick_Recorded_StartStrafe = g_iLastTurnTick_Recorded_StartStrafe[client];
955 | x.g_iLastTurnTick_Recorded_EndStrafe = g_iLastTurnTick_Recorded_EndStrafe[client];
956 | x.g_iLastStopTurnTick = g_iLastStopTurnTick[client];
957 | x.g_bIsTurning = g_bIsTurning[client];
958 | x.g_iReleaseTickAtLastEndStrafe = g_iReleaseTickAtLastEndStrafe[client];
959 | x.g_fLastAngles = g_fLastAngles[client];
960 | x.g_InvalidButtonSidemoveCount = g_InvalidButtonSidemoveCount[client];
961 | x.g_iCmdNum = g_iCmdNum[client];
962 | x.g_fLastPosition = g_fLastPosition[client];
963 | x.g_iLastTeleportTick = g_iLastTeleportTick[client];
964 | x.g_fAngleDifference = g_fAngleDifference[client];
965 | x.g_fLastAngleDifference = g_fLastAngleDifference[client];
966 |
967 | x.g_strafeTick = g_strafeTick[client];
968 | x.g_flRawGain = g_flRawGain[client];
969 | x.g_bTouchesWall = g_bTouchesWall[client];
970 | x.g_iJump = g_iJump[client];
971 | x.g_iTicksOnGround = g_iTicksOnGround[client];
972 | x.g_iYawSpeed = g_iYawSpeed[client];
973 | x.g_iYawTickCount = g_iYawTickCount[client];
974 | x.g_iTimingTickCount = g_iTimingTickCount[client];
975 | x.g_iStrafesDone = g_iStrafesDone[client];
976 | x.g_bFirstSixJumps = g_bFirstSixJumps[client];
977 |
978 | x.g_iStartStrafe_CurrentFrame = g_iStartStrafe_CurrentFrame[client];
979 |
980 | x.g_iStartStrafe_Stats_0 = g_iStartStrafe_Stats[client][0];
981 | x.g_iStartStrafe_Stats_1 = g_iStartStrafe_Stats[client][1];
982 | x.g_iStartStrafe_Stats_2 = g_iStartStrafe_Stats[client][2];
983 | x.g_iStartStrafe_Stats_3 = g_iStartStrafe_Stats[client][3];
984 | x.g_iStartStrafe_Stats_4 = g_iStartStrafe_Stats[client][4];
985 | x.g_iStartStrafe_Stats_5 = g_iStartStrafe_Stats[client][5];
986 | x.g_iStartStrafe_Stats_6 = g_iStartStrafe_Stats[client][6];
987 |
988 | x.g_iStartStrafe_LastRecordedTick = g_iStartStrafe_LastRecordedTick[client];
989 | x.g_iStartStrafe_LastTickDifference = g_iStartStrafe_LastTickDifference[client];
990 | x.g_bStartStrafe_IsRecorded = g_bStartStrafe_IsRecorded[client];
991 | x.g_iStartStrafe_IdenticalCount = g_iStartStrafe_IdenticalCount[client];
992 |
993 | x.g_iEndStrafe_CurrentFrame = g_iEndStrafe_CurrentFrame[client];
994 |
995 | x.g_iEndStrafe_Stats_0 = g_iEndStrafe_Stats[client][0];
996 | x.g_iEndStrafe_Stats_1 = g_iEndStrafe_Stats[client][1];
997 | x.g_iEndStrafe_Stats_2 = g_iEndStrafe_Stats[client][2];
998 | x.g_iEndStrafe_Stats_3 = g_iEndStrafe_Stats[client][3];
999 | x.g_iEndStrafe_Stats_4 = g_iEndStrafe_Stats[client][4];
1000 | x.g_iEndStrafe_Stats_5 = g_iEndStrafe_Stats[client][5];
1001 | x.g_iEndStrafe_Stats_6 = g_iEndStrafe_Stats[client][6];
1002 |
1003 | x.g_iEndStrafe_LastRecordedTick = g_iEndStrafe_LastRecordedTick[client];
1004 | x.g_iEndStrafe_LastTickDifference = g_iEndStrafe_LastTickDifference[client];
1005 | x.g_bEndStrafe_IsRecorded = g_bEndStrafe_IsRecorded[client];
1006 | x.g_iEndStrafe_IdenticalCount = g_iEndStrafe_IdenticalCount[client];
1007 | x.g_iKeySwitch_CurrentFrame = g_iKeySwitch_CurrentFrame[client];
1008 |
1009 | x.g_iKeySwitch_Stats_0_0 = g_iKeySwitch_Stats[client][0][0];
1010 | x.g_iKeySwitch_Stats_0_1 = g_iKeySwitch_Stats[client][0][1];
1011 | x.g_iKeySwitch_Stats_1_0 = g_iKeySwitch_Stats[client][1][0];
1012 | x.g_iKeySwitch_Stats_1_1 = g_iKeySwitch_Stats[client][1][1];
1013 | x.g_iKeySwitch_Stats_2_0 = g_iKeySwitch_Stats[client][2][0];
1014 | x.g_iKeySwitch_Stats_2_1 = g_iKeySwitch_Stats[client][2][1];
1015 |
1016 | x.g_bKeySwitch_IsRecorded_0 = g_bKeySwitch_IsRecorded[client][0];
1017 | x.g_bKeySwitch_IsRecorded_1 = g_bKeySwitch_IsRecorded[client][1];
1018 |
1019 | x.g_iKeySwitch_LastRecordedTick = g_iKeySwitch_LastRecordedTick[client];
1020 | x.g_iIllegalTurn = g_iIllegalTurn[client];
1021 | x.g_iIllegalTurn_CurrentFrame = g_iIllegalTurn_CurrentFrame[client];
1022 | x.g_iIllegalTurn_IsTiming = g_iIllegalTurn_IsTiming[client];
1023 | x.g_iLastIllegalReason = g_iLastIllegalReason[client];
1024 | x.g_iIllegalSidemoveCount = g_iIllegalSidemoveCount[client];
1025 | x.g_iLastIllegalSidemoveCount = g_iLastIllegalSidemoveCount[client];
1026 | x.g_iLastInvalidButtonCount = g_iLastInvalidButtonCount[client];
1027 | x.g_iYawChangeCount = g_iYawChangeCount[client];
1028 |
1029 | g_aPersistentData.PushArray(x);
1030 | }
1031 | }
1032 |
1033 | public Action Hook_GroundFlags(int entity, const char[] PropName, int &iValue, int element)
1034 | {
1035 | #if defined TIMER
1036 | int style = Shavit_GetBhopStyle(entity);
1037 | bool autobhop = Shavit_GetStyleSettingBool(style, "autobhop");
1038 |
1039 | if(autobhop == false)
1040 | iValue &= ~FL_ONGROUND;
1041 |
1042 | return Plugin_Changed;
1043 | #endif
1044 | }
1045 |
1046 |
1047 | void QueryForCvars(int client)
1048 | {
1049 | if(g_Engine == Engine_CSS) QueryClientConVar(client, "cl_yawspeed", OnYawSpeedRetrieved);
1050 | QueryClientConVar(client, "m_yaw", OnYawRetrieved);
1051 | QueryClientConVar(client, "m_filter", OnFilterRetrieved);
1052 | QueryClientConVar(client, "m_customaccel", OnCustomAccelRetrieved);
1053 | QueryClientConVar(client, "m_customaccel_max", OnCustomAccelMaxRetrieved);
1054 | QueryClientConVar(client, "m_customaccel_scale", OnCustomAccelScaleRetrieved);
1055 | QueryClientConVar(client, "m_customaccel_exponent", OnCustomAccelExRetrieved);
1056 | QueryClientConVar(client, "m_rawinput", OnRawInputRetrieved);
1057 | QueryClientConVar(client, "sensitivity", OnSensitivityRetrieved);
1058 | QueryClientConVar(client, "joy_yawsensitivity", OnYawSensitivityRetrieved);
1059 | QueryClientConVar(client, "joystick", OnJoystickRetrieved);
1060 | if(g_Engine == Engine_CSGO) QueryClientConVar(client, "zoom_sensitivity_ratio_mouse", OnZoomSensitivityRetrieved);
1061 | if(g_Engine == Engine_CSS) QueryClientConVar(client, "zoom_sensitivity_ratio", OnZoomSensitivityRetrieved);
1062 | }
1063 |
1064 | public void OnYawSpeedRetrieved(QueryCookie cookie, int client, ConVarQueryResult result, const char[] cvarName, const char[] cvarValue)
1065 | {
1066 | g_iYawSpeed[client] = StringToFloat(cvarValue);
1067 |
1068 | if(g_iYawSpeed[client] < 0)
1069 | {
1070 | KickClient(client, "cl_yawspeed cannot be negative");
1071 | }
1072 | }
1073 |
1074 | public void OnYawRetrieved(QueryCookie cookie, int client, ConVarQueryResult result, const char[] cvarName, const char[] cvarValue)
1075 | {
1076 | float mYaw = StringToFloat(cvarValue);
1077 | if(mYaw != g_mYaw[client])
1078 | {
1079 | g_mYaw[client] = mYaw;
1080 | g_mYawChangedCount[client]++;
1081 |
1082 | if(g_mYawChangedCount[client] > 1)
1083 | {
1084 | PrintToAdmins("%N changed their m_yaw ConVar to %.2f", client, mYaw);
1085 | //AnticheatLog("%L changed their m_yaw ConVar to %.2f", client, mYaw);
1086 | }
1087 | }
1088 |
1089 | g_mYawCheckedCount[client]++;
1090 | }
1091 |
1092 | public void OnFilterRetrieved(QueryCookie cookie, int client, ConVarQueryResult result, const char[] cvarName, const char[] cvarValue)
1093 | {
1094 | bool mFilter = (0.0 <= StringToFloat(cvarValue) < 1.0)?false:true;
1095 | if(mFilter != g_mFilter[client])
1096 | {
1097 | g_mFilterChangedCount[client]++;
1098 | g_mFilter[client] = mFilter;
1099 |
1100 | if(g_mFilterChangedCount[client] > 1)
1101 | {
1102 | PrintToAdmins("%N changed their m_filter ConVar to %d", client, mFilter);
1103 | //AnticheatLog("%L changed their m_filter ConVar to %d", client, mFilter);
1104 | }
1105 | }
1106 |
1107 | g_mFilterCheckedCount[client]++;
1108 | }
1109 |
1110 | public void OnCustomAccelRetrieved(QueryCookie cookie, int client, ConVarQueryResult result, const char[] cvarName, const char[] cvarValue)
1111 | {
1112 | int mCustomAccel = StringToInt(cvarValue);
1113 |
1114 | if(mCustomAccel != g_mCustomAccel[client])
1115 | {
1116 | g_mCustomAccel[client] = mCustomAccel;
1117 | g_mCustomAccelChangedCount[client]++;
1118 |
1119 | if(g_mCustomAccelChangedCount[client] > 1)
1120 | {
1121 | PrintToAdmins("%N changed their m_customaccel ConVar to %d", client, mCustomAccel);
1122 | //AnticheatLog("%L changed their m_customaccel ConVar to %d", client, mCustomAccel);
1123 | }
1124 | }
1125 |
1126 | g_mCustomAccelCheckedCount[client]++;
1127 | }
1128 |
1129 | public void OnCustomAccelMaxRetrieved(QueryCookie cookie, int client, ConVarQueryResult result, const char[] cvarName, const char[] cvarValue)
1130 | {
1131 | float mCustomAccelMax = StringToFloat(cvarValue);
1132 |
1133 | if(mCustomAccelMax != g_mCustomAccelMax[client])
1134 | {
1135 | g_mCustomAccelMax[client] = mCustomAccelMax;
1136 | g_mCustomAccelMaxChangedCount[client]++;
1137 |
1138 | if(g_mCustomAccelMaxChangedCount[client] > 1)
1139 | {
1140 | PrintToAdmins("%N changed their m_customaccel_max ConVar to %f", client, mCustomAccelMax);
1141 | }
1142 | }
1143 |
1144 | g_mCustomAccelMaxCheckedCount[client]++;
1145 | }
1146 |
1147 | public void OnCustomAccelScaleRetrieved(QueryCookie cookie, int client, ConVarQueryResult result, const char[] cvarName, const char[] cvarValue)
1148 | {
1149 | float mCustomAccelScale = StringToFloat(cvarValue);
1150 |
1151 | if(mCustomAccelScale != g_mCustomAccelScale[client])
1152 | {
1153 | g_mCustomAccelScale[client] = mCustomAccelScale;
1154 | g_mCustomAccelScaleChangedCount[client]++;
1155 |
1156 | if(g_mCustomAccelScaleChangedCount[client] > 1)
1157 | {
1158 | PrintToAdmins("%N changed their m_customaccel_scale ConVar to %f", client, mCustomAccelScale);
1159 | //AnticheatLog("%L changed their m_customaccel ConVar to %d", client, mCustomAccel);
1160 | }
1161 | }
1162 |
1163 | g_mCustomAccelScaleCheckedCount[client]++;
1164 | }
1165 |
1166 | public void OnCustomAccelExRetrieved(QueryCookie cookie, int client, ConVarQueryResult result, const char[] cvarName, const char[] cvarValue)
1167 | {
1168 | float mCustomAccelExponent = StringToFloat(cvarValue);
1169 |
1170 | if(mCustomAccelExponent != g_mCustomAccelExponent[client])
1171 | {
1172 | g_mCustomAccelExponent[client] = mCustomAccelExponent;
1173 | g_mCustomAccelExponentChangedCount[client]++;
1174 |
1175 | if(g_mCustomAccelExponentChangedCount[client] > 1)
1176 | {
1177 | PrintToAdmins("%N changed their m_customaccel_exponent ConVar to %f", client, mCustomAccelExponent);
1178 | //AnticheatLog("%L changed their m_customaccel ConVar to %d", client, mCustomAccel);
1179 | }
1180 | }
1181 |
1182 | g_mCustomAccelExponentCheckedCount[client]++;
1183 | }
1184 |
1185 | public void OnRawInputRetrieved(QueryCookie cookie, int client, ConVarQueryResult result, const char[] cvarName, const char[] cvarValue)
1186 | {
1187 | bool mRawInput = (0.0 <= StringToFloat(cvarValue) < 1.0)?false:true;
1188 | if(mRawInput != g_mRawInput[client])
1189 | {
1190 | g_mRawInputChangedCount[client]++;
1191 | g_mRawInput[client] = mRawInput;
1192 |
1193 | if(g_mRawInputChangedCount[client] > 1)
1194 | {
1195 | PrintToAdmins("%N changed their m_rawinput ConVar to %d", client, mRawInput);
1196 | //AnticheatLog(client, "%L changed their m_rawinput ConVar to %d", mRawInput);
1197 | }
1198 | }
1199 |
1200 | g_mRawInputCheckedCount[client]++;
1201 | }
1202 |
1203 | public void OnSensitivityRetrieved(QueryCookie cookie, int client, ConVarQueryResult result, const char[] cvarName, const char[] cvarValue)
1204 | {
1205 | float sensitivity = StringToFloat(cvarValue);
1206 | if(sensitivity != g_Sensitivity[client])
1207 | {
1208 | g_Sensitivity[client] = sensitivity;
1209 | g_SensitivityChangedCount[client]++;
1210 |
1211 | if(g_SensitivityChangedCount[client] > 1)
1212 | {
1213 | PrintToAdmins("%N changed their sensitivity ConVar to %.2f", client, sensitivity);
1214 | //AnticheatLog("%L changed their sensitivity ConVar to %.2f", client, sensitivity);
1215 | }
1216 | }
1217 |
1218 | g_SensitivityCheckedCount[client]++;
1219 | }
1220 |
1221 | public void OnYawSensitivityRetrieved(QueryCookie cookie, int client, ConVarQueryResult result, const char[] cvarName, const char[] cvarValue)
1222 | {
1223 | float sensitivity = StringToFloat(cvarValue);
1224 | if(sensitivity != g_JoySensitivity[client])
1225 | {
1226 | g_JoySensitivity[client] = sensitivity;
1227 | g_JoySensitivityChangedCount[client]++;
1228 |
1229 | if(g_JoySensitivityChangedCount[client] > 1)
1230 | {
1231 | PrintToAdmins("%N changed their joy_yawsensitivity ConVar to %.2f", client, sensitivity);
1232 | //AnticheatLog("%L changed their joy_yawsensitivity ConVar to %.2f", client, sensitivity);
1233 | }
1234 | }
1235 |
1236 | g_JoySensitivityCheckedCount[client]++;
1237 | }
1238 |
1239 | public void OnZoomSensitivityRetrieved(QueryCookie cookie, int client, ConVarQueryResult result, const char[] cvarName, const char[] cvarValue)
1240 | {
1241 | float sensitivity = StringToFloat(cvarValue);
1242 | if(sensitivity != g_ZoomSensitivity[client])
1243 | {
1244 | g_ZoomSensitivity[client] = sensitivity;
1245 | g_ZoomSensitivityChangedCount[client]++;
1246 |
1247 | if(g_ZoomSensitivityChangedCount[client] > 1)
1248 | {
1249 | PrintToAdmins("%N changed their %s ConVar to %.2f", client, cvarName, sensitivity);
1250 | //AnticheatLog("%L changed their joy_yawsensitivity ConVar to %.2f", client, sensitivity);
1251 | }
1252 | }
1253 |
1254 | g_ZoomSensitivityCheckedCount[client]++;
1255 | }
1256 |
1257 | public void OnJoystickRetrieved(QueryCookie cookie, int client, ConVarQueryResult result, const char[] cvarName, const char[] cvarValue)
1258 | {
1259 | bool joyStick = (0.0 <= StringToFloat(cvarValue) < 1.0)?false:true;
1260 | if(joyStick != g_JoyStick[client])
1261 | {
1262 | g_JoyStickChangedCount[client]++;
1263 | g_JoyStick[client] = joyStick;
1264 |
1265 | if(g_JoyStickChangedCount[client] > 1)
1266 | {
1267 | PrintToAdmins("%N changed their joystick ConVar to %d", client, joyStick);
1268 | //AnticheatLog("%L changed their joystick ConVar to %d", client, joyStick);
1269 | }
1270 | }
1271 |
1272 | g_JoyStickCheckedCount[client]++;
1273 | }
1274 |
1275 |
1276 | public Action Hook_OnTouch(int client, int entity)
1277 | {
1278 | if(entity == 0)
1279 | {
1280 | g_bTouchesWall[client] = true;
1281 | }
1282 |
1283 | char sClassname[64];
1284 | GetEntityClassname(entity, sClassname, sizeof(sClassname));
1285 | if(StrEqual(sClassname, "func_rotating"))
1286 | {
1287 | g_bTouchesFuncRotating[client] = true;
1288 | }
1289 |
1290 | }
1291 |
1292 | public Action Bash_Stats(int client, int args)
1293 | {
1294 | if(args == 0)
1295 | {
1296 | int target;
1297 | if(IsPlayerAlive(client))
1298 | {
1299 | target = client;
1300 | }
1301 | else
1302 | {
1303 | target = GetEntPropEnt(client, Prop_Send, "m_hObserverTarget");
1304 | }
1305 |
1306 | if(0 < target <= MaxClients)
1307 | {
1308 | ShowBashStats(client, GetClientUserId(target));
1309 | }
1310 | }
1311 | else
1312 | {
1313 | char sArg[MAX_NAME_LENGTH];
1314 | GetCmdArgString(sArg, MAX_NAME_LENGTH);
1315 |
1316 | if(sArg[0] == '#')
1317 | {
1318 | ReplaceString(sArg, MAX_NAME_LENGTH, "#", "", true);
1319 | int target = GetClientOfUserId(StringToInt(sArg, 10));
1320 | if(target)
1321 | {
1322 | ShowBashStats(client, GetClientUserId(target));
1323 | }
1324 | else
1325 | {
1326 | ReplyToCommand(client, "[BASH] No player with userid '%s'.", sArg);
1327 | }
1328 | }
1329 |
1330 | char sName[MAX_NAME_LENGTH];
1331 | bool bFoundTarget;
1332 | for(int target = 1; target <= MaxClients; target++)
1333 | {
1334 | if(IsClientInGame(target))
1335 | {
1336 | GetClientName(target, sName, MAX_NAME_LENGTH);
1337 | if(StrContains(sName, sArg, false) != -1)
1338 | {
1339 | bFoundTarget = true;
1340 | ShowBashStats(client, GetClientUserId(target));
1341 | }
1342 | }
1343 | }
1344 |
1345 | if(!bFoundTarget)
1346 | {
1347 | ReplyToCommand(client, "[BASH] No player found with '%s' in their name.", sArg);
1348 | }
1349 | }
1350 |
1351 | return Plugin_Handled;
1352 | }
1353 |
1354 | public Action Bash_AdminMode(int client, int args)
1355 | {
1356 | if(g_bAdminMode[client])
1357 | {
1358 | g_bAdminMode[client] = !g_bAdminMode[client];
1359 | ReplyToCommand(client, "[BASH] You are no longer in admin mode.");
1360 | } else {
1361 | g_bAdminMode[client] = !g_bAdminMode[client]
1362 | ReplyToCommand(client, "[BASH] You are now in admin mode.");
1363 | }
1364 | return Plugin_Handled;
1365 | }
1366 |
1367 | public Action Bash_Test(int client, int args)
1368 | {
1369 | if (client == 0)
1370 | {
1371 | for (int i = 1; i<= MaxClients; i++)
1372 | {
1373 | if (IsClientConnected(i) && IsClientInGame(i))
1374 | {
1375 | client = i;
1376 | break;
1377 | }
1378 | }
1379 | }
1380 |
1381 | if (client == 0)
1382 | {
1383 | PrintToServer("No client to use for test log... :|");
1384 | }
1385 | else
1386 | {
1387 | AnticheatLog(client, "bash2_test log. plz ignore :)");
1388 | }
1389 |
1390 | return Plugin_Handled;
1391 | }
1392 |
1393 | void ShowBashStats(int client, int userid)
1394 | {
1395 | int target = GetClientOfUserId(userid);
1396 | if(target == 0)
1397 | {
1398 | PrintToChat(client, "[BASH] Selected player no longer ingame.");
1399 | return;
1400 | }
1401 |
1402 | g_iTarget[client] = userid;
1403 | Menu menu = new Menu(BashStats_MainMenu);
1404 | char sName[MAX_NAME_LENGTH];
1405 | GetClientName(target, sName, sizeof(sName));
1406 | menu.SetTitle("[BASH] - Select stats for %N", target);
1407 |
1408 | menu.AddItem("start", "Start Strafe (Original)");
1409 | menu.AddItem("end", "End Strafe");
1410 | menu.AddItem("keys", "Key Switch");
1411 |
1412 | char sGain[32];
1413 | FormatEx(sGain, 32, "Current gains: %.2f", GetGainPercent(target));
1414 | menu.AddItem("gain", sGain);
1415 | /*if(IsBlacky(client))
1416 | {
1417 | menu.AddItem("man1", "Manual Test (MOTD)");
1418 | menu.AddItem("man2", "Manual Test (Angle)");
1419 | menu.AddItem("flags", "Player flags", ITEMDRAW_DISABLED);
1420 | }*/
1421 |
1422 | menu.Display(client, MENU_TIME_FOREVER);
1423 | }
1424 |
1425 | public int BashStats_MainMenu(Menu menu, MenuAction action, int param1, int param2)
1426 | {
1427 | if(action == MenuAction_Select)
1428 | {
1429 | char sInfo[32];
1430 | menu.GetItem(param2, sInfo, sizeof(sInfo));
1431 |
1432 | if(StrEqual(sInfo, "start"))
1433 | {
1434 | ShowBashStats_StartStrafes(param1);
1435 | }
1436 | else if(StrEqual(sInfo, "end"))
1437 | {
1438 | ShowBashStats_EndStrafes(param1);
1439 | }
1440 | else if(StrEqual(sInfo, "keys"))
1441 | {
1442 | ShowBashStats_KeySwitches(param1);
1443 | }
1444 | else if(StrEqual(sInfo, "gain"))
1445 | {
1446 | ShowBashStats(param1, g_iTarget[param1]);
1447 | }
1448 | else if(StrEqual(sInfo, "man1"))
1449 | {
1450 | PerformMOTDTest(param1);
1451 | }
1452 | else if(StrEqual(sInfo, "man2"))
1453 | {
1454 | PerformAngleTest(param1);
1455 | }
1456 | else if(StrEqual(sInfo, "flags"))
1457 | {
1458 |
1459 | }
1460 | }
1461 |
1462 | if (action & MenuAction_End)
1463 | {
1464 | delete menu;
1465 | }
1466 | }
1467 |
1468 | void PerformMOTDTest(int client)
1469 | {
1470 | int target = GetClientOfUserId(g_iTarget[client]);
1471 | if(target == 0)
1472 | {
1473 | return;
1474 | }
1475 |
1476 | //void ShowVGUIPanel(int client, const char[] name, Handle Kv, bool show)
1477 | //MotdChanger_SendClientMotd(client, "Welcome", "text", "Welcome to KawaiiClan!");
1478 | g_bMOTDTest[target] = true;
1479 | if(g_Engine == Engine_CSGO)
1480 | {
1481 | ShowMOTDPanel(target, "Welcome", "http://kawaiiclan.com/welcome.html", MOTDPANEL_TYPE_URL);
1482 | }
1483 | else if(g_Engine == Engine_CSS)
1484 | {
1485 | ShowMOTDPanel(target, "Welcome", "http://kawaiiclan.com/", MOTDPANEL_TYPE_URL);
1486 | }
1487 | }
1488 |
1489 | stock void PerformAngleTest(int client)
1490 | {
1491 |
1492 | }
1493 |
1494 | void ShowBashStats_StartStrafes(int client)
1495 | {
1496 | int target = GetClientOfUserId(g_iTarget[client]);
1497 | if(target == 0)
1498 | {
1499 | PrintToChat(client, "[BASH] Selected player no longer ingame.");
1500 | return;
1501 | }
1502 |
1503 | int array[MAX_FRAMES];
1504 | int buttons[4];
1505 | int size;
1506 | for(int idx; idx < MAX_FRAMES; idx++)
1507 | {
1508 | if(g_bStartStrafe_IsRecorded[target][idx] == true)
1509 | {
1510 | array[idx] = g_iStartStrafe_Stats[target][StrafeData_Difference][idx];
1511 | buttons[g_iStartStrafe_Stats[target][StrafeData_Button][idx]]++;
1512 | size++;
1513 | }
1514 | }
1515 |
1516 | if(size == 0)
1517 | {
1518 | PrintToChat(client, "[BASH] Player '%N' has no start strafe stats.", target);
1519 | }
1520 | float startStrafeMean = GetAverage(array, size);
1521 | float startStrafeSD = StandardDeviation(array, size, startStrafeMean);
1522 |
1523 | Menu menu = new Menu(BashStats_StartStrafesMenu);
1524 | menu.SetTitle("[BASH] Start Strafe stats for %N\nAverage: %.2f | Deviation: %.2f\nA: %d, D: %d, W: %d, S: %d\n ",
1525 | target, startStrafeMean, startStrafeSD,
1526 | buttons[2], buttons[3], buttons[0], buttons[1]);
1527 |
1528 | char sDisplay[128];
1529 | for(int idx; idx < size; idx++)
1530 | {
1531 | Format(sDisplay, sizeof(sDisplay), "%s%d ", sDisplay, array[idx]);
1532 |
1533 | if((idx + 1) % 10 == 0 || size - idx == 1)
1534 | {
1535 | menu.AddItem("", sDisplay, ITEMDRAW_DISABLED);
1536 | FormatEx(sDisplay, sizeof(sDisplay), "");
1537 | }
1538 | }
1539 |
1540 | menu.ExitBackButton = true;
1541 | menu.Display(client, MENU_TIME_FOREVER);
1542 | }
1543 |
1544 | public int BashStats_StartStrafesMenu(Menu menu, MenuAction action, int param1, int param2)
1545 | {
1546 | /*
1547 | if(action == MenuAction_Select)
1548 | {
1549 |
1550 | }
1551 | */
1552 | if(action == MenuAction_Cancel)
1553 | {
1554 | if(param2 == MenuCancel_ExitBack)
1555 | ShowBashStats(param1, g_iTarget[param1]);
1556 | }
1557 |
1558 | if (action & MenuAction_End)
1559 | {
1560 | delete menu;
1561 | }
1562 | }
1563 |
1564 | void ShowBashStats_EndStrafes(int client)
1565 | {
1566 | int target = GetClientOfUserId(g_iTarget[client]);
1567 | if(target == 0)
1568 | {
1569 | PrintToChat(client, "[BASH] Selected player no longer ingame.");
1570 | return;
1571 | }
1572 |
1573 | int array[MAX_FRAMES];
1574 | int buttons[4];
1575 | int size;
1576 | for(int idx; idx < MAX_FRAMES; idx++)
1577 | {
1578 | if(g_bEndStrafe_IsRecorded[target][idx] == true)
1579 | {
1580 | array[idx] = g_iEndStrafe_Stats[target][StrafeData_Difference][idx];
1581 | buttons[g_iEndStrafe_Stats[target][StrafeData_Button][idx]]++;
1582 | size++;
1583 | }
1584 | }
1585 |
1586 | if(size == 0)
1587 | {
1588 | PrintToChat(client, "[BASH] Player '%N' has no end strafe stats.", target);
1589 | }
1590 |
1591 | float mean = GetAverage(array, size);
1592 | float sd = StandardDeviation(array, size, mean);
1593 |
1594 | Menu menu = new Menu(BashStats_EndStrafesMenu);
1595 | menu.SetTitle("[BASH] End Strafe stats for %N\nAverage: %.2f | Deviation: %.2f\nA: %d, D: %d, W: %d, S: %d\n ",
1596 | target, mean, sd,
1597 | buttons[2], buttons[3], buttons[0], buttons[1]);
1598 |
1599 | char sDisplay[128];
1600 | for(int idx; idx < size; idx++)
1601 | {
1602 | Format(sDisplay, sizeof(sDisplay), "%s%d ", sDisplay, array[idx]);
1603 |
1604 | if((idx + 1) % 10 == 0 || (size - idx == 1))
1605 | {
1606 | menu.AddItem("", sDisplay, ITEMDRAW_DISABLED);
1607 | FormatEx(sDisplay, sizeof(sDisplay), "");
1608 | }
1609 | }
1610 |
1611 | menu.ExitBackButton = true;
1612 | menu.Display(client, MENU_TIME_FOREVER);
1613 | }
1614 |
1615 | public int BashStats_EndStrafesMenu(Menu menu, MenuAction action, int param1, int param2)
1616 | {
1617 | /*
1618 | if(action == MenuAction_Select)
1619 | {
1620 |
1621 | }
1622 | */
1623 | if(action == MenuAction_Cancel)
1624 | {
1625 | if(param2 == MenuCancel_ExitBack)
1626 | ShowBashStats(param1, g_iTarget[param1]);
1627 | }
1628 |
1629 | if (action & MenuAction_End)
1630 | {
1631 | delete menu;
1632 | }
1633 | }
1634 |
1635 | void ShowBashStats_KeySwitches(int client)
1636 | {
1637 | int target = GetClientOfUserId(g_iTarget[client]);
1638 | if(target == 0)
1639 | {
1640 | PrintToChat(client, "[BASH] Selected player no longer ingame.");
1641 | return;
1642 | }
1643 |
1644 | Menu menu = new Menu(BashStats_KeySwitchesMenu);
1645 | menu.SetTitle("[BASH] Select key switch type");
1646 | menu.AddItem("move", "Movement");
1647 | menu.AddItem("key", "Buttons");
1648 | menu.ExitBackButton = true;
1649 | menu.Display(client, MENU_TIME_FOREVER);
1650 | }
1651 |
1652 | public int BashStats_KeySwitchesMenu(Menu menu, MenuAction action, int param1, int param2)
1653 | {
1654 | if(action & MenuAction_Select)
1655 | {
1656 | char sInfo[32];
1657 | menu.GetItem(param2, sInfo, sizeof(sInfo));
1658 |
1659 | if(StrEqual(sInfo, "move"))
1660 | {
1661 | ShowBashStats_KeySwitches_Move(param1);
1662 | }
1663 | else if(StrEqual(sInfo, "key"))
1664 | {
1665 | ShowBashStats_KeySwitches_Keys(param1);
1666 | }
1667 | }
1668 | if(action == MenuAction_Cancel)
1669 | {
1670 | if(param2 == MenuCancel_ExitBack)
1671 | ShowBashStats(param1, g_iTarget[param1]);
1672 | }
1673 |
1674 | if (action & MenuAction_End)
1675 | {
1676 | delete menu;
1677 | }
1678 | }
1679 |
1680 | void ShowBashStats_KeySwitches_Move(int client)
1681 | {
1682 | int target = GetClientOfUserId(g_iTarget[client]);
1683 | if(target == 0)
1684 | {
1685 | PrintToChat(client, "[BASH] Selected player no longer ingame.");
1686 | return;
1687 | }
1688 |
1689 | int array[MAX_FRAMES_KEYSWITCH];
1690 | int size;
1691 | for(int idx; idx < MAX_FRAMES_KEYSWITCH; idx++)
1692 | {
1693 | if(g_bKeySwitch_IsRecorded[target][BT_Move][idx] == true)
1694 | {
1695 | array[idx] = g_iKeySwitch_Stats[target][KeySwitchData_Difference][BT_Move][idx];
1696 | size++;
1697 | }
1698 | }
1699 | float mean = GetAverage(array, size);
1700 | float sd = StandardDeviation(array, size, mean);
1701 |
1702 | Menu menu = new Menu(BashStats_KeySwitchesMenu_Move);
1703 | menu.SetTitle("[BASH] Sidemove Switch stats for %N\nAverage: %.2f | Deviation: %.2f\n ", target, mean, sd);
1704 |
1705 | char sDisplay[128];
1706 | for(int idx; idx < size; idx++)
1707 | {
1708 | Format(sDisplay, sizeof(sDisplay), "%s%d ", sDisplay, array[idx]);
1709 |
1710 | if((idx + 1) % 10 == 0 || (size - idx == 1))
1711 | {
1712 | menu.AddItem("", sDisplay, ITEMDRAW_DISABLED);
1713 | FormatEx(sDisplay, sizeof(sDisplay), "");
1714 | }
1715 | }
1716 |
1717 | menu.ExitBackButton = true;
1718 | menu.Display(client, MENU_TIME_FOREVER);
1719 | }
1720 |
1721 | void ShowBashStats_KeySwitches_Keys(int client)
1722 | {
1723 | int target = GetClientOfUserId(g_iTarget[client]);
1724 | if(target == 0)
1725 | {
1726 | PrintToChat(client, "[BASH] Selected player no longer ingame.");
1727 | return;
1728 | }
1729 |
1730 | int array[MAX_FRAMES_KEYSWITCH];
1731 | int size, positiveCount;
1732 | for(int idx; idx < MAX_FRAMES_KEYSWITCH; idx++)
1733 | {
1734 | if(g_bKeySwitch_IsRecorded[target][BT_Key][idx] == true)
1735 | {
1736 | array[idx] = g_iKeySwitch_Stats[target][KeySwitchData_Difference][BT_Key][idx];
1737 | size++;
1738 |
1739 | if(g_iKeySwitch_Stats[target][KeySwitchData_Difference][BT_Key][idx] >= 0)
1740 | {
1741 | positiveCount++;
1742 | }
1743 | }
1744 | }
1745 |
1746 | float mean = GetAverage(array, size);
1747 | float sd = StandardDeviation(array, size, mean);
1748 | float pctPositive = float(positiveCount) / float(size);
1749 | Menu menu = new Menu(BashStats_KeySwitchesMenu_Move);
1750 | menu.SetTitle("[BASH] Key Switch stats for %N\nAverage: %.2f | Deviation: %.2f | Positive: %.2f\n ", target, mean, sd, pctPositive);
1751 |
1752 | char sDisplay[128];
1753 | for(int idx; idx < size; idx++)
1754 | {
1755 | Format(sDisplay, sizeof(sDisplay), "%s%d ", sDisplay, array[idx]);
1756 |
1757 | if((idx + 1) % 10 == 0 || (size - idx == 1))
1758 | {
1759 | menu.AddItem("", sDisplay, ITEMDRAW_DISABLED);
1760 | FormatEx(sDisplay, sizeof(sDisplay), "");
1761 | }
1762 | }
1763 |
1764 | menu.ExitBackButton = true;
1765 | menu.Display(client, MENU_TIME_FOREVER);
1766 | }
1767 |
1768 | public int BashStats_KeySwitchesMenu_Move(Menu menu, MenuAction action, int param1, int param2)
1769 | {
1770 | /*
1771 | if(action == MenuAction_Select)
1772 | {
1773 |
1774 | }
1775 | */
1776 | if(action == MenuAction_Cancel)
1777 | {
1778 | if(param2 == MenuCancel_ExitBack)
1779 | ShowBashStats_KeySwitches(param1);
1780 | }
1781 |
1782 | if (action & MenuAction_End)
1783 | {
1784 | delete menu;
1785 | }
1786 | }
1787 |
1788 | float StandardDeviation(int[] array, int size, float mean, bool countZeroes = true)
1789 | {
1790 | float sd;
1791 |
1792 | for(int idx; idx < size; idx++)
1793 | {
1794 | if(countZeroes || array[idx] != 0)
1795 | {
1796 | sd += Pow(float(array[idx]) - mean, 2.0);
1797 | }
1798 | }
1799 |
1800 | return SquareRoot(sd/size);
1801 | }
1802 |
1803 | float GetAverage(int[] array, int size, bool countZeroes = true)
1804 | {
1805 | int total;
1806 |
1807 | for(int idx; idx < size; idx++)
1808 | {
1809 | if(countZeroes || array[idx] != 0)
1810 | {
1811 | total += array[idx];
1812 | }
1813 |
1814 | }
1815 |
1816 | return float(total) / float(size);
1817 | }
1818 |
1819 | int g_iRunCmdsPerSecond[MAXPLAYERS + 1];
1820 | int g_iBadSeconds[MAXPLAYERS + 1];
1821 | float g_fLastCheckTime[MAXPLAYERS + 1];
1822 | MoveType g_mLastMoveType[MAXPLAYERS + 1];
1823 |
1824 | 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])
1825 | {
1826 | if(!IsFakeClient(client) && IsPlayerAlive(client))
1827 | {
1828 | g_iRealButtons[client] = buttons;
1829 | // Update all information this tick
1830 | bool bCheck = true;
1831 |
1832 | #if defined TIMER
1833 |
1834 | g_bIsBeingTimed[client] = false;
1835 | if(Shavit_GetTimerStatus(client) == Timer_Running) {
1836 | g_bIsBeingTimed[client] = true;
1837 | }
1838 |
1839 | //if(TimerInfo(client).Paused == true)
1840 | if(Shavit_GetTimerStatus(client) == Timer_Paused)
1841 | {
1842 | bCheck = false;
1843 | }
1844 |
1845 | char sSpecial[128];
1846 | int style = Shavit_GetBhopStyle(client);
1847 | Shavit_GetStyleStrings(style, sSpecialString, sSpecial, 128);
1848 | if(StrContains(sSpecial, "bash_bypass", false) != -1)
1849 | {
1850 | bCheck = false;
1851 | }
1852 |
1853 | #endif
1854 |
1855 | UpdateButtons(client, vel, buttons);
1856 | UpdateAngles(client, angles);
1857 |
1858 | if(bCheck == true)
1859 | {
1860 | if(g_bCheckedYet[client] == false)
1861 | {
1862 | g_bCheckedYet[client] = true;
1863 | g_fLastCheckTime[client] = GetEngineTime();
1864 | }
1865 |
1866 | if(GetEntityMoveType(client) != MOVETYPE_NONE)
1867 | {
1868 | g_mLastMoveType[client] = GetEntityMoveType(client);
1869 | }
1870 |
1871 | float tickRate = 1.0 / GetTickInterval();
1872 | g_iRunCmdsPerSecond[client]++;
1873 | if(GetEngineTime() - g_fLastCheckTime[client] >= 1.0)
1874 | {
1875 | if(float(g_iRunCmdsPerSecond[client]) / tickRate <= 0.95)
1876 | {
1877 | if(++g_iBadSeconds[client] >= 3)
1878 | {
1879 | //PrintToAdmins("%N has had %d bad seconds", client, g_iBadSeconds[client]);
1880 | SetEntityMoveType(client, MOVETYPE_NONE);
1881 | }
1882 | }
1883 | else
1884 | {
1885 | if(GetEntityMoveType(client) == MOVETYPE_NONE)
1886 | {
1887 | SetEntityMoveType(client, g_mLastMoveType[client]);
1888 | }
1889 | g_iBadSeconds[client] = 0;
1890 | }
1891 |
1892 | g_fLastCheckTime[client] = GetEngineTime();
1893 | g_iRunCmdsPerSecond[client] = 0;
1894 | }
1895 | }
1896 |
1897 | if(!g_bDhooksLoaded) CheckForTeleport(client);
1898 | CheckForEndKey(client);
1899 | CheckForTurn(client);
1900 | CheckForStartKey(client);
1901 |
1902 | // After we have all the information we can get, do stuff with it
1903 | if(!(GetEntityFlags(client) & (FL_ONGROUND|FL_INWATER)) && GetEntityMoveType(client) == MOVETYPE_WALK && bCheck)
1904 | {
1905 | for(int idx; idx < 4; idx++)
1906 | {
1907 | if(g_iLastReleaseTick[client][idx][BT_Move] == g_iCmdNum[client])
1908 | {
1909 | ClientReleasedKey(client, idx, BT_Move);
1910 | }
1911 |
1912 | if(g_iLastReleaseTick[client][idx][BT_Key] == g_iCmdNum[client])
1913 | {
1914 | ClientReleasedKey(client, idx, BT_Key);
1915 | }
1916 | }
1917 |
1918 | if(g_iLastTurnTick[client] == g_iCmdNum[client])
1919 | {
1920 | ClientTurned(client, g_iLastTurnDir[client]);
1921 | }
1922 |
1923 | if(g_iLastStopTurnTick[client] == g_iCmdNum[client])
1924 | {
1925 | ClientStoppedTurning(client);
1926 | }
1927 |
1928 | for(int idx; idx < 4; idx++)
1929 | {
1930 | if(g_iLastPressTick[client][idx][BT_Move] == g_iCmdNum[client])
1931 | {
1932 | ClientPressedKey(client, idx, BT_Move);
1933 | }
1934 |
1935 | if(g_iLastPressTick[client][idx][BT_Key] == g_iCmdNum[client])
1936 | {
1937 | ClientPressedKey(client, idx, BT_Key);
1938 | }
1939 | }
1940 | }
1941 |
1942 | if(bCheck)
1943 | {
1944 | CheckForIllegalMovement(client, vel, buttons);
1945 | CheckForIllegalTurning(client, vel);
1946 | UpdateGains(client, vel, angles, buttons);
1947 | }
1948 |
1949 | g_fLastMove[client][0] = vel[0];
1950 | g_fLastMove[client][1] = vel[1];
1951 | g_fLastMove[client][2] = vel[2];
1952 | g_fLastAngles[client][0] = angles[0];
1953 | g_fLastAngles[client][1] = angles[1];
1954 | g_fLastAngles[client][2] = angles[2];
1955 | GetClientAbsOrigin(client, g_fLastPosition[client]);
1956 | g_fLastAngleDifference[client][0] = g_fAngleDifference[client][0];
1957 | g_fLastAngleDifference[client][1] = g_fAngleDifference[client][1];
1958 | g_iCmdNum[client]++;
1959 | g_bTouchesFuncRotating[client] = false;
1960 | g_bTouchesWall[client] = false;
1961 | }
1962 | }
1963 |
1964 | int g_iIllegalYawCount[MAXPLAYERS + 1];
1965 | int g_iPlusLeftCount[MAXPLAYERS + 1];
1966 |
1967 | /* float MAX(float a, float b)
1968 | {
1969 | return (a > b)?a:b;
1970 | } */
1971 |
1972 | int g_iCurrentIFrame[MAXPLAYERS + 1];
1973 | float g_fIList[MAXPLAYERS + 1][100];
1974 |
1975 | void CheckForIllegalTurning(int client, float vel[3])
1976 | {
1977 | if(GetClientButtons(client) & (IN_LEFT|IN_RIGHT))
1978 | {
1979 | g_iPlusLeftCount[client]++;
1980 | }
1981 |
1982 | if(g_iCmdNum[client] % 100 == 0)
1983 | {
1984 | if(g_iIllegalYawCount[client] > 30 && g_iPlusLeftCount[client] == 0)
1985 | {
1986 | AnticheatLog(client, "is turning with illegal yaw values (m_yaw: %f, sens: %f, m_customaccel: %d, count: %d, m_yaw changes: %d, Joystick: %d)", g_mYaw[client], g_Sensitivity[client], g_mCustomAccel[client], g_iIllegalYawCount[client], g_mYawChangedCount[client], g_JoyStick[client]);
1987 |
1988 | char sValues[256];
1989 | for(int idx; idx < 20; idx++)
1990 | {
1991 | Format(sValues, 256, "%s %.3f", sValues, g_fIList[idx]);
1992 | }
1993 |
1994 | //AnticheatLog(client, sValues);
1995 | }
1996 |
1997 | g_iIllegalYawCount[client] = 0;
1998 | g_iPlusLeftCount[client] = 0;
1999 | }
2000 |
2001 |
2002 | // Don't bother checking if they arent turning
2003 | if(FloatAbs(g_fAngleDifference[client][1]) < 0.01)
2004 | {
2005 | return;
2006 | }
2007 |
2008 | // Only calculate illegal turns when player cvars have been checked
2009 | if(g_mCustomAccelCheckedCount[client] == 0 || g_mFilterCheckedCount[client] == 0 || g_mYawCheckedCount[client] == 0 || g_SensitivityCheckedCount[client] == 0)
2010 | {
2011 | return;
2012 | }
2013 |
2014 | // Check for teleporting because teleporting can cause illegal turn values
2015 | if(g_iCmdNum[client] - g_iLastTeleportTick[client] < 100)
2016 | {
2017 | return;
2018 | }
2019 |
2020 | // Prevent incredibly high sensitivity from causing detections
2021 | if(FloatAbs(g_fAngleDifference[client][1]) > 20.0 || FloatAbs(g_Sensitivity[client] * g_mYaw[client]) > 0.8)
2022 | {
2023 | return;
2024 | }
2025 |
2026 | // Prevent players who are zooming with a weapon to trigger the anticheat
2027 | if(GetEntProp(client, Prop_Send, "m_iFOVStart") != 90)
2028 | {
2029 | return;
2030 | }
2031 |
2032 | // Prevent false positives with players touching rotating blocks that will change their angles
2033 | if(g_bTouchesFuncRotating[client] == true)
2034 | {
2035 | return;
2036 | }
2037 |
2038 | if(g_iIllegalSidemoveCount[client] > 0)
2039 | {
2040 | return;
2041 | }
2042 |
2043 | // Attempt to prevent players who are using xbox controllers from triggering the anticheat, because they can't use controller and have legal sidemove values at the same time
2044 | float fMaxMove;
2045 | if(g_Engine == Engine_CSS) fMaxMove = 400.0;
2046 | else if(g_Engine == Engine_CSGO) fMaxMove = 450.0;
2047 |
2048 | if(FloatAbs(vel[0]) != fMaxMove && FloatAbs(vel[1]) != fMaxMove)
2049 | {
2050 | return;
2051 | }
2052 |
2053 | float my = g_fAngleDifference[client][0];
2054 | float mx = g_fAngleDifference[client][1];
2055 | float fCoeff;
2056 |
2057 | // Player should not be able to turn at all with sensitivity or m_yaw equal to 0 so detect them if they are
2058 | if((g_mYaw[client] == 0.0 || g_Sensitivity[client] == 0.0) && !(GetClientButtons(client) & (IN_LEFT|IN_RIGHT)))
2059 | {
2060 | g_iIllegalYawCount[client]++;
2061 | }
2062 | else if(g_mCustomAccel[client] <= 0 || g_mCustomAccel[client] > 3)
2063 | {
2064 | //fCoeff = mx / (g_mYaw[client] * g_Sensitivity[client]);
2065 | fCoeff = g_Sensitivity[client];
2066 | }
2067 | else if(g_mCustomAccel[client] == 1 || g_mCustomAccel[client] == 2)
2068 | {
2069 | float raw_mouse_movement_distance = SquareRoot(mx * mx + my * my);
2070 | float acceleration_scale = g_mCustomAccelScale[client];
2071 | float accelerated_sensitivity_max = g_mCustomAccelMax[client];
2072 | float accelerated_sensitivity_exponent = g_mCustomAccelExponent[client];
2073 | float accelerated_sensitivity = Pow(raw_mouse_movement_distance, accelerated_sensitivity_exponent) * acceleration_scale + g_Sensitivity[client];
2074 |
2075 | if (accelerated_sensitivity_max > 0.0001 && accelerated_sensitivity > accelerated_sensitivity_max)
2076 | {
2077 | accelerated_sensitivity = accelerated_sensitivity_max;
2078 | }
2079 |
2080 | fCoeff = accelerated_sensitivity;
2081 |
2082 | if(g_mCustomAccel[client] == 2)
2083 | {
2084 | fCoeff *= g_mYaw[client];
2085 | }
2086 | }
2087 | else if(g_mCustomAccel[client] == 3)
2088 | {
2089 | //float raw_mouse_movement_distance_squared = (mx * mx) + (my * my);
2090 | //float fExp = MAX(0.0, (g_mCustomAccelExponent[client] - 1.0) / 2.0);
2091 | //float accelerated_sensitivity = Pow(raw_mouse_movement_distance_squared, fExp) * g_Sensitivity[client];
2092 |
2093 | //PrintToChat(client, "%f %f", raw_mouse_movement_distance_squared, fExp);
2094 | //PrintToChat(client, "%f", accelerated_sensitivity);
2095 | //PrintToChat(client, "%f", mx);
2096 |
2097 | //fCoeff = accelerated_sensitivity;
2098 | fCoeff = g_Sensitivity[client];
2099 |
2100 | return;
2101 | }
2102 |
2103 | if(g_Engine == Engine_CSS && g_mFilter[client] == true)
2104 | {
2105 | fCoeff /= 4;
2106 | }
2107 |
2108 | float fTurn = mx / (g_mYaw[client] * fCoeff);
2109 | float fRounded = float(RoundFloat(fTurn));
2110 |
2111 | if(FloatAbs(fRounded - fTurn) > 0.1)
2112 | {
2113 | g_fIList[client][g_iCurrentIFrame[client]] = fTurn;
2114 | g_iCurrentIFrame[client] = (g_iCurrentIFrame[client] + 1) % 20;
2115 | g_iIllegalYawCount[client]++;
2116 | }
2117 | }
2118 |
2119 | void CheckForWOnlyHack(int client)
2120 | {
2121 | if(FloatAbs(g_fAngleDifference[client][1] - g_fLastAngleDifference[client][1]) > 13 && // Player turned more than 13 degrees in 1 tick
2122 | g_fAngleDifference[client][1] != 0.0 &&
2123 | ((g_iCmdNum[client] - g_iLastTeleportTick[client]) > 200// &&
2124 | //g_iButtons[client][BT_Move] & (1 << GetOppositeButton(GetDesiredButton(client, g_iLastTurnDir[client])))// &&
2125 | ))
2126 | {
2127 | g_iIllegalTurn[client][g_iIllegalTurn_CurrentFrame[client]] = true;
2128 | //PrintToAdmins("%N: %.1f", client, FloatAbs(g_fAngleDifference[client] - g_fLastAngleDifference[client]));
2129 | }
2130 | else
2131 | {
2132 | g_iIllegalTurn[client][g_iIllegalTurn_CurrentFrame[client]] = false;
2133 | //char sTurn[32];
2134 | //GetTurnDirectionName(g_iLastTurnDir[client], sTurn, sizeof(sTurn));
2135 | //PrintToAdmins("No: Diff: %.1f, Btn: %d, Gain: %.1f", FloatAbs(g_fAngleDifference[client] - g_fLastAngleDifference[client]), g_iButtons[client][BT_Move] & (1 << GetOppositeButton(GetDesiredButton(client, g_iLastTurnDir[client]))), GetGainPercent(client));
2136 | }
2137 |
2138 | #if defined TIMER
2139 |
2140 | g_iIllegalTurn_IsTiming[client][g_iIllegalTurn_CurrentFrame[client]] = g_bIsBeingTimed[client];
2141 | #endif
2142 |
2143 | g_iIllegalTurn_CurrentFrame[client] = (g_iIllegalTurn_CurrentFrame[client] + 1) % MAX_FRAMES;
2144 |
2145 | if(g_iIllegalTurn_CurrentFrame[client] == 0)
2146 | {
2147 | int illegalCount, timingCount;
2148 | for(int idx; idx < MAX_FRAMES; idx++)
2149 | {
2150 | if(g_iIllegalTurn[client][idx] == true)
2151 | {
2152 | illegalCount++;
2153 | }
2154 |
2155 | if(g_iIllegalTurn_IsTiming[client][idx] == true)
2156 | {
2157 | timingCount++;
2158 | }
2159 | }
2160 |
2161 | float illegalPct, timingPct;
2162 | illegalPct = float(illegalCount) / float(MAX_FRAMES);
2163 | timingPct = float(timingCount) / float(MAX_FRAMES);
2164 | if(illegalPct > 0.6)
2165 | {
2166 |
2167 | #if defined TIMER
2168 | char sStyle[32];
2169 | int style = Shavit_GetBhopStyle(client);
2170 | Shavit_GetStyleStrings(style, sStyleName, g_sStyleStrings[style].sStyleName, sizeof(stylestrings_t::sStyleName));
2171 | FormatEx(sStyle, sizeof(sStyle), "%s", g_sStyleStrings[style].sStyleName)
2172 | AnticheatLog(client, "angle snap hack, Pct: %.2f%, Timing: %.1f%, Style: %s", illegalPct * 100.0, timingPct * 100.0, sStyle);
2173 | #endif
2174 |
2175 | #if !defined TIMER
2176 | AnticheatLog(client, "angle snap hack, Pct: %.2f%, Timing: %.1f%", illegalPct * 100.0, timingPct * 100.0);
2177 | #endif
2178 | }
2179 | }
2180 |
2181 | return;
2182 | }
2183 |
2184 | void CheckForStartKey(int client)
2185 | {
2186 | for(int idx; idx < 4; idx++)
2187 | {
2188 | if(!(g_iLastButtons[client][BT_Move] & (1 << idx)) && (g_iButtons[client][BT_Move] & (1 << idx)))
2189 | {
2190 | g_iLastPressTick[client][idx][BT_Move] = g_iCmdNum[client];
2191 | }
2192 |
2193 | if(!(g_iLastButtons[client][BT_Key] & (1 << idx)) && (g_iButtons[client][BT_Key] & (1 << idx)))
2194 | {
2195 | g_iLastPressTick[client][idx][BT_Key] = g_iCmdNum[client];
2196 | }
2197 | }
2198 | }
2199 |
2200 | void ClientPressedKey(int client, int button, int btype)
2201 | {
2202 | g_iKeyPressesThisStrafe[client][btype]++;
2203 | // Check if player started a strafe
2204 | if(btype == BT_Move)
2205 | {
2206 | g_iStrafesDone[client]++; // player pressed either w,a,s,d. update strafe count
2207 |
2208 | int turnDir = GetDesiredTurnDir(client, button, false);
2209 |
2210 | if(g_iLastTurnDir[client] == turnDir &&
2211 | g_iStartStrafe_LastRecordedTick[client] != g_iCmdNum[client] &&
2212 | g_iLastPressTick[client][button][BT_Move] != g_iLastPressTick_Recorded[client][button][BT_Move] &&
2213 | g_iLastTurnTick[client] != g_iLastTurnTick_Recorded_StartStrafe[client])
2214 | {
2215 | int difference = g_iLastTurnTick[client] - g_iLastPressTick[client][button][BT_Move];
2216 |
2217 | if(-15 <= difference <= 15)
2218 | {
2219 | RecordStartStrafe(client, button, turnDir, "ClientPressedKey");
2220 | }
2221 | }
2222 | }
2223 |
2224 | // Check if player finished switching their keys
2225 | int oppositeButton = GetOppositeButton(button);
2226 | int difference = g_iLastPressTick[client][button][btype] - g_iLastReleaseTick[client][oppositeButton][btype];
2227 | if(difference <= 15 && g_iKeySwitch_LastRecordedTick[client][btype] != g_iCmdNum[client] &&
2228 | g_iLastReleaseTick[client][oppositeButton][btype] != g_iLastReleaseTick_Recorded_KS[client][oppositeButton][btype] &&
2229 | g_iLastPressTick[client][button][btype] != g_iLastPressTick_Recorded_KS[client][button][btype])
2230 | {
2231 | RecordKeySwitch(client, button, oppositeButton, btype, "ClientPressedKey");
2232 | }
2233 | }
2234 |
2235 | void CheckForTeleport(int client)
2236 | {
2237 | float vPos[3];
2238 | GetClientAbsOrigin(client, vPos);
2239 |
2240 | float distance = SquareRoot(Pow(vPos[0] - g_fLastPosition[client][0], 2.0) +
2241 | Pow(vPos[1] - g_fLastPosition[client][1], 2.0) +
2242 | Pow(vPos[2] - g_fLastPosition[client][2], 2.0));
2243 |
2244 | if(distance > 35.0)
2245 | {
2246 | g_iLastTeleportTick[client] = g_iCmdNum[client];
2247 | }
2248 | }
2249 |
2250 | void CheckForEndKey(int client)
2251 | {
2252 | for(int idx; idx < 4; idx++)
2253 | {
2254 | if((g_iLastButtons[client][BT_Move] & (1 << idx)) && !(g_iButtons[client][BT_Move] & (1 << idx)))
2255 | {
2256 | g_iLastReleaseTick[client][idx][BT_Move] = g_iCmdNum[client];
2257 | }
2258 |
2259 | if((g_iLastButtons[client][BT_Key] & (1 << idx)) && !(g_iButtons[client][BT_Key] & (1 << idx)))
2260 | {
2261 | g_iLastReleaseTick[client][idx][BT_Key] = g_iCmdNum[client];
2262 | }
2263 | }
2264 | }
2265 |
2266 | void ClientReleasedKey(int client, int button, int btype)
2267 | {
2268 | if(btype == BT_Move)
2269 | {
2270 | // Record end strafe if it is actually an end strafe
2271 | int turnDir = GetDesiredTurnDir(client, button, true);
2272 |
2273 | if((g_iLastTurnDir[client] == turnDir || g_bIsTurning[client] == false) &&
2274 | g_iEndStrafe_LastRecordedTick[client] != g_iCmdNum[client] &&
2275 | g_iLastReleaseTick_Recorded[client][button][BT_Move] != g_iLastReleaseTick[client][button][BT_Move] &&
2276 | g_iLastTurnTick_Recorded_EndStrafe[client] != g_iLastTurnTick[client])
2277 | {
2278 | int difference = g_iLastTurnTick[client] - g_iLastReleaseTick[client][button][BT_Move];
2279 |
2280 | if(-15 <= difference <= 15)
2281 | {
2282 | RecordEndStrafe(client, button, turnDir, "ClientReleasedKey");
2283 | }
2284 | }
2285 | }
2286 |
2287 | // Check if we should record a key switch (BT_Key)
2288 | if(btype == BT_Key)
2289 | {
2290 | int oppositeButton = GetOppositeButton(button);
2291 |
2292 | if(g_iLastReleaseTick[client][button][BT_Key] - g_iLastPressTick[client][oppositeButton][BT_Key] <= 15 &&
2293 | g_iKeySwitch_LastRecordedTick[client][BT_Key] != g_iCmdNum[client] &&
2294 | g_iLastReleaseTick[client][button][btype] != g_iLastReleaseTick_Recorded_KS[client][button][btype] &&
2295 | g_iLastPressTick[client][oppositeButton][btype] != g_iLastPressTick_Recorded_KS[client][oppositeButton][btype])
2296 | {
2297 | RecordKeySwitch(client, oppositeButton, button, btype, "ClientReleasedKey");
2298 | }
2299 | }
2300 | }
2301 |
2302 | void CheckForTurn(int client)
2303 | {
2304 | if(g_fAngleDifference[client][1] == 0.0 && g_bIsTurning[client] == true)
2305 | {
2306 | g_iLastStopTurnTick[client] = g_iCmdNum[client];
2307 | g_bIsTurning[client] = false;
2308 | }
2309 | else if(g_fAngleDifference[client][1] > 0)
2310 | {
2311 | if(g_iLastTurnDir[client] == Turn_Right)
2312 | {
2313 | // Turned left
2314 | g_iLastTurnTick[client] = g_iCmdNum[client];
2315 | g_iLastTurnDir[client] = Turn_Left;
2316 | g_bIsTurning[client] = true;
2317 | }
2318 | }
2319 | else if(g_fAngleDifference[client][1] < 0)
2320 | {
2321 | if(g_iLastTurnDir[client] == Turn_Left)
2322 | {
2323 | // Turned right
2324 | g_iLastTurnTick[client] = g_iCmdNum[client];
2325 | g_iLastTurnDir[client] = Turn_Right;
2326 | g_bIsTurning[client] = true;
2327 | }
2328 | }
2329 | }
2330 |
2331 | void ClientTurned(int client, int turnDir)
2332 | {
2333 | // Check if client ended a strafe
2334 | int button = GetDesiredButton(client, turnDir);
2335 |
2336 | int oppositeButton = GetOppositeButton(button);
2337 | if(!(g_iButtons[client][BT_Move] & (1 << oppositeButton)) &&
2338 | g_iEndStrafe_LastRecordedTick[client] != g_iCmdNum[client] &&
2339 | g_iReleaseTickAtLastEndStrafe[client][oppositeButton] != g_iLastReleaseTick[client][oppositeButton][BT_Move] &&
2340 | g_iLastTurnTick_Recorded_EndStrafe[client] != g_iLastTurnTick[client])
2341 | {
2342 | int difference = g_iLastTurnTick[client] - g_iLastReleaseTick[client][oppositeButton][BT_Move];
2343 |
2344 | if(-15 <= difference <= 15)
2345 | {
2346 | RecordEndStrafe(client, oppositeButton, turnDir, "ClientTurned");
2347 | }
2348 | }
2349 |
2350 | // Check if client just started a strafe
2351 | if(g_iButtons[client][BT_Move] & (1 << button) &&
2352 | g_iStartStrafe_LastRecordedTick[client] != g_iCmdNum[client] &&
2353 | g_iLastPressTick_Recorded[client][button][BT_Move] != g_iLastPressTick[client][button][BT_Move] &&
2354 | g_iLastTurnTick_Recorded_StartStrafe[client] != g_iLastTurnTick[client])
2355 | {
2356 | int difference = g_iLastTurnTick[client] - g_iLastPressTick[client][button][BT_Move];
2357 |
2358 | if(-15 <= difference <= 15)
2359 | {
2360 | RecordStartStrafe(client, button, turnDir, "ClientTurned");
2361 | }
2362 | }
2363 |
2364 | // Check if client is cheating on w-only
2365 | CheckForWOnlyHack(client);
2366 | }
2367 |
2368 | void ClientStoppedTurning(int client)
2369 | {
2370 | int turnDir = g_iLastTurnDir[client];
2371 | int button = GetDesiredButton(client, turnDir);
2372 |
2373 | // if client already let go of movement button, and end strafe hasn't been recorded this tick and since they released their key
2374 | if(!(g_iButtons[client][BT_Move] & (1 << button)) &&
2375 | g_iEndStrafe_LastRecordedTick[client] != g_iCmdNum[client] &&
2376 | g_iReleaseTickAtLastEndStrafe[client][button] != g_iLastReleaseTick[client][button][BT_Move] &&
2377 | g_iLastTurnTick_Recorded_EndStrafe[client] != g_iLastStopTurnTick[client])
2378 | {
2379 | int difference = g_iLastStopTurnTick[client] - g_iLastReleaseTick[client][button][BT_Move];
2380 |
2381 | if(-15 <= difference <= 15)
2382 | {
2383 | RecordEndStrafe(client, button, turnDir, "ClientStoppedTurning");
2384 | }
2385 | }
2386 | }
2387 |
2388 | stock void RecordStartStrafe(int client, int button, int turnDir, const char[] caller)
2389 | {
2390 | g_iLastPressTick_Recorded[client][button][BT_Move] = g_iLastPressTick[client][button][BT_Move];
2391 | g_iLastTurnTick_Recorded_StartStrafe[client] = g_iLastTurnTick[client];
2392 |
2393 | int moveDir = GetDirection(client);
2394 | int currFrame = g_iStartStrafe_CurrentFrame[client];
2395 | g_iStartStrafe_LastRecordedTick[client] = g_iCmdNum[client];
2396 | g_iStartStrafe_Stats[client][StrafeData_Button][currFrame] = button;
2397 | g_iStartStrafe_Stats[client][StrafeData_TurnDirection][currFrame] = turnDir;
2398 | g_iStartStrafe_Stats[client][StrafeData_MoveDirection][currFrame] = moveDir;
2399 | g_iStartStrafe_Stats[client][StrafeData_Difference][currFrame] = g_iLastPressTick[client][button][BT_Move] - g_iLastTurnTick[client];
2400 | g_iStartStrafe_Stats[client][StrafeData_Tick][currFrame] = g_iCmdNum[client];
2401 | #if defined TIMER
2402 | g_iStartStrafe_Stats[client][StrafeData_IsTiming][currFrame] = g_bIsBeingTimed[client];
2403 | #endif
2404 | g_bStartStrafe_IsRecorded[client][currFrame] = true;
2405 | g_iStartStrafe_CurrentFrame[client] = (g_iStartStrafe_CurrentFrame[client] + 1) % MAX_FRAMES;
2406 |
2407 |
2408 | if(g_iStartStrafe_Stats[client][StrafeData_Difference][currFrame] == g_iStartStrafe_LastTickDifference[client] && !IsInLeftRight(client, g_iRealButtons[client]))
2409 | {
2410 | g_iStartStrafe_IdenticalCount[client]++;
2411 |
2412 | if (g_iStartStrafe_IdenticalCount[client] >= IDENTICAL_STRAFE_MIN)
2413 | {
2414 | AnticheatLog(client, "too many %i strafes in a row (%d)", g_iStartStrafe_LastTickDifference[client], g_iStartStrafe_IdenticalCount[client]);
2415 | AutoBanPlayer(client);
2416 | }
2417 | }
2418 | else
2419 | {
2420 | if (g_iStartStrafe_IdenticalCount[client] >= 15 && g_iStartStrafe_IdenticalCount[client] < IDENTICAL_STRAFE_MIN)
2421 | {
2422 | AnticheatLog(client, "too many %i strafes in a row (%d)", g_iStartStrafe_LastTickDifference[client], g_iStartStrafe_IdenticalCount[client]);
2423 | }
2424 |
2425 | g_iStartStrafe_LastTickDifference[client] = g_iStartStrafe_Stats[client][StrafeData_Difference][currFrame];
2426 | g_iStartStrafe_IdenticalCount[client] = 0;
2427 | }
2428 |
2429 | if(g_iStartStrafe_CurrentFrame[client] == 0)
2430 | {
2431 | int array[MAX_FRAMES];
2432 | int size, timingCount;
2433 | for(int idx; idx < MAX_FRAMES; idx++)
2434 | {
2435 | if(g_bStartStrafe_IsRecorded[client][idx] == true)
2436 | {
2437 | array[idx] = g_iStartStrafe_Stats[client][StrafeData_Difference][idx];
2438 | size++;
2439 |
2440 | if(g_iStartStrafe_Stats[client][StrafeData_IsTiming][idx] == true)
2441 | {
2442 | timingCount++;
2443 | }
2444 | }
2445 | }
2446 | float mean = GetAverage(array, size);
2447 | float sd = StandardDeviation(array, size, mean);
2448 |
2449 | if(sd < 0.8)
2450 | {
2451 | char sStyle[32];
2452 | #if defined TIMER
2453 | int style = Shavit_GetBhopStyle(client);
2454 | Shavit_GetStyleStrings(style, sStyleName, g_sStyleStrings[style].sStyleName, sizeof(stylestrings_t::sStyleName));
2455 | FormatEx(sStyle, sizeof(sStyle), "%s", g_sStyleStrings[style].sStyleName)
2456 | #endif
2457 | float timingPct = float(timingCount) / float(MAX_FRAMES);
2458 | AnticheatLog(client, "start strafe, avg: %.2f, dev: %.2f, Timing: %.1f%, style: %s", mean, sd, timingPct * 100, sStyle);
2459 |
2460 | #if defined TIMER
2461 | if(sd <= 0.4 && timingPct == 1.0)
2462 | #else
2463 | if(sd <= 0.4)
2464 | #endif
2465 | {
2466 | AutoBanPlayer(client);
2467 | }
2468 | }
2469 | }
2470 |
2471 | //char sOutput[128], sButton[16], sTurn[16], sMove[16];
2472 | //GetTurnDirectionName(turnDir, sTurn, sizeof(sTurn));
2473 | //GetMoveDirectionName(button, sButton, sizeof(sButton));
2474 | //GetMoveDirectionName(moveDir, sMove, sizeof(sMove));
2475 |
2476 | //PrintToAdmins("Turned %s | Pressed %s | Moving %s | Difference %d",
2477 | // sTurn,
2478 | // sButton,
2479 | // sMove,
2480 | // g_iStartStrafe_Stats[client][StrafeData_Difference][currFrame]);
2481 | }
2482 |
2483 | stock void RecordEndStrafe(int client, int button, int turnDir, const char[] caller)
2484 | {
2485 | g_iReleaseTickAtLastEndStrafe[client][button] = g_iLastReleaseTick[client][button][BT_Move];
2486 | g_iLastReleaseTick_Recorded[client][button][BT_Move] = g_iLastReleaseTick[client][button][BT_Move];
2487 | g_iEndStrafe_LastRecordedTick[client] = g_iCmdNum[client];
2488 | int moveDir = GetDirection(client);
2489 | int currFrame = g_iEndStrafe_CurrentFrame[client];
2490 | g_iEndStrafe_Stats[client][StrafeData_Button][currFrame] = button;
2491 | g_iEndStrafe_Stats[client][StrafeData_TurnDirection][currFrame] = turnDir;
2492 | g_iEndStrafe_Stats[client][StrafeData_MoveDirection][currFrame] = moveDir;
2493 | #if defined TIMER
2494 | g_iEndStrafe_Stats[client][StrafeData_IsTiming][currFrame] = g_bIsBeingTimed[client];
2495 | #endif
2496 |
2497 | int difference = g_iLastReleaseTick[client][button][BT_Move] - g_iLastStopTurnTick[client];
2498 | g_iLastTurnTick_Recorded_EndStrafe[client] = g_iLastStopTurnTick[client];
2499 |
2500 | if(g_iLastTurnTick[client] > g_iLastStopTurnTick[client])
2501 | {
2502 | difference = g_iLastReleaseTick[client][button][BT_Move] - g_iLastTurnTick[client];
2503 | g_iLastTurnTick_Recorded_EndStrafe[client] = g_iLastTurnTick[client];
2504 | }
2505 | g_iEndStrafe_Stats[client][StrafeData_Difference][currFrame] = difference;
2506 | g_bEndStrafe_IsRecorded[client][currFrame] = true;
2507 | g_iEndStrafe_Stats[client][StrafeData_Tick][currFrame] = g_iCmdNum[client];
2508 | g_iEndStrafe_CurrentFrame[client] = (g_iEndStrafe_CurrentFrame[client] + 1) % MAX_FRAMES;
2509 |
2510 | if(g_iEndStrafe_Stats[client][StrafeData_Difference][currFrame] == g_iEndStrafe_LastTickDifference[client] && !IsInLeftRight(client, g_iRealButtons[client]))
2511 | {
2512 | g_iEndStrafe_IdenticalCount[client]++;
2513 |
2514 | if (g_iEndStrafe_IdenticalCount[client] >= IDENTICAL_STRAFE_MIN)
2515 | {
2516 | AnticheatLog(client, "too many %i strafes in a row (%d)", g_iEndStrafe_LastTickDifference[client], g_iEndStrafe_IdenticalCount[client]);
2517 | AutoBanPlayer(client);
2518 | }
2519 | }
2520 | else
2521 | {
2522 | if (g_iEndStrafe_IdenticalCount[client] >= 15 && g_iEndStrafe_IdenticalCount[client] < IDENTICAL_STRAFE_MIN)
2523 | {
2524 | AnticheatLog(client, "too many %i strafes in a row (%d)", g_iEndStrafe_LastTickDifference[client], g_iEndStrafe_IdenticalCount[client]);
2525 | }
2526 |
2527 | g_iEndStrafe_LastTickDifference[client] = g_iEndStrafe_Stats[client][StrafeData_Difference][currFrame];
2528 | g_iEndStrafe_IdenticalCount[client] = 0;
2529 | }
2530 |
2531 | if(g_iEndStrafe_CurrentFrame[client] == 0)
2532 | {
2533 | int array[MAX_FRAMES];
2534 | int size, timingCount;
2535 | for(int idx; idx < MAX_FRAMES; idx++)
2536 | {
2537 | if(g_bEndStrafe_IsRecorded[client][idx] == true)
2538 | {
2539 | array[idx] = g_iEndStrafe_Stats[client][StrafeData_Difference][idx];
2540 | size++;
2541 |
2542 | if(g_iEndStrafe_Stats[client][StrafeData_IsTiming][idx] == true)
2543 | {
2544 | timingCount++;
2545 | }
2546 | }
2547 | }
2548 | float mean = GetAverage(array, size);
2549 | float sd = StandardDeviation(array, size, mean);
2550 |
2551 | if(sd < 0.8)
2552 | {
2553 | char sStyle[32];
2554 | #if defined TIMER
2555 | int style = Shavit_GetBhopStyle(client);
2556 | Shavit_GetStyleStrings(style, sStyleName, g_sStyleStrings[style].sStyleName, sizeof(stylestrings_t::sStyleName));
2557 | FormatEx(sStyle, sizeof(sStyle), "%s", g_sStyleStrings[style].sStyleName)
2558 | #endif
2559 | float timingPct = float(timingCount) / float(MAX_FRAMES);
2560 | AnticheatLog(client, "end strafe, avg: %.2f, dev: %.2f, Timing: %.1f%, style: %s", mean, sd, timingPct * 100, sStyle);
2561 |
2562 | #if defined TIMER
2563 | if(sd <= 0.4 && timingPct == 1.0)
2564 | #else
2565 | if(sd <= 0.4)
2566 | #endif
2567 | {
2568 | AutoBanPlayer(client);
2569 | }
2570 | }
2571 | }
2572 | /*
2573 | char sButton[16], sTurn[16], sMove[16];
2574 | GetTurnDirectionName(turnDir, sTurn, sizeof(sTurn));
2575 | GetMoveDirectionName(button, sButton, sizeof(sButton));
2576 | GetMoveDirectionName(moveDir, sMove, sizeof(sMove));
2577 |
2578 | PrintToAdmins("Turn %s | Press %s | Moving %s | Dif %d | %s",
2579 | sTurn,
2580 | sButton,
2581 | sMove,
2582 | g_iEndStrafe_Stats[client][StrafeData_Difference][currFrame],
2583 | caller);
2584 | */
2585 |
2586 | // Check key press count
2587 | //PrintToChat(client, "%d", g_iKeyPressesThisStrafe[client][BT_Move]);
2588 | g_iKeyPressesThisStrafe[client][BT_Move] = 0;
2589 | g_iKeyPressesThisStrafe[client][BT_Key] = 0;
2590 | }
2591 |
2592 | stock void RecordKeySwitch(int client, int button, int oppositeButton, int btype, const char[] caller)
2593 | {
2594 | // Record the data
2595 | int currFrame = g_iKeySwitch_CurrentFrame[client][btype];
2596 | g_iKeySwitch_Stats[client][KeySwitchData_Button][btype][currFrame] = button;
2597 | g_iKeySwitch_Stats[client][KeySwitchData_Difference][btype][currFrame] = g_iLastPressTick[client][button][btype] - g_iLastReleaseTick[client][oppositeButton][btype];
2598 | #if defined TIMER
2599 | g_iKeySwitch_Stats[client][KeySwitchData_IsTiming][btype][currFrame] = g_bIsBeingTimed[client];
2600 | #endif
2601 | g_bKeySwitch_IsRecorded[client][btype][currFrame] = true;
2602 | g_iKeySwitch_LastRecordedTick[client][btype] = g_iCmdNum[client];
2603 | g_iKeySwitch_CurrentFrame[client][btype] = (g_iKeySwitch_CurrentFrame[client][btype] + 1) % MAX_FRAMES_KEYSWITCH;
2604 | g_iLastPressTick_Recorded_KS[client][button][btype] = g_iLastPressTick[client][button][btype];
2605 | g_iLastReleaseTick_Recorded_KS[client][oppositeButton][btype] = g_iLastReleaseTick[client][oppositeButton][btype];
2606 |
2607 | // After we have a new set of data, check to see if they are cheating
2608 | if(g_iKeySwitch_CurrentFrame[client][btype] == 0)
2609 | {
2610 | int array[MAX_FRAMES_KEYSWITCH];
2611 | int size, positiveCount, timingCount, nullCount;
2612 | for(int idx; idx < MAX_FRAMES_KEYSWITCH; idx++)
2613 | {
2614 | if(g_bKeySwitch_IsRecorded[client][btype][idx] == true)
2615 | {
2616 | array[idx] = g_iKeySwitch_Stats[client][KeySwitchData_Difference][btype][idx];
2617 | size++;
2618 |
2619 | if(btype == BT_Key)
2620 | {
2621 | if(g_iKeySwitch_Stats[client][KeySwitchData_Difference][BT_Key][idx] >= 0)
2622 | {
2623 | positiveCount++;
2624 | }
2625 | }
2626 |
2627 | if(g_iKeySwitch_Stats[client][KeySwitchData_Difference][BT_Key][idx] == 0)
2628 | {
2629 | nullCount++;
2630 | }
2631 |
2632 | if(g_iKeySwitch_Stats[client][KeySwitchData_IsTiming][btype][idx] == true)
2633 | {
2634 | timingCount++;
2635 | }
2636 | }
2637 | }
2638 |
2639 | float mean = GetAverage(array, size);
2640 | float sd = StandardDeviation(array, size, mean);
2641 | float nullPct = float(nullCount) / float(MAX_FRAMES_KEYSWITCH);
2642 | if(sd <= 0.25 || nullPct >= 0.95)
2643 | {
2644 | if(btype == BT_Key)
2645 | {
2646 | if(positiveCount == MAX_FRAMES_KEYSWITCH)
2647 | {
2648 | //PrintToAdmins("%N key switch positive count every frame", client);
2649 | }
2650 | }
2651 |
2652 | float timingPct, positivePct;
2653 | positivePct = float(positiveCount) / float(MAX_FRAMES_KEYSWITCH);
2654 | timingPct = float(timingCount) / float(MAX_FRAMES_KEYSWITCH);
2655 |
2656 |
2657 | #if defined TIMER
2658 | char sStyle[32];
2659 | int style = Shavit_GetBhopStyle(client);
2660 | Shavit_GetStyleStrings(style, sStyleName, g_sStyleStrings[style].sStyleName, sizeof(stylestrings_t::sStyleName));
2661 | FormatEx(sStyle, sizeof(sStyle), "%s", g_sStyleStrings[style].sStyleName)
2662 | AnticheatLog(client, "key switch %d, avg: %.2f, dev: %.2f, p: %.2f%, nullPct: %.2f, Timing: %.1f, Style: %s", btype, mean, sd, positivePct * 100, nullPct * 100, timingPct * 100, sStyle);
2663 | #endif
2664 |
2665 | //AnticheatLog(client, "key switch %d, avg: %.2f, dev: %.2f, p: %.2f%, nullPct: %.2f, Timing: %.1f%%", btype, mean, sd, positivePct * 100, nullPct * 100, timingPct * 100);
2666 | #if !defined TIMER
2667 | AnticheatLog(client, "key switch %d, avg: %.2f, dev: %.2f, p: %.2f%, nullPct: %.2f, Timing: %.1f", btype, mean, sd, positivePct * 100, nullPct * 100, timingPct * 100);
2668 | #endif
2669 | if(IsClientInGame(client) && g_hAntiNull.BoolValue)
2670 | {
2671 | // Add a delay to the kick in case they are using an obvious strafehack that would ban them anyway
2672 | CreateTimer(10.0, Timer_NullKick, GetClientUserId(client));
2673 | }
2674 | }
2675 | }
2676 | }
2677 |
2678 | public Action Timer_NullKick(Handle timer, int userid)
2679 | {
2680 | int client = GetClientOfUserId(userid);
2681 |
2682 | if(client != 1)
2683 | {
2684 | KickClient(client, "Kicked for potentional movement config");
2685 | }
2686 | }
2687 |
2688 | // If a player triggers this while they are turning and their turning rate is legal from the CheckForIllegalTurning function, then we can probably autoban
2689 | void CheckForIllegalMovement(int client, float vel[3], int buttons)
2690 | {
2691 | g_iLastInvalidButtonCount[client] = g_InvalidButtonSidemoveCount[client];
2692 | bool bInvalid;
2693 | if(vel[1] > 0 && (buttons & IN_MOVELEFT))
2694 | {
2695 | bInvalid = true;
2696 | g_iLastIllegalReason[client] = 1;
2697 | }
2698 | if(vel[1] > 0 && (buttons & (IN_MOVELEFT|IN_MOVERIGHT) == (IN_MOVELEFT|IN_MOVERIGHT)))
2699 | {
2700 | bInvalid = true;
2701 | g_iLastIllegalReason[client] = 2;
2702 | }
2703 | if(vel[1] < 0 && (buttons & IN_MOVERIGHT))
2704 | {
2705 | bInvalid = true;
2706 | g_iLastIllegalReason[client] = 3;
2707 | }
2708 | if(vel[1] < 0 && (buttons & (IN_MOVELEFT|IN_MOVERIGHT) == (IN_MOVELEFT|IN_MOVERIGHT)))
2709 | {
2710 | bInvalid = true;
2711 | g_iLastIllegalReason[client] = 4;
2712 | }
2713 | if(vel[1] == 0.0 && ((buttons & (IN_MOVELEFT|IN_MOVERIGHT)) == IN_MOVELEFT || (buttons & (IN_MOVELEFT|IN_MOVERIGHT)) == IN_MOVERIGHT))
2714 | {
2715 | bInvalid = true;
2716 | g_iLastIllegalReason[client] = 5;
2717 | }
2718 | if(vel[1] != 0.0 && !(buttons & IN_MOVELEFT|IN_MOVERIGHT))
2719 | {
2720 | bInvalid = true;
2721 | g_iLastIllegalReason[client] = 6;
2722 | }
2723 |
2724 | if(bInvalid == true)
2725 | {
2726 | g_InvalidButtonSidemoveCount[client]++;
2727 | }
2728 | else
2729 | {
2730 | g_InvalidButtonSidemoveCount[client] = 0;
2731 | }
2732 |
2733 | if(g_InvalidButtonSidemoveCount[client] >= 4)
2734 | {
2735 | vel[0] = 0.0;
2736 | vel[1] = 0.0;
2737 | vel[2] = 0.0;
2738 | }
2739 |
2740 | if(g_InvalidButtonSidemoveCount[client] == 0 && g_iLastInvalidButtonCount[client] >= 10)
2741 | {
2742 | AnticheatLog(client, "has invalid buttons and sidemove combination %d %d", g_iLastIllegalReason[client], g_InvalidButtonSidemoveCount[client]);
2743 | }
2744 |
2745 | /*
2746 | if((vel[0] != float(RoundToFloor(vel[0])) || vel[1] != float(RoundToFloor(vel[1]))) || (RoundFloat(vel[0]) % 25 != 0 || RoundFloat(vel[1]) % 25 != 0))
2747 | {
2748 | // Extra checks for values that the modulo dosent pick up
2749 | if(FloatAbs(vel[0]) != 112.500000 && FloatAbs(vel[1]) != 112.500000)
2750 | {
2751 | vel[0] = 0.0;
2752 | vel[1] = 0.0;
2753 | vel[2] = 0.0;
2754 | }
2755 | }
2756 | */
2757 |
2758 | // Prevent 28 velocity exploit
2759 | float fMaxMove;
2760 | if(g_Engine == Engine_CSS)
2761 | {
2762 | fMaxMove = 400.0;
2763 | }
2764 | else if(g_Engine == Engine_CSGO)
2765 | {
2766 | fMaxMove = 450.0;
2767 | }
2768 |
2769 | if(RoundToFloor(vel[0] * 100.0) % 625 != 0 || RoundToFloor( vel[1] * 100.0 ) % 625 != 0)
2770 | {
2771 | g_iIllegalSidemoveCount[client]++;
2772 | vel[0] = 0.0;
2773 | vel[1] = 0.0;
2774 | vel[2] = 0.0;
2775 |
2776 | if(FloatAbs(g_fAngleDifference[client][1]) > 0)
2777 | {
2778 | g_iYawChangeCount[client]++;
2779 | }
2780 | }
2781 | else if((FloatAbs(vel[0]) != fMaxMove && vel[0] != 0.0) || (FloatAbs(vel[1]) != fMaxMove && vel[1] != 0.0))
2782 | {
2783 | g_iIllegalSidemoveCount[client]++;
2784 |
2785 | if(FloatAbs(g_fAngleDifference[client][1]) > 0)
2786 | {
2787 | g_iYawChangeCount[client]++;
2788 | }
2789 | }
2790 | else
2791 | {
2792 | g_iIllegalSidemoveCount[client] = 0;
2793 | }
2794 |
2795 | if(g_iIllegalSidemoveCount[client] >= 4)
2796 | {
2797 | vel[0] = 0.0;
2798 | vel[1] = 0.0;
2799 | vel[2] = 0.0;
2800 | }
2801 |
2802 | if(g_iIllegalSidemoveCount[client] == 0)
2803 | {
2804 | if(g_iLastIllegalSidemoveCount[client] >= 10)
2805 | {
2806 | bool bBan;
2807 | if((float(g_iYawChangeCount[client]) / float(g_iLastIllegalSidemoveCount[client])) > 0.3 && g_JoyStick[client] == false) // Rule out xbox controllers, +strafe, and lookstrafe false positives
2808 | {
2809 | bBan = true;
2810 | }
2811 |
2812 | AnticheatLog(client, "has invalid consecutive movement values, (Joystick = %d, YawChanges = %d/%d) - %s", g_JoyStick[client], g_iYawChangeCount[client], g_iLastIllegalSidemoveCount[client], bBan?"BAN":"SUSPECT");
2813 | //if(bBan) AutoBanPlayer(client);
2814 | }
2815 |
2816 | g_iYawChangeCount[client] = 0;
2817 | }
2818 |
2819 | g_iLastIllegalSidemoveCount[client] = g_iIllegalSidemoveCount[client];
2820 | }
2821 |
2822 | stock void UpdateButtons(int client, float vel[3], int buttons)
2823 | {
2824 | g_iLastButtons[client][BT_Move] = g_iButtons[client][BT_Move];
2825 | g_iButtons[client][BT_Move] = 0;
2826 |
2827 | if(vel[0] > 0)
2828 | {
2829 | g_iButtons[client][BT_Move] |= (1 << Button_Forward);
2830 | }
2831 | else if(vel[0] < 0)
2832 | {
2833 | g_iButtons[client][BT_Move] |= (1 << Button_Back);
2834 | }
2835 |
2836 | if(vel[1] > 0)
2837 | {
2838 | g_iButtons[client][BT_Move] |= (1 << Button_Right);
2839 | }
2840 | else if(vel[1] < 0)
2841 | {
2842 | g_iButtons[client][BT_Move] |= (1 << Button_Left);
2843 | }
2844 |
2845 | g_iLastButtons[client][BT_Key] = g_iButtons[client][BT_Key];
2846 | g_iButtons[client][BT_Key] = 0;
2847 |
2848 | if(buttons & IN_MOVELEFT)
2849 | {
2850 | g_iButtons[client][BT_Key] |= (1 << Button_Left);
2851 | }
2852 | if(buttons & IN_MOVERIGHT)
2853 | {
2854 | g_iButtons[client][BT_Key] |= (1 << Button_Right);
2855 | }
2856 | if(buttons & IN_FORWARD)
2857 | {
2858 | g_iButtons[client][BT_Key] |= (1 << Button_Forward);
2859 | }
2860 | if(buttons & IN_BACK)
2861 | {
2862 | g_iButtons[client][BT_Key] |= (1 << Button_Back);
2863 | }
2864 | }
2865 |
2866 | void UpdateAngles(int client, float angles[3])
2867 | {
2868 | for(int i; i < 2; i++)
2869 | {
2870 | g_fAngleDifference[client][i] = angles[i] - g_fLastAngles[client][i];
2871 |
2872 | if (g_fAngleDifference[client][i] > 180)
2873 | g_fAngleDifference[client][i] -= 360;
2874 | else if(g_fAngleDifference[client][i] < -180)
2875 | g_fAngleDifference[client][i] += 360;
2876 | }
2877 | }
2878 |
2879 | stock float FindDegreeAngleFromVectors(float vOldAngle[3], float vNewAngle[3])
2880 | {
2881 | float deltaX = vOldAngle[1] - vNewAngle[1];
2882 | float deltaY = vNewAngle[0] - vOldAngle[0];
2883 | float angleInDegrees = ArcTangent2(deltaX, deltaY) * 180 / FLOAT_PI;
2884 |
2885 | if(angleInDegrees < 0)
2886 | {
2887 | angleInDegrees += 360;
2888 | }
2889 |
2890 | return angleInDegrees;
2891 | }
2892 |
2893 | void UpdateGains(int client, float vel[3], float angles[3], int buttons)
2894 | {
2895 | if(GetEntityFlags(client) & FL_ONGROUND)
2896 | {
2897 | if(g_iTicksOnGround[client] > BHOP_TIME)
2898 | {
2899 | g_iJump[client] = 0;
2900 | g_strafeTick[client] = 0;
2901 | g_flRawGain[client] = 0.0;
2902 | g_iYawTickCount[client] = 0;
2903 | g_iTimingTickCount[client] = 0;
2904 | g_iStrafesDone[client] = 0;
2905 | g_bFirstSixJumps[client] = true;
2906 | }
2907 | g_iTicksOnGround[client]++;
2908 | }
2909 | else
2910 | {
2911 |
2912 |
2913 | if(GetEntityMoveType(client) == MOVETYPE_WALK &&
2914 | GetEntProp(client, Prop_Data, "m_nWaterLevel") < 2 &&
2915 | !(GetEntityFlags(client) & FL_ATCONTROLS))
2916 | {
2917 | bool isYawing = false;
2918 | if(buttons & IN_LEFT) isYawing = !isYawing;
2919 | if(buttons & IN_RIGHT) isYawing = !isYawing;
2920 | if(!(g_iYawSpeed[client] < 50.0 || isYawing == false))
2921 | {
2922 | g_iYawTickCount[client]++;
2923 | }
2924 |
2925 | #if defined TIMER
2926 | if(g_bIsBeingTimed[client])
2927 | {
2928 | g_iTimingTickCount[client]++;
2929 | }
2930 | #endif
2931 |
2932 | float gaincoeff;
2933 | g_strafeTick[client]++;
2934 | if(g_strafeTick[client] == 1000)
2935 | {
2936 | g_flRawGain[client] *= 998.0/999.0;
2937 | g_strafeTick[client]--;
2938 | }
2939 |
2940 | float velocity[3];
2941 | GetEntPropVector(client, Prop_Data, "m_vecAbsVelocity", velocity);
2942 |
2943 | float fore[3], side[3], wishvel[3], wishdir[3];
2944 | float wishspeed, wishspd, currentgain;
2945 |
2946 | GetAngleVectors(angles, fore, side, NULL_VECTOR);
2947 |
2948 | fore[2] = 0.0;
2949 | side[2] = 0.0;
2950 | NormalizeVector(fore, fore);
2951 | NormalizeVector(side, side);
2952 |
2953 | for(int i = 0; i < 2; i++)
2954 | wishvel[i] = fore[i] * vel[0] + side[i] * vel[1];
2955 |
2956 | wishspeed = NormalizeVector(wishvel, wishdir);
2957 | if(wishspeed > GetEntPropFloat(client, Prop_Send, "m_flMaxspeed")) wishspeed = GetEntPropFloat(client, Prop_Send, "m_flMaxspeed");
2958 |
2959 | if(wishspeed)
2960 | {
2961 | wishspd = (wishspeed > 30.0) ? 30.0 : wishspeed;
2962 |
2963 | currentgain = GetVectorDotProduct(velocity, wishdir);
2964 | if(currentgain < 30.0)
2965 | gaincoeff = (wishspd - FloatAbs(currentgain)) / wishspd;
2966 | if(g_bTouchesWall[client] && gaincoeff > 0.5)
2967 | {
2968 | gaincoeff -= 1;
2969 | gaincoeff = FloatAbs(gaincoeff);
2970 | }
2971 |
2972 | if(!g_bTouchesFuncRotating[client])
2973 | {
2974 | g_flRawGain[client] += gaincoeff;
2975 | }
2976 |
2977 | }
2978 | }
2979 | g_iTicksOnGround[client] = 0;
2980 | }
2981 | }
2982 |
2983 | bool IsInLeftRight(int client, int buttons)
2984 | {
2985 | bool isYawing = false;
2986 | if(buttons & IN_LEFT) isYawing = !isYawing;
2987 | if(buttons & IN_RIGHT) isYawing = !isYawing;
2988 | if(!(g_iYawSpeed[client] < 50.0 || isYawing == false))
2989 | {
2990 | return true;
2991 | }
2992 |
2993 | return false;
2994 | }
2995 |
2996 | float GetGainPercent(int client)
2997 | {
2998 | if(g_strafeTick[client] == 0)
2999 | {
3000 | return 0.0;
3001 | }
3002 |
3003 | float coeffsum = g_flRawGain[client];
3004 | coeffsum /= g_strafeTick[client];
3005 | coeffsum *= 100.0;
3006 | coeffsum = RoundToFloor(coeffsum * 100.0 + 0.5) / 100.0;
3007 |
3008 | return coeffsum;
3009 | }
3010 |
3011 | int GetDesiredTurnDir(int client, int button, bool opposite)
3012 | {
3013 | int direction = GetDirection(client);
3014 | int desiredTurnDir = -1;
3015 |
3016 | // if holding a and going forward then look for left turn
3017 | if(button == Button_Left && direction == Moving_Forward)
3018 | {
3019 | desiredTurnDir = Turn_Left;
3020 | }
3021 |
3022 | // if holding d and going forward then look for right turn
3023 | else if(button == Button_Right && direction == Moving_Forward)
3024 | {
3025 | desiredTurnDir = Turn_Right;
3026 | }
3027 |
3028 | // if holding a and going backward then look for right turn
3029 | else if(button == Button_Left && direction == Moving_Back)
3030 | {
3031 | desiredTurnDir = Turn_Right;
3032 | }
3033 |
3034 | // if holding d and going backward then look for left turn
3035 | else if(button == Button_Right && direction == Moving_Back)
3036 | {
3037 | desiredTurnDir = Turn_Left;
3038 | }
3039 |
3040 | // if holding w and going left then look for right turn
3041 | else if(button == Button_Forward && direction == Moving_Left)
3042 | {
3043 | desiredTurnDir = Turn_Right;
3044 | }
3045 |
3046 | // if holding s and going left then look for left turn
3047 | else if(button == Button_Back && direction == Moving_Left)
3048 | {
3049 | desiredTurnDir = Turn_Left;
3050 | }
3051 |
3052 | // if holding w and going right then look for left turn
3053 | else if(button == Button_Forward && direction == Moving_Right)
3054 | {
3055 | desiredTurnDir = Turn_Left;
3056 | }
3057 |
3058 | // if holding s and going right then look for right turn
3059 | else if(button == Button_Back && direction == Moving_Right)
3060 | {
3061 | desiredTurnDir = Turn_Right;
3062 | }
3063 |
3064 | if(opposite == true)
3065 | {
3066 | if(desiredTurnDir == Turn_Right)
3067 | {
3068 | return Turn_Left;
3069 | }
3070 | else
3071 | {
3072 | return Turn_Right;
3073 | }
3074 | }
3075 |
3076 | return desiredTurnDir;
3077 | }
3078 |
3079 | int GetDesiredButton(int client, int dir)
3080 | {
3081 | int moveDir = GetDirection(client);
3082 | if(dir == Turn_Left)
3083 | {
3084 | if(moveDir == Moving_Forward)
3085 | {
3086 | return Button_Left;
3087 | }
3088 | else if(moveDir == Moving_Back)
3089 | {
3090 | return Button_Right;
3091 | }
3092 | else if(moveDir == Moving_Left)
3093 | {
3094 | return Button_Back;
3095 | }
3096 | else if(moveDir == Moving_Right)
3097 | {
3098 | return Button_Forward;
3099 | }
3100 | }
3101 | else if(dir == Turn_Right)
3102 | {
3103 | if(moveDir == Moving_Forward)
3104 | {
3105 | return Button_Right;
3106 | }
3107 | else if(moveDir == Moving_Back)
3108 | {
3109 | return Button_Left;
3110 | }
3111 | else if(moveDir == Moving_Left)
3112 | {
3113 | return Button_Forward;
3114 | }
3115 | else if(moveDir == Moving_Right)
3116 | {
3117 | return Button_Back;
3118 | }
3119 | }
3120 |
3121 | return 0;
3122 | }
3123 |
3124 | int GetOppositeButton(int button)
3125 | {
3126 | if(button == Button_Forward)
3127 | {
3128 | return Button_Back;
3129 | }
3130 | else if(button == Button_Back)
3131 | {
3132 | return Button_Forward;
3133 | }
3134 | else if(button == Button_Right)
3135 | {
3136 | return Button_Left;
3137 | }
3138 | else if(button == Button_Left)
3139 | {
3140 | return Button_Right;
3141 | }
3142 |
3143 | return -1;
3144 | }
3145 |
3146 | int GetDirection(int client)
3147 | {
3148 | float vVel[3];
3149 | GetEntPropVector(client, Prop_Data, "m_vecVelocity", vVel);
3150 |
3151 | float vAng[3];
3152 | GetClientEyeAngles(client, vAng);
3153 |
3154 | float movementDiff = ArcTangent(vVel[1] / vVel[0]) * 180.0 / FLOAT_PI;
3155 |
3156 | if (vVel[0] < 0.0)
3157 | {
3158 | if (vVel[1] > 0.0)
3159 | movementDiff += 180.0;
3160 | else
3161 | movementDiff -= 180.0;
3162 | }
3163 |
3164 | if(movementDiff < 0.0)
3165 | movementDiff += 360.0;
3166 |
3167 | if(vAng[1] < 0.0)
3168 | vAng[1] += 360.0;
3169 |
3170 | movementDiff = movementDiff - vAng[1];
3171 |
3172 | bool flipped = false;
3173 |
3174 | if(movementDiff < 0.0)
3175 | {
3176 | flipped = true;
3177 | movementDiff = -movementDiff;
3178 | }
3179 |
3180 | if(movementDiff > 180.0)
3181 | {
3182 | if(flipped)
3183 | flipped = false;
3184 | else
3185 | flipped = true;
3186 |
3187 | movementDiff = FloatAbs(movementDiff - 360.0);
3188 | }
3189 |
3190 | if(-0.1 < movementDiff < 67.5)
3191 | {
3192 | return Moving_Forward; // Forwards
3193 | }
3194 | if(67.5 < movementDiff < 112.5)
3195 | {
3196 | if(flipped)
3197 | {
3198 | return Moving_Right; // Sideways
3199 | }
3200 | else
3201 | {
3202 | return Moving_Left; // Sideways other way
3203 | }
3204 | }
3205 | if(112.5 < movementDiff <= 180.0)
3206 | {
3207 | return Moving_Back; // Backwards
3208 | }
3209 | return 0; // Unknown should never happend
3210 | }
3211 |
3212 | stock void GetTurnDirectionName(int direction, char[] buffer, int maxlength)
3213 | {
3214 | if(direction == Turn_Left)
3215 | {
3216 | FormatEx(buffer, maxlength, "Left");
3217 | }
3218 | else if(direction == Turn_Right)
3219 | {
3220 | FormatEx(buffer, maxlength, "Right");
3221 | }
3222 | else
3223 | {
3224 | FormatEx(buffer, maxlength, "Unknown");
3225 | }
3226 | }
3227 |
3228 | stock void GetMoveDirectionName(int direction, char[] buffer, int maxlength)
3229 | {
3230 | if(direction == Moving_Forward)
3231 | {
3232 | FormatEx(buffer, maxlength, "Forward");
3233 | }
3234 | else if(direction == Moving_Back)
3235 | {
3236 | FormatEx(buffer, maxlength, "Backward");
3237 | }
3238 | else if(direction == Moving_Left)
3239 | {
3240 | FormatEx(buffer, maxlength, "Left");
3241 | }
3242 | else if(direction == Moving_Right)
3243 | {
3244 | FormatEx(buffer, maxlength, "Right");
3245 | }
3246 | else
3247 | {
3248 | FormatEx(buffer, maxlength, "Unknown");
3249 | }
3250 | }
3251 |
3252 | #if !defined TIMER
3253 |
3254 | /**
3255 | * Gets a client's velocity with extra settings to disallow velocity on certain axes
3256 | */
3257 | stock float GetClientVelocity(int client, bool UseX, bool UseY, bool UseZ)
3258 | {
3259 | float vVel[3];
3260 |
3261 | if(UseX)
3262 | {
3263 | vVel[0] = GetEntPropFloat(client, Prop_Send, "m_vecVelocity[0]");
3264 | }
3265 |
3266 | if(UseY)
3267 | {
3268 | vVel[1] = GetEntPropFloat(client, Prop_Send, "m_vecVelocity[1]");
3269 | }
3270 |
3271 | if(UseZ)
3272 | {
3273 | vVel[2] = GetEntPropFloat(client, Prop_Send, "m_vecVelocity[2]");
3274 | }
3275 |
3276 | return GetVectorLength(vVel);
3277 | }
3278 | #endif
3279 |
--------------------------------------------------------------------------------