20.06.2014, 06:43
I tried to make an Infinite-Ammo cheat detection, but for some reason, the script doesn't want to work..
I tried debugging it ( you can see by the messages ), but that doesn't work either.
pawn Код:
//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");
}
}