[Tutorial] How to create a "plain & simple" anti-armour hacks
#1

Note: This is not recommended for advanced scripters, or servers that have a high population because hackers and cheaters may easily bypass this and simply set their armour to 99 instead of 100, you have been warned.

Part I: The Introduction
Tired of these armour hackers and you want to get rid of them? Face no fear, with this plain and basic tutorial, you will be able to stop cheaters from spawning health! Great news, right?

Part II: The Code
pawn Code:
forward OneSecondTimer(); // This is required for every public you want to create, it defines your public callback.
public OneSecondTimer() // In this case, we want to call this little timer, "OneSecondTimer"
{ // Start

    for(new i = 0; i < MAX_PLAYERS; i++) // Basic loop to run this procedure on all players.
    { // Start
        if(IsPlayerConnected(i)) // It verifies and confirms if the player is connected.
        { // Start
            new Float: armor; // Armors are all float.  We need this to be able to use the GetPlayerArmor.
            new GetArmor = GetPlayerArmour(i, armor); // We want to make it a little shorter, so decided to name GetPlayerArmor with GetArmor to make it easier and faster to type.

            if(GetArmor > 99 && !IsPlayerAdmin(playerid)) // It checks if the player armor's is above 99, and he is not an RCON administrator, therefore, RCON administrators will not have themselves kicked for hacks.
            { // Start
                new string[256], pname[MAX_PLAYER_NAME]; // We define a string to be using for SendClientMessage() which means to send a message to a specific person,
// or SendClientMessageToAll() to send a message to all online players, so as we have defined pname to get the cheater's or hacker's name to be able to announce it to the server.
                GetPlayerName(playerid, pname, sizeof(pname)); // We use GetPlayerName() to get the player's name, self explanatory.
                format(string, sizeof(string), "[Anti Cheat] %s has been automatically kicked for possible armour hacks.", pname); // Here we attach a whole text to the string, you may change this as you want, %s refers to the player's name, as at the end, you can see "pname" which means the first %s you can find
// will be the first thing defined after the text, in this case, %s refers to pname, which is the player's name.
                SendClientMessageToAll(0xFF0000FF, string); // This sends a client message to all online players in the server and announce that string we have created.
                Kick(i); // This kicks the player out of the server, of course, we need to put this at last so we can receive player's name and specific information.
            } // Close
        } // Close
    } // Close
} // Close
You might be asking yourself, how do we actually get the script to begin functioning with this new public thing I have created? Ehh, the answer is easy - now, open up your gamemode, or filterscript and search for:
pawn Code:
public OnGameModeInit()
If you're implementing this to a gamemode of course, and if you're implementing this to a filterscript, search for:
pawn Code:
public OnFilterScriptInit()
instead.

Add the following line anywhere under the starting bracket and before the ending bracket:
pawn Code:
SetTimer("OneSecondTimer", 1000, 1);
Here we set a timer that will be running every 1000 milliseconds, we all know a little maths, right? One thousand millisecond equals one second, now if you're wondering, what's that "1" at the end? That one can also be replaced with 'true', therefore it'll be either:
pawn Code:
SetTimer("OneSecondTimer", 1000, true);
or the first one, which is "1" - this means to enable the timer, therefore, if you set this to 0 (aka. false) it will not run and will be there in your script for nothing, unless you have disabled it for a reason.


Part III: The Replacement
Open your pawn client and hold (CTRL + H) then in the search field, put:
pawn Code:
SetPlayerArmour(playerid, 100);
and in the replacement field, place:
pawn Code:
SetPlayerArmour(playerid, 99);
Obviously, repeat this process about 5 to 10 times as we will want to make sure that all SetPlayerArmour() that are supposed to be 100, set to 99 - of course, replace playerid with i, id, giveplayerid, etc.

Part IV: Frequently Asked Questions (FAQ)
What if I want to ban the user instead?
We do not recommend that, but hey - okay, replace:
pawn Code:
Kick(i);
with:
pawn Code:
Ban(i);
or:

pawn Code:
BanEx(i, "Armour Hacking");
to have your ban list more organized.
Hey, some cheaters are not getting banned, why!?
If you would only read the title of the thread, and the note at the top of the thread, you would realize why - it's because they can bypass it by simply changing their set armour values to 99 instead, but most of them are clueless and just install-and-run so they have absolutely no idea how to do it, just experienced armour hackers do know how to bypass this.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)