Simple anti infinite ammo - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Simple anti infinite ammo (
/showthread.php?tid=610311)
Simple anti infinite ammo -
Lajko1 - 22.06.2016
Hey.
What I'm trying to do is simple detection for infinite ammo, when I tested it with another person it worked fine.
When it's on server, it detect the infinite ammo but often detects a player without hacks also, so the code I tried is the following:
pawn Код:
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
OldAmmo[playerid] = GetPlayerAmmo(playerid);
SetTimerEx("CheckUnlimitedAmmo", 500, false, "i", playerid);
return 1;
}
public CheckUnlimitedAmmo(playerid)
{
new msg[128];
NewAmmo[playerid] = GetPlayerAmmo(playerid);
if (OldAmmo[playerid] == NewAmmo[playerid]){
format(msg,sizeof(msg),"[AC] Possible infinite ammo hack on %s",GetPlayerNameEx(playerid, ENameType_CharName));
ABroadcast(X11_YELLOW, msg, EAdminFlags_All);
}
return true;
Where is the problem that script detects a player without hacks also ? :/
Re: Simple anti infinite ammo -
SyS - 22.06.2016
the true boolean is returning after if statement put it inside and false boolean outside
Re: Simple anti infinite ammo -
Stinged - 22.06.2016
GetPlayerAmmo under OnPlayerWeaponShot returns the player's current ammo.
So NewAmmo[playerid] and OldAmmo[playerid] would be the same.
Try something like this:
Код:
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
new ammo = GetPlayerAmmo(playerid);
if (ammo != OldAmmo[playerid] - 1)
{
// Possible hacks
}
OldAmmo[playerid] = ammo;
return 1;
}