View difference between Paste ID: JrSsw4nK and WAzYJJBJ
SHOW: | | - or go back to the newest paste.
1
/*
2
	Extremely simple CBug detector/Anti-CBug
3
	Version 1.0 (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
19
// is treated as CBug
20
#define CBUG_INTERVAL	700
21
22
23
// Used for getting shot intervals
24
new lastDShot[MAX_PLAYERS];
25
26
// If 1, extra cbug shots are unsynced automatically
27
new removeCBugs = 1;
28
// If 1, OnPlayerCBug is called on cbug usages
29
new alertCBugs = 1;
30
31
32
// Callback forward
33
forward OnPlayerCBug(playerid, interval);
34
35
36
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
37
{	
38
	// Avoid driveby false alarms
39
	if (!IsPlayerInAnyVehicle(playerid) && (removeCBugs || alertCBugs))
40
	{
41-
			if (GetTickCount() - lastDShot[playerid] < 700 && GetTickCount() - lastDShot[playerid] >= 0)
41+
42
		if (weaponid == 24)
43
		{
44
			// Normal deagle shots shouldnt be faster than 700ms
45
			// Check if time difference is positive to avoid GetTickCount-reset false alarms
46
			if (GetTickCount() - lastDShot[playerid] < CBUG_INTERVAL && GetTickCount() - lastDShot[playerid] >= 0)
47
			{				
48
				if (alertCBugs) CallLocalFunction("OnPlayerCBug", "ii", playerid, GetTickCount() - lastDShot[playerid]);
49
				return !removeCBugs;
50
			}
51
			lastDShot[playerid] = GetTickCount();
52
		}
53
	}
54
	return CallLocalFunction("ACBUG_OnPlayerWeaponShot", "iiiifff", playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ);
55
}
56
#if defined _ALS_OnPlayerWeaponShot
57
	#undef OnPlayerWeaponShot
58
#else
59
	#define _ALS_OnPlayerWeaponShot
60
#endif
61
#define OnPlayerWeaponShot ACBUG_OnPlayerWeaponShot
62
forward ACBUG_OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ);