SA-MP Forums Archive
[FilterScript] Aero's Anti-Cheat - 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: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+--- Thread: [FilterScript] Aero's Anti-Cheat (/showthread.php?tid=515775)



Aero's Anti-Cheat - Aerotactics - 27.05.2014

Aero's Anti-Cheat
About
I couldn't find an anti-cheat that fit my needs, and I wanted one that didn't require me to change my GM in order to see if it worked. This script runs right out of the box, and you don't need to edit your gamemode AT ALL! This filterscript is very basic, in that it will spot obvious hacks, but won't catch everything. If you want to get a better anti-cheat than this, expect to rewrite half your gamemode just to see if it still works.

Features
pawn Код:
/*
Features:
-Anti Weapon Hack
-Anti Money Hack
-Anti Health Hack
-Anti Armour Hack
-Anti Vehicle Health Hack
-Anti God Mode
-Anti Fly Hack
*/
Settings
pawn Код:
new BanWeap[] = { 35, 36, 37, 38, 44, 45};
new Max_Cash = 9999999;
new Cash_Increment = 1000;
new bool:BanPlayers = false;
BanWeap[] - These are the weapon IDs you wish to ban from the server

Max_Cash - exactly as it sounds, the maximum amount of cash a player is able to have at any time.

Cash_Increment - the maximum amount of money a player can receive at any given time.

BanPlayers - if set to true, bans any cheating players, else it just kicks them.

Script
pawn Код:
//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\//
//                            Aero's Anti-Cheat                               //
//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\//
/*
Features:
-Anti Weapon Hack
-Anti Money Hack
-Anti Health Hack
-Anti Armour Hack
-Anti Vehicle Health Hack
-Anti God Mode
-Anti Fly Hack
*/

#define FILTERSCRIPT

#include <a_samp>

#if defined FILTERSCRIPT
public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" Aero's Anticheat Filterscript");
    print("--------------------------------------\n");
    return 1;
}
#endif

//Defines
#define COLOR_WHITE 0xFFFFFFFF
#define COLOR_RED 0xAA0000FF
#define COLOR_GOLD 0xDCB700FF
#define COLOR_GREEN 0x00AA00FF
#define COLOR_BLUE 0x0000AAFF

#define SCM SendClientMessage
#define SCMA SendClientMessageToAll
#define SCMX SendClientMessageEx

//Settings and Variables
new BanWeap[] = { 35, 36, 37, 38, 44, 45};
new Max_Cash = 9999999;
new Cash_Increment = 1000;
new bool:BanPlayers = false;

new Tag[6] = "[AAC]";
new NewCash[MAX_PLAYERS];
new OldCash[MAX_PLAYERS];
new TIMER_Kick[MAX_PLAYERS];
new TIMER_Spawn[MAX_PLAYERS];
new bool:Damaged[MAX_PLAYERS] = false;
new bool:Spawned[MAX_PLAYERS] = false;
new Float:GodHealth, Float: GodArmour;
forward OneSecTimer();
forward KickTimer(playerid);
forward SpawnTimer(playerid);

//Stocks
stock SendClientMessageEx(playerid, color, message[128])
{
    new str[128];
    format(str,sizeof(str),"%s: %s", Tag, message);
    SCM(playerid,color,str);
    return 1;
}
stock KickMessages(playerid, reason[128])
{
    new str[128];
    format(str,sizeof(str),"%s: You were kicked from the server for %s.", Tag, reason);
    SCM(playerid,COLOR_RED,str);
    new str2[128];
    format(str2,sizeof(str2),"%s: %s was kicked from the server for %s.", Tag, GetName(playerid), reason);
    SCMA(COLOR_GREEN,str2);
    return 1;
}
stock GetName(playerid)
{
    new name[48];
    GetPlayerName(playerid,name,sizeof(name));
    return name;
}
stock BanKick(playerid)
{
    if(BanPlayers == true){Ban(playerid);}
    else{Kick(playerid);}
    return 1;
}

//Timers
public OneSecTimer()
{
    for (new playerid=0;playerid<MAX_PLAYERS;playerid++)
    {
        if(Spawned[playerid] == false) continue;
        new Gun = 0;
        GunLoop:
        if(GetPlayerWeapon(playerid) == BanWeap[Gun])
        {
            KickMessages(playerid,"Weapon Hacking");
            TIMER_Kick[playerid] = SetTimerEx("KickTimer",1000,false,"i",playerid);
        }
        Gun++;
        if(Gun < sizeof(BanWeap))goto GunLoop;
        NewCash[playerid] = GetPlayerMoney(playerid);
        if(NewCash[playerid] > Max_Cash || OldCash[playerid] + Cash_Increment < NewCash[playerid])
        {
            KickMessages(playerid,"Money Hacking");
            TIMER_Kick[playerid] = SetTimerEx("KickTimer",1000,false,"i",playerid);
            ResetPlayerMoney(playerid);
            GivePlayerMoney(playerid, OldCash[playerid]);
        }
        OldCash[playerid] = GetPlayerMoney(playerid);
        new Float:Health, Float:Armour;
        GetPlayerHealth(playerid, Health);
        GetPlayerArmour(playerid, Armour);
        if (Health > 100 || Armour > 100)
        {
            KickMessages(playerid,"Health/Armour Hacking");
            TIMER_Kick[playerid] = SetTimerEx("KickTimer",1000,false,"i",playerid);
        }
        GodHealth = Health;
        GodArmour = Armour;
        if(IsPlayerInAnyVehicle(playerid))
        {
            new vehicleid = GetPlayerVehicleID(playerid), Float: vHealth;
            if(GetVehicleHealth(vehicleid, vHealth) > 1000)
            {
                KickMessages(playerid,"Vehicle Health Hacking");
                TIMER_Kick[playerid] = SetTimerEx("KickTimer",1000,false,"i",playerid);
            }
        }
        new Float:Pos_x,Float:Pos_y,Float:Pos_z;
        new anim = GetPlayerAnimationIndex(playerid);
        GetPlayerVelocity(playerid,Pos_x,Pos_y,Pos_z);
        if((Pos_x <= -0.800000  || Pos_y <= -0.800000 || Pos_z <= -0.800000) && (anim == 1008 || anim == 1539))
        {
            KickMessages(playerid,"Fly Hacking");
            TIMER_Kick[playerid] = SetTimerEx("KickTimer",1000,false,"i",playerid);
        }
    }
    return 1;
}

public KickTimer(playerid)
{
    BanKick(playerid);
    KillTimer(TIMER_Kick[playerid]);
    return 1;
}

public SpawnTimer(playerid)
{
    OldCash[playerid] = GetPlayerMoney(playerid);
    Spawned[playerid] = true;
    KillTimer(TIMER_Spawn[playerid]);
    return 1;
}

//General Script
public OnGameModeInit()
{
    SetTimer("OneSecTimer",1000,true);
    return 1;
}

public OnGameModeExit()
{
    return 1;
}

public OnPlayerConnect(playerid)
{
    SCMX(playerid, COLOR_GOLD, "This server is protected by Aero's Anti-Cheat.");
    Damaged[playerid] = false;
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    Spawned[playerid] = false;
    Damaged[playerid] = false;
    return 1;
}

public OnPlayerSpawn(playerid)
{
    TIMER_Spawn[playerid] = SetTimerEx("SpawnTimer",3000,true,"i",playerid);
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    Spawned[playerid] = false;
    Damaged[playerid] = false;
    return 1;
}

public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart)
{
    if(issuerid != INVALID_PLAYER_ID)
    {
        new Float:Health,Float:Armour;
        if(GetPlayerHealth(playerid, Health) == GodHealth || GetPlayerArmour(playerid, Armour) == GodArmour)
        {
            KickMessages(playerid,"God Mode");
            TIMER_Kick[playerid] = SetTimerEx("KickTimer",1000,false,"i",playerid);
            return 1;
        }
    }
    return 1;
}
Download: Mediafire


Re: Respuesta: Aero's Anti-Cheat - Aerotactics - 27.05.2014

Quote:
Originally Posted by SkyT
Посмотреть сообщение
pawn Код:
if(GetPlayerHealth(playerid, Health) == GodHealth)
Well, if "1" == "GodHealth", is because the player got GodMode?
GodHealth is a variable used to get their health before they take damage, and after they take damage, if it's the same as before taking damage, then they are cheating.


Re: Aero's Anti-Cheat - awsomedude - 27.05.2014

For health hacks OnPlayerTakeDamage does not get called.


Re: Aero's Anti-Cheat - VenomMancer - 27.05.2014

Fly hack works ?


Re: Aero's Anti-Cheat - Aerotactics - 27.05.2014

Quote:
Originally Posted by VenomMancer
Посмотреть сообщение
Fly hack works ?
Yup, but it wont detect airbrake, sorry.

Quote:
Originally Posted by awsomedude
Посмотреть сообщение
For health hacks OnPlayerTakeDamage does not get called.
Alright, I'll look into an update on this FS, thanks for the feedback!


Re: Aero's Anti-Cheat - SickAttack - 27.05.2014

You should add more features, and what awesomedude said is true.


Re: Aero's Anti-Cheat - GeekSiMo - 27.05.2014

Good '!!


Re: Aero's Anti-Cheat - Aerotactics - 27.05.2014

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
You should add more features, and what awesomedude said is true.
Alright thanks. If you've got more ideas, lay them on me. So far I was thinking of adding anti-airbrake.


Re: Aero's Anti-Cheat - iAnonymous - 27.05.2014

Neat work buddy


Re: Aero's Anti-Cheat - Dangjai - 27.05.2014

good job


Re: Aero's Anti-Cheat - SickAttack - 28.05.2014

Okay here's some of my ideas/suggestions:
- Don't ban players, prevent them from using it (Ex exception: Anti no-reload hacks - kick).
- Add more cheat detections (Ex: Anti refill health hacks, Anti armour refill hacks, Anti no-reload hacks, Anti money spawn hacks, Anti unlimited health hacks, Anti vehicle teleportation (Mass & normal), Anti airbreak, Anti weapon spawn hacks, Anti speed hacks (Vehicle), Anti run-fast hacks, Anti cam hacks (Player is able to shoot other players while he's in a different position), Anti pro-aim.cs hacks, Anti dialog spoof, Anti joystick (Controller) system, Anti keybinds (Ex: You'll have to wait 0.75ms to use another command), etc).
- Code optimization.

Good luck!


Re: Aero's Anti-Cheat - Team_PRO - 28.05.2014

good job


Re: Aero's Anti-Cheat - VenomMancer - 28.05.2014

I will text when i am at home


Re: Aero's Anti-Cheat - punklord - 28.05.2014

Good work Aero. Looks clean and nice.


Re: Aero's Anti-Cheat - iRaiDeN - 28.05.2014

Nice!


Re: Aero's Anti-Cheat - KayJ - 28.05.2014

Super Cool, +rep