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