[Include] Southclaw's & Pottus's Anti-cheat patches
#46

Efficient Simple Timer based Anti Weapon & Anti Ammo Hack
There are chances that the cheat may not be detected immediately since the code given below uses 1s timer. However, the player will eventually be identified if he is using a weapon or ammo cheat(This should happen within a few seconds). The smaller the interval, the higher is chance that every player using a weapon/ammo cheat is detected.

This code doesn't detect players who illegally get weapons unless they switch to it. In this way , this include is more efficient than the traditional weapon check methods where every slot is checked every time.

//The code can be optimized further to use char arrays
//Anti Ammo Hack works with high-fire-rate weapons

Last Updated:2013

Code:
#include <a_samp>
#include <izcmd>

#define INVALID_WEAPON 0
#define MAX_WEAPON_SLOTS 13
#define MAX_WEAPONS 47
/////////////////////////////////////////////////////////////////////////////////
static pWeaponData[MAX_PLAYERS][MAX_WEAPON_SLOTS];
static pAmmoData[MAX_PLAYERS][MAX_WEAPON_SLOTS];
static pAmmoWarns[MAX_PLAYERS];

static const WeaponSlot[MAX_WEAPONS] =
{
	0,0,1,1,1,1,1,1,1,1,10,10,10,10,10,10,8,8,8,-1,-1,-1,2,2,2,3,3,3,4,4,5,5,4,6,6,7,7,7,7,8,12,9,9,9,11,11,11
};
/////////////////////////////////////////////////////////////////////////////////
stock ac_SetPlayerAmmo(playerid,weaponslot,ammo)
{
	pAmmoData[playerid][weaponslot] = ammo;
	return SetPlayerAmmo(playerid,weaponslot,ammo);
}

#if defined _ALS_SetPlayerAmmo
    #undef SetPlayerAmmo
#else
    #define _ALS_SetPlayerAmmo
#endif
#define SetPlayerAmmo ac_SetPlayerAmmo

stock ac_GivePlayerWeapon(playerid,weaponid,ammo)
{
	pWeaponData[playerid][WeaponSlot[weaponid]] = weaponid;
	pAmmoData[playerid][WeaponSlot[weaponid]] = GetPlayerAmmo(playerid) + ammo;
	return GivePlayerWeapon(playerid,weaponid,ammo);
}

#if defined _ALS_GivePlayerWeapon
    #undef GivePlayerWeapon
#else
    #define _ALS_GivePlayerWeapon
#endif

#define GivePlayerWeapon ac_GivePlayerWeapon

stock ac_ResetPlayerWeapons(playerid)
{
	for(new i = 0; i < MAX_WEAPON_SLOTS;i++)
	{
		pWeaponData[playerid][i] = INVALID_WEAPON;
        pAmmoData[playerid][i] = 0;
	}
	return ResetPlayerWeapons(playerid);
}

#if defined _ALS_ResetPlayerWeapons
    #undef ResetPlayerWeapons
#else
    #define _ALS_ResetPlayerWeapons
#endif

#define ResetPlayerWeapons ac_ResetPlayerWeapons
/////////////////////////////////////////////////////////////////////////////////
forward WeaponCheck();
public WeaponCheck()
{
    static wid;
	for(new playerid = 0; playerid <= GetMaxPlayers(); playerid++)
	{
	    wid = GetPlayerWeapon(playerid);
	    if(wid == -1) continue; //INVALID WEAPON

		switch(GetPlayerState(playerid))
		{
		    case PLAYER_STATE_NONE,PLAYER_STATE_WASTED,PLAYER_STATE_SPAWNED: continue;
		}

     	if(pWeaponData[playerid][WeaponSlot[wid]] != wid)
		{
			new str[144],name[24],wname[24];
			GetPlayerName(playerid,name,sizeof(name));
		    GetWeaponName(wid,wname,sizeof(wname));
  			format(str,256,"%s(%d) suspected to be using Weapon Hacks (Weapon Name:%s)",name,playerid,wname);
		    SendClientMessageToAll(-1,str);
		}
		if(pAmmoData[playerid][WeaponSlot[wid]] < GetPlayerAmmo(playerid))
		{
		    if(++pAmmoWarns[playerid] == 3)
		    {
                pAmmoWarns[playerid] = 0;
			    new str[144],name[24],wname[24];
				GetPlayerName(playerid,name,sizeof(name));
			    GetWeaponName(wid,wname,sizeof(wname));
	  			format(str,256,"%s(%d) suspected to be using Ammo Hacks (Weapon Name:%s)",name,playerid,wname);
			    SendClientMessageToAll(-1,str);
			}
		}
		else pAmmoWarns[playerid] = 0;
		pAmmoData[playerid][WeaponSlot[wid]] = GetPlayerAmmo(playerid);
		continue;
	}
}
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
    pAmmoData[playerid][WeaponSlot[weaponid]]--;
    return 1;
}
/////////////////////////////////////////////////////////////////////////////////
main()
{

}
public OnGameModeInit()
{
	SetGameModeText("asdasdasd");
	AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
	SetTimer("WeaponCheck",1000,true);
	return 1;
}
public OnPlayerConnect(playerid)
{
    pAmmoWarns[playerid] = 0;
	ResetPlayerWeapons(playerid);
	return 1;
}
Reply


Messages In This Thread
Southclaw's & Pottus's Anti-cheat patches - by Pottus - 02.04.2014, 23:54
Re: Southclaw's & Pottus's Anti-cheat patches - by RenovanZ - 03.04.2014, 01:36
Re: Southclaw's & Pottus's Anti-cheat patches - by Whitetiger - 03.04.2014, 01:42
Re: Southclaw's & Pottus's Anti-cheat patches - by Pottus - 03.04.2014, 01:57
Re: Southclaw's & Pottus's Anti-cheat patches - by awsomedude - 03.04.2014, 03:50
Re: Southclaw's & Pottus's Anti-cheat patches - by Niko_boy - 03.04.2014, 03:54
Re: Southclaw's & Pottus's Anti-cheat patches - by Lorenc_ - 03.04.2014, 06:07
Re: Southclaw's & Pottus's Anti-cheat patches - by iZN - 03.04.2014, 08:12
Re: Southclaw's & Pottus's Anti-cheat patches - by Kar - 03.04.2014, 12:36
Re: Southclaw's & Pottus's Anti-cheat patches - by Pottus - 03.04.2014, 13:03
Re: Southclaw's & Pottus's Anti-cheat patches - by shittt - 03.04.2014, 13:15
Respuesta: Southclaw's & Pottus's Anti-cheat patches - by MugiwaraNoLuffy - 05.04.2014, 05:51
Re: Southclaw's & Pottus's Anti-cheat patches - by Kyle - 08.04.2014, 09:51
Re: Southclaw's & Pottus's Anti-cheat patches - by Admigo - 08.04.2014, 14:08
Re: Southclaw's & Pottus's Anti-cheat patches - by Kyra - 08.04.2014, 20:12
Re: Southclaw's & Pottus's Anti-cheat patches - by Pottus - 09.04.2014, 00:31
Respuesta: Re: Southclaw's & Pottus's Anti-cheat patches - by MugiwaraNoLuffy - 09.04.2014, 03:41
Re: Southclaw's & Pottus's Anti-cheat patches - by kristo - 13.04.2014, 13:18
Re: Southclaw's & Pottus's Anti-cheat patches - by Pottus - 13.04.2014, 13:22
Re: Southclaw's & Pottus's Anti-cheat patches - by SkittlesAreFalling - 14.04.2014, 03:46
Re: Southclaw's & Pottus's Anti-cheat patches - by iRaiDeN - 14.04.2014, 08:22
Re: Southclaw's & Pottus's Anti-cheat patches - by Kyra - 14.04.2014, 21:04
Re: Southclaw's & Pottus's Anti-cheat patches - by NoahF - 20.04.2014, 11:27
Re: Southclaw's & Pottus's Anti-cheat patches - by Kyra - 11.05.2014, 17:52
Re: Southclaw's & Pottus's Anti-cheat patches - by Pottus - 15.05.2014, 12:28
Re: Southclaw's & Pottus's Anti-cheat patches - by Admigo - 15.05.2014, 14:53
Re: Southclaw's & Pottus's Anti-cheat patches - by Kyra - 17.05.2014, 20:32
Re: Southclaw's & Pottus's Anti-cheat patches - by Chrillzen - 04.10.2014, 12:22
Re: Southclaw's & Pottus's Anti-cheat patches - by Chefгo - 28.10.2014, 14:03
Re: Southclaw's & Pottus's Anti-cheat patches - by Alex Magaсa - 28.10.2014, 15:48
Re: Southclaw's & Pottus's Anti-cheat patches - by Chefгo - 28.10.2014, 16:41
Re: Southclaw's & Pottus's Anti-cheat patches - by Pottus - 01.11.2014, 05:25
Re: Southclaw's & Pottus's Anti-cheat patches - by Pottus - 02.11.2014, 01:15
Re: Southclaw's & Pottus's Anti-cheat patches - by Killa[DGZ] - 02.11.2014, 01:24
Re: Southclaw's & Pottus's Anti-cheat patches - by Killa[DGZ] - 02.11.2014, 01:33
Re: Southclaw's & Pottus's Anti-cheat patches - by Pottus - 02.11.2014, 01:35
Re: Southclaw's & Pottus's Anti-cheat patches - by Killa[DGZ] - 02.11.2014, 01:39
Re: Southclaw's & Pottus's Anti-cheat patches - by Killa[DGZ] - 02.11.2014, 02:28
Re: Southclaw's & Pottus's Anti-cheat patches - by Jakwob - 18.11.2014, 19:51
Re: Southclaw's & Pottus's Anti-cheat patches - by PaulDinam - 15.01.2015, 13:16
Re: Southclaw's & Pottus's Anti-cheat patches - by HydraHumza - 01.03.2015, 03:53
Re: Southclaw's & Pottus's Anti-cheat patches - by Yashas - 02.05.2015, 15:02
Re: Southclaw's & Pottus's Anti-cheat patches - by Pottus - 02.05.2015, 15:05
Re: Southclaw's & Pottus's Anti-cheat patches - by GameR16 - 01.06.2015, 14:51
Re: Southclaw's & Pottus's Anti-cheat patches - by anime107 - 15.07.2015, 21:55
Re: Southclaw's & Pottus's Anti-cheat patches - by Yashas - 05.10.2015, 09:37
Re: Southclaw's & Pottus's Anti-cheat patches - by qilia - 07.10.2015, 23:43
Re: Southclaw's & Pottus's Anti-cheat patches - by thaKing - 08.10.2015, 04:28
Re: Southclaw's & Pottus's Anti-cheat patches - by T-N-Z - 21.11.2015, 20:27
Re: Southclaw's & Pottus's Anti-cheat patches - by Yashas - 22.11.2015, 11:38
Re: Southclaw's & Pottus's Anti-cheat patches - by Mister0 - 22.08.2016, 22:16
Re: Southclaw's & Pottus's Anti-cheat patches - by Abagail - 22.08.2016, 23:27
Re: Southclaw's & Pottus's Anti-cheat patches - by PT - 14.01.2017, 19:48

Forum Jump:


Users browsing this thread: 1 Guest(s)