//Local
new
LastSavedAmmo[ MAX_PLAYERS ],
LastSavedWeapon[ MAX_PLAYERS ],
CurrentAmmo[ MAX_PLAYERS ],
CurrentWeapon[ MAX_PLAYERS ],
CanCheckDifference[ MAX_PLAYERS ]
;
//OnPlayerConnect
LastSavedAmmo[playerid] = 0;
LastSavedWeapon[playerid] = 0;
CurrentAmmo[playerid] = 0;
CurrentWeapon[playerid] = 0;
//OnPlayerWeaponShot
if(LastSavedWeapon[playerid] == CurrentWeapon[playerid] && CanCheckDifference[playerid])
{
if(LastSavedAmmo[playerid] == CurrentAmmo[playerid])
{
SendClientMessage(playerid, -1, "Bad boy, stop using hax pls ;_;");
}
else
{
SendClientMessage(playerid, -1, "Good boy, no ammo hax :)");
}
}
//Timers and other stuff..
forward AllowChecking(playerid);
public AllowChecking(playerid)
{
CanCheckDifference[playerid] = 1;
SendClientMessage(playerid, -1, "CanCheckDifference = 1");
return 1;
}
forward AntiAmmoHack();
public AntiAmmoHack()
{
foreach(Player, i)
{
CurrentAmmo[i] = GetPlayerAmmo(i);
CurrentWeapon[i] = GetPlayerWeapon(i);
CanCheckDifference[i] = 0;
SetTimerEx("AllowChecking", 500, false, "i", i);
SendClientMessage(i, -1, "CurrentAmmo + CurrentWeapon + CanCheckDifference = 0");
}
return 1;
}
//Timer where i store 'LastSavedWeapon'/Ammo
forward AntiCheat();
public AntiCheat()
{
//many things here
foreach(Player, i)
{
//things here
switch(GetPlayerWeapon(i))
{
case 16..43:
{
LastSavedAmmo[i] = GetPlayerAmmo(i);
LastSavedWeapon[i] = GetPlayerWeapon(i);
SendClientMessage(i, -1, "LastSavedAmmo + LastSavedWeapon used now");
}
}
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
new WeaponAmmo, WeaponType, i = GetWeaponSlot(weaponid); GetPlayerWeaponData(playerid, i, WeaponType, WeaponAmmo);
if(!IsPlayerInAnyVehicle(playerid) && GetPVarInt(playerid,"Last_Ammo") == WeaponAmmo)
{
SetPVarInt(playerid, "Ammo_Warnings", GetPVarInt(playerid,"Ammo_Warnings") + 1);
if(GetPVarInt(playerid,"Ammo_Warnings") == 8) //Detected ammo value is not changing.
{
SetPVarInt(playerid,"Ammo_Warnings",0);
new string[128]; format(string,sizeof(string),"Player ID: %d's ammo value hasn't changed in 8 shots.",playerid);
SendClientMessageToAll(COLOR_WHITE, string);
}
}
else SetPVarInt(playerid,"Ammo_Warnings",0);
SetPVarInt(playerid,"Last_Ammo",WeaponAmmo);
}
//GetWeaponSlot was created by another SAMP Forums user whom I can't remember (Sorry to whoever made it lol).
stock GetWeaponSlot(weaponid)
{
new slot;
switch(weaponid)
{
case 0,1: slot = 0;
case 2 .. 9: slot = 1;
case 10 .. 15: slot = 10;
case 16 .. 18, 39: slot = 8;
case 22 .. 24: slot =2;
case 25 .. 27: slot = 3;
case 28, 29, 32: slot = 4;
case 30, 31: slot = 5;
case 33, 34: slot = 6;
case 35 .. 38: slot = 7;
case 40: slot = 12;
case 41 .. 43: slot = 9;
case 44 .. 46: slot = 11;
}
return slot;
}
Hi, I made a simple code to detect this the other day, it works well but can't detect users who are in a vehicle (Limitations with the OnPlayerWeaponShot Function).
You can change the 8 value but there was a few false detects when it was set to just 1, 8 is still detected very quickly (Go In-game and shoot). pawn Код:
|