SHOW:
|
|
- or go back to the newest paste.
| 1 | /* | |
| 2 | Extremely simple CBug detector/Anti-CBug | |
| 3 | Version 1.1 (1/23/2014) | |
| 4 | ||
| 5 | Made by Mauzen (msoll(at)web.de) | |
| 6 | Special thanks to pds2k12 | |
| 7 | ||
| 8 | This include allows to unsync extra deagle shots automatically, | |
| 9 | and calls OnPlayerCBug once a cbug was detected. | |
| 10 | ||
| 11 | Use as you like, but dont remove this header. | |
| 12 | */ | |
| 13 | ||
| 14 | #if (!defined VectorSize) | |
| 15 | #error "The Anti-CBug include requires at least SA-MP 0.3z RC3" | |
| 16 | #endif | |
| 17 | ||
| 18 | ||
| 19 | // The minimum intervals between two shots, everything below that | |
| 20 | // is treated as CBug | |
| 21 | #define CBUG_INTERVAL_DEAGLE 700 | |
| 22 | #define CBUG_INTERVAL_SHOTGUN 1000 | |
| 23 | #define CBUG_INTERVAL_COMBATSG 340 | |
| 24 | #define CBUG_INTERVAL_COUNTRY 850 | |
| 25 | #define CBUG_INTERVAL_SNIPER 850 | |
| 26 | ||
| 27 | ||
| 28 | // Used for getting shot intervals | |
| 29 | new lastDShot[MAX_PLAYERS]; | |
| 30 | ||
| 31 | // If 1, extra cbug shots are unsynced automatically | |
| 32 | new removeCBugs = 1; | |
| 33 | // If 1, OnPlayerCBug is called on cbug usages | |
| 34 | new alertCBugs = 1; | |
| 35 | ||
| 36 | ||
| 37 | // Callback forward | |
| 38 | forward OnPlayerCBug(playerid, weaponid, interval); | |
| 39 | ||
| 40 | ||
| 41 | public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ) | |
| 42 | {
| |
| 43 | // Avoid driveby false alarms | |
| 44 | if (!IsPlayerInAnyVehicle(playerid) && (removeCBugs || alertCBugs)) | |
| 45 | {
| |
| 46 | new interval = 0; | |
| 47 | switch (weaponid) | |
| 48 | {
| |
| 49 | case 24: interval = CBUG_INTERVAL_DEAGLE; | |
| 50 | case 25: interval = CBUG_INTERVAL_SHOTGUN; | |
| 51 | case 27: interval = CBUG_INTERVAL_COMBATSG; | |
| 52 | case 33: interval = CBUG_INTERVAL_COUNTRY; | |
| 53 | case 34: interval = CBUG_INTERVAL_SNIPER; | |
| 54 | } | |
| 55 | ||
| 56 | // Check if used weapon is a CBug-Weapon | |
| 57 | if (interval > 0) {
| |
| 58 | // Check if time difference is positive to avoid GetTickCount-reset false alarms | |
| 59 | if (GetTickCount() - lastDShot[playerid] < interval && GetTickCount() - lastDShot[playerid] >= 0) | |
| 60 | {
| |
| 61 | if (alertCBugs) CallLocalFunction("OnPlayerCBug", "iii", playerid, weaponid, GetTickCount() - lastDShot[playerid]);
| |
| 62 | return !removeCBugs; | |
| 63 | } | |
| 64 | lastDShot[playerid] = GetTickCount(); | |
| 65 | } | |
| 66 | } | |
| 67 | #if defined ACBUG_OnPlayerWeaponShot | |
| 68 | return ACBUG_OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ); | |
| 69 | #else | |
| 70 | return 1; | |
| 71 | #endif | |
| 72 | } | |
| 73 | #if defined _ALS_OnPlayerWeaponShot | |
| 74 | #undef OnPlayerWeaponShot | |
| 75 | #else | |
| 76 | #define _ALS_OnPlayerWeaponShot | |
| 77 | #endif | |
| 78 | #define OnPlayerWeaponShot ACBUG_OnPlayerWeaponShot | |
| 79 | #if defined ACBUG_OnPlayerWeaponShot | |
| 80 | forward ACBUG_OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ); | |
| 81 | #endif |