Anti Ammo hack problem
#1

Okay so there's a anti hack thread
pawn Код:
if (HOLDING(KEY_FIRE))
     {
          ammo[playerid] = GetPlayerAmmo(playerid);
          weapon[playerid] = GetPlayerWeapon(playerid);
          if(!IsValidWeapon(weapon[playerid])) return 0;
          for(new i=0; i<7;i++) // Use any amount of iteration ( 5 or more is recommended)
          {
              n_ammo[playerid] = GetPlayerAmmo(playerid);
              n_weapon[playerid] = GetPlayerWeapon(playerid);
          }
          if(n_weapon[playerid] == weapon[playerid] && n_ammo[playerid] == ammo[playerid])
          {
            new str[128];
            new string[128], pName[MAX_PLAYER_NAME];
            GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
            cheatdetect[playerid]++;
            format(str, 128, "[ANTI CHEAT ALERT] Cheat Detected: %s(%d). [Reason: Ammo Hack]", pName,playerid);
            SendAdminMessage(COLOR_PINK,str);
            if(cheatdetect[playerid] > 1)
            {
               GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
               format(string,sizeof(string),"[ANTI CHEAT] Anti-Cheat has banned %s(%d). [Reason: Cheats Detected]",pName,playerid);
               SendClientMessageToAll(COLOR_PINK,string);

               format(string,sizeof(string),"1[ANTI CHEAT] Anti-Cheat has banned %s(%d). [Reason: Cheats Detected]",pName,playerid);
               IRC_GroupSay(gGroupID,IRC_CHANNEL,string);
               IRC_GroupSay(gGroupID,IRC_ADMINCHANNEL,string);

               format(string, sizeof(string), "~r~BANNED!");
               GameTextForPlayer(playerid, string, 3000, 1);

               new INI: File = INI_Open(UserPath(playerid));
               INI_SetTag(File,"Player's Data");
               INI_WriteString(File,"BanReason","Cheats Detected");
               INI_Close(File);
               PlayerInfo[playerid][pBanned] =1;

               SetTimerEx("KickPlayer",1000,false,"i",playerid);
            }
          }
    }
no compiling errors, but there is no hacks activated, and the ammo decreases, still bans
anyone?
Reply
#2

bump
Reply
#3

First off you shouldnt be banning someone for this because there are many ways that it can go bad. You are being way too trusting by banning after cheatDetected[playerid] gets incremented twice.

Anyway in terms of your problem, the first thing I see is directly after you check if he's holding fire, you update his server-side weapon information. What you need to do is compare what his ammo is NOW with what it was the last time you checked (the values that -should- be in n_ammo and n_weapon.

Secondly:

pawn Код:
for(new i=0; i<7;i++) // Use any amount of iteration ( 5 or more is recommended)
          {
              n_ammo[playerid] = GetPlayerAmmo(playerid);
              n_weapon[playerid] = GetPlayerWeapon(playerid);
          }
You aren't even using i in that iteration, all this code does is update his ammo 7 times, something you already did 2 lines above, so I really don't see what this code is doing for you.

In an anti-ammo hack (aka no reload), you wanna check to see if his ammo is the same as what it was a few seconds ago, while the player is shooting. The definition of "shooting" takes some extra work to do, I will come back to this later.

Here's a quick snippet to work with:

pawn Код:
if (isShooting{playerid}) { //Determining when he is and isn't shooting requires some work, you cannot just use if (HOLDING(KEY_FIRE))
        new weapon, ammo;
        GetPlayerWeaponData(playerid, GetPlayerWeaponSlot(playerid), weapon, ammo);
       
        if ((ammo == n_ammo[i]) && ammo > 0 && !isPlayerInIdleVehicle(playerid)) { //If a player is idle DBing, OPU stops getting called so it doesn't update his ammo
                       
            if (alreadyDetectedOnce{playerid}) { //We need to watch him for at least a few seconds to determine if he's doing no reload.
                new str[126];
                format(str, sizeof(str), "%s[%i] - %s ammo stuck at %i", playerName(playerid), playerid, GetWeaponName(GetPlayerWeapon(playerid)), lastAmmo[playerid]);
                SendAdminMessage(COLOR_PINK,str);
                alreadyDetectedOnce{playerid} = false;
               
                //Increment his cheat counts
               
                cheatdetect[playerid]++;
               
                if(cheatdetect[playerid] > 6)
                   GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
                   format(string,sizeof(string),"[ANTI CHEAT] Anti-Cheat has banned %s(%d). [Reason: Cheats Detected]",pName,playerid);
                   SendClientMessageToAll(COLOR_PINK,string);

                   format(string,sizeof(string),"1[ANTI CHEAT] Anti-Cheat has banned %s(%d). [Reason: Cheats Detected]",pName,playerid);
                   IRC_GroupSay(gGroupID,IRC_CHANNEL,string);
                   IRC_GroupSay(gGroupID,IRC_ADMINCHANNEL,string);

                   format(string, sizeof(string), "~r~BANNED!");
                   GameTextForPlayer(playerid, string, 3000, 1);

                   new INI: File = INI_Open(UserPath(playerid));
                   INI_SetTag(File,"Player's Data");
                   INI_WriteString(File,"BanReason","Cheats Detected");
                   INI_Close(File);
                   PlayerInfo[playerid][pBanned] =1;

                   SetTimerEx("KickPlayer",1000,false,"i",playerid);
                }
            }
            else {
                alreadyDetectedOnce{playerid} = true;
            }
        }
    }
After you verify that this works but the definition of "shooting" doesn't work, there are a few things you need to know.

-As stated, if someone is idle DBing, his ammo doesn't update so you need to excuse him.
-Holding down the fire key does not mean he is shooting a gun, what if he's in a car or spectating? What if he's doing an animation and holding down the fire key? What if he's shooting rustler guns?
-You need to compensate for when he is doing driver DB, do your no reload checks for this.
-Make sure he actually has a gun that can be used for doing a no reload hack (ex. doing no reload with chainsaw is impossible)

I will leave you to find out how to do all this compensation, but if you have any questions about what to actually do after verifying that he is in fact shooting, feel free to ask.
Reply
#4

Thanks mate, that was pro
I appreciate that, I'll take time in that
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)