SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts > Includes

Reply
 
Thread Tools Display Modes
Old 19/04/2019, 08:52 AM   #1
Lorenc_
High-roller
 
Lorenc_'s Avatar
 
Join Date: Jan 2010
Location: Australia
Posts: 3,800
Reputation: 1160
Default Irresistible Anticheat & Weapon Shot Sync System (Lightweight)

Irresistible Anticheat

An extension of my renowned fuckCleo project. More up to date and more powerful.

The anticheat handles everything included in this enumerator (including the commented parts).

The whole system is modular, so ideally you can copy the things you need.

An example, is the recent bot attack hack. I have made a script recently to mitigate this as much as possible.

I'm making a seperate thread for this because it is a key take from open sourcing my gamemode.

90% of the hacks your server will face will automatically be mitigated with the help from this anticheat.

Download

zeelorenc/sf-cnr/tree/master/gamemodes/irresistible/anticheat

(All the files in that link are a part of the anticheat). Put them all in a folder.

Documentation

CHEAT_TYPE_MONEY

This has its own functions. I haven't bothered to hook giveplayermoney just to be absolutely safe. Only thing not Plug n Play is this.

GivePlayerCash( playerid, amount )
GetPlayerCash( playerid )

Introduces OnPlayerMoneyChanged callback as well.
pawn Code:
#if defined AC_INCLUDED
    public OnPlayerMoneyChanged( playerid, amount )
    {
        // save player money on each monetary movement
        if ( IsPlayerLoggedIn( playerid ) )
        {
            mysql_single_query( sprintf( "UPDATE `USERS` SET `CASH` = %d WHERE `ID` = %d", GetPlayerCash( playerid ), GetPlayerAccountID( playerid ) ) );
        }
        return 1;
    }
#endif

CHEAT_TYPE_PLAYERBUGGER

Restores player position if it is very exaggerated/far at random.

CHEAT_TYPE_WEAPON

Almost flawless. But no ammo detection. Just simple weapon hack detection. I'd say 99% accurate.

CHEAT_TYPE_CARWARP

If a car flies randomly it won't be synced to other players.

CHEAT_TYPE_FAKEKILL

When a player spams deaths / or death by another individual.

CHEAT_TYPE_REMOTE_JACK

Abnormal remote jacking detection. Large credit to JernejL.

CHEAT_TYPE_HEALTH / ARMOUR

While writing this I noticed these types are redundant due to my new system.

It is based off client-sided shooting and has the most basic/lightweight validation.

10x more lightweight than slice's one. 600 lines. His is 6000. Not a diss.

Replaced callbacks:
pawn Code:
#if defined AC_INCLUDED
public OnPlayerDeathEx( playerid, killerid, reason, Float: damage, bodypart )
#else
public OnPlayerDeath( playerid, killerid, reason )
#endif
{
    return 1;
}

#if defined AC_INCLUDED
public OnPlayerTakePlayerDamage( playerid, issuerid, &Float: amount, weaponid, bodypart )
{
    return 1; // returning 0 will prevent user from taking damage (THIS IS A BIG FEATURE!)
}
#endif

Note, has a RARE bug when a player dies with 99 damage. It simply will not register their death, nothing big. To be fixed by someone hopefully soon.

CHEAT_TYPE_AIRBRAKE

Credit to Emmet_. I don't think I made this, but I do recall Kar helping to improve this.

This was years ago. I don't speak frequently with these blokes anymore.

CHEAT_TYPE_PROAIM

90% accurate at first detection. 99% accurate after 3 lines of spam.

CHEAT_TYPE_AUTOCBUG

Same thing.

90% accurate at first detection. 99% accurate after 3 lines of spam.

CHEAT_TYPE_FLYHACKS

Pretty accurate for basic fly hack detection.

CHEAT_TYPE_RAPIDFIRE

That annoying hack where people shoot snipers, and other weapons very fast.

CHEAT_TYPE_CAR_PARTICLE_SPAM

When a car's doors etc are spammed all over the place by a hacker. Pretty accurate (should desync the player ideally).

CHEAT_TYPE_PICKUP_SPAM

When a user picks up a lot of pickups in a short timespan.

90% accurate at first detection. 99% accurate after 3 lines of spam.

Instructions

It is designed to be plug and play. REQUIRES YSI 3.
  1. Copy the anticheat folder into your includes folder
  2. #include "anticheat\_anticheat.pwn"

Sample code in your gamemode after including (more samples in the whole sf-cnr project e.g gamemodes/sf-cnr.pwn):

pawn Code:
#if defined AC_INCLUDED
    public OnPlayerCheatDetected( playerid, detection, params )
    {
        if ( detection == CHEAT_TYPE_REMOTE_JACK )
        {
            if ( GetPlayerScore( playerid ) < 200 )
            {
                SendGlobalMessage( -1, ""COL_PINK"[ANTI-CHEAT]{FFFFFF} %s(%d) has been kicked for abnormally jacking vehicles.", ReturnPlayerName( playerid ), playerid );
                SendClientMessageToAdmins( -1, ""COL_PINK"[ABNORMAL JACKING]"COL_GREY" %s(%d) - %d score - %d ping - %s IP", ReturnPlayerName( playerid ), playerid, GetPlayerScore( playerid ), GetPlayerPing( playerid ), ReturnPlayerIP( playerid ) );
                return Kick( playerid ), 1;
            }
            SendClientMessageToAdmins( -1, ""COL_PINK"[ABNORMAL JACKING]"COL_GREY" %s(%d) is a suspect of jacking vehicles abnormally.", ReturnPlayerName( playerid ), playerid );
        }
        else if ( detection == CHEAT_TYPE_RAPIDFIRE )
        {
            SendGlobalMessage( -1, ""COL_PINK"[ANTI-CHEAT]{FFFFFF} %s(%d) has been kicked for rapid-firing.", ReturnPlayerName( playerid ), playerid );
            Kick( playerid );
        }
        else if ( detection == CHEAT_TYPE_FAKEKILL )
        {
            SendGlobalMessage( -1, ""COL_PINK"[ANTI-CHEAT]{FFFFFF} %s(%d) has been banned for fake-killing.", ReturnPlayerName( playerid ), playerid );
            BanEx( playerid, "Fake-kill" );
        }
        else if ( detection == CHEAT_TYPE_CARWARP )
        {
            if ( ! GetPlayerAdminLevel( playerid ) )
            {
                SendGlobalMessage( -1, ""COL_PINK"[ANTI-CHEAT]{FFFFFF} %s(%d) has been banned for car warping.", ReturnPlayerName( playerid ), playerid );
                BanEx( playerid, "Car Warp" );
            }
        }
        else if ( detection == CHEAT_TYPE_AIRBRAKE )
        {
            //SendGlobalMessage( -1, ""COL_PINK"[ANTI-CHEAT]{FFFFFF} %s(%d) has been banned for airbraking.", ReturnPlayerName( playerid ), playerid );
            //AdvancedBan( playerid, "Server", "Airbrake", ReturnPlayerIP( playerid ) );
            SendClientMessageToAdmins( -1, ""COL_PINK"[ABNORMAL MOVEMENT]"COL_GREY" %s(%d) has been detected for airbrake.", ReturnPlayerName( playerid ), playerid );
        }
        else if ( detection == CHEAT_TYPE_FLYHACKS )
        {
            SendClientMessageToAdmins( -1, ""COL_PINK"[ABNORMAL MOVEMENT]"COL_GREY" %s(%d) has been detected for fly hacks.", ReturnPlayerName( playerid ), playerid );
            // SendGlobalMessage( -1, ""COL_PINK"[ANTI-CHEAT]{FFFFFF} %s(%d) has been banned for fly hacks.", ReturnPlayerName( playerid ), playerid );
            // AdvancedBan( playerid, "Server", "Fly Hacks", ReturnPlayerIP( playerid ) );
        }
        else if ( detection == CHEAT_TYPE_WEAPON )
        {
            SendClientMessageToAdmins( -1, ""COL_PINK"[ANTI-CHEAT]"COL_GREY" %s(%d) has been detected for weapon hack (%s).", ReturnPlayerName( playerid ), playerid, ReturnWeaponName( params ) );
        }
        else if ( detection == CHEAT_TYPE_CAR_PARTICLE_SPAM )
        {
            SendGlobalMessage( -1, ""COL_PINK"[ANTI-CHEAT]{FFFFFF} %s(%d) has been kicked for car particle spam.", ReturnPlayerName( playerid ), playerid );
            Kick( playerid );
        }
        else if( detection == CHEAT_TYPE_PICKUP_SPAM )
        {
            SendGlobalMessage( -1, ""COL_PINK"[ANTI-CHEAT]{FFFFFF} %s(%d) has been banned for rapid pickup spam.", ReturnPlayerName( playerid ), playerid );
            BanEx( playerid, "Pickup Spam" );
        }
        else
        {
            SendClientMessageToAdmins( -1, ""COL_PINK"[ANTI-CHEAT]"COL_GREY" %s(%d) has been detected for %s.", ReturnPlayerName( playerid ), playerid, AC_DetectedCheatToString( detection ) );
        }
        return 1;
    }
#endif

Designed to work with all my (Irresisitible Gaming) gamemodes (currently only the SF-CNR & COD projects).

Then you are done.

Final notes

I have honestly rushed to make this thread, but yeah. I've made my anticheat so simple that it should be pretty understandable to most scripters.

There are a lot of samples in the SF-CNR repo. Just use the GitHub search feature for specific things etc.

I'll try attend simple questions here but for now my help is honestly limited.
__________________
Join the best Cops And Robbers in SA-MP, today. svr.sfcnr.com:7777

Lorenc_ is offline   Reply With Quote
Old 19/04/2019, 09:02 AM   #2
raydx
Huge Clucker
 
raydx's Avatar
 
Join Date: Feb 2017
Posts: 205
Reputation: 73
Default Re: Irresistible Anticheat & Weapon Shot Sync System (Lightweight)

You've made little mistake in carwarp.pwn, it is calling rapid fire instead of car warp.

Code:
  if ( p_ac_CarWarpTime[ playerid ] > server_time )
	        {
				CallLocalFunction( "OnPlayerCheatDetected", "ddd", playerid, CHEAT_TYPE_RAPIDFIRE, 0 );
	            return Y_HOOKS_BREAK_RETURN_1;
	        }
raydx is offline   Reply With Quote
Old 19/04/2019, 09:08 AM   #3
Lorenc_
High-roller
 
Lorenc_'s Avatar
 
Join Date: Jan 2010
Location: Australia
Posts: 3,800
Reputation: 1160
Default Re: Irresistible Anticheat & Weapon Shot Sync System (Lightweight)

Quote:
Originally Posted by raydx View Post
You've made little mistake in carwarp.pwn, it is calling rapid fire instead of car warp.

Code:
  if ( p_ac_CarWarpTime[ playerid ] > server_time )
	        {
				CallLocalFunction( "OnPlayerCheatDetected", "ddd", playerid, CHEAT_TYPE_RAPIDFIRE, 0 );
	            return Y_HOOKS_BREAK_RETURN_1;
	        }
My admins get informed whenever anything is called, just to make sure. Fixed now.

That might be the reason why I've considered rapid fire to be slightly inaccurate - because of what you pointed out.

No regrets being open source after you pointed that out. LOL +repped
__________________
Join the best Cops And Robbers in SA-MP, today. svr.sfcnr.com:7777

Lorenc_ is offline   Reply With Quote
Old 19/04/2019, 10:29 AM   #4
Kasichok
Big Clucker
 
Kasichok's Avatar
 
Join Date: Sep 2018
Location: weed farm
Posts: 61
Reputation: 24
Default Re: Irresistible Anticheat & Weapon Shot Sync System (Lightweight)

For ammo you can hook GivePlayerWeapon

PHP Code:
//hook GivePlayerWeapon
server_ammo[playerid][weaponslot] += ammo
PHP Code:
//OnPlayerWeaponShoot
if(server_ammo[playerid][GetWeaponSlot(weaponid)] < 1)
{
    
server_ammo[playerid][GetWeaponSlot(weaponid)] = 0;
    
server_weapon[playerid][GetWeaponSlot(weaponid)] = 0;
    if(
GetPlayerAmmo(playerid) != server_ammo[playerid][GetWeaponSlot(weaponid)])
    {
         
//ResetAllPlayerWeapons
         //loop 12 slots and give them the server weapons like GivePlayerWeapon(playerid, server_weapon[playerid][i], server_ammo[playerid][i]);
    
}

So when the player is using ammo hack the weapon will still remove.
__________________



STRESSED? TRY KASICHOK AND RELAX


Kasichok is offline   Reply With Quote
Old 19/04/2019, 10:57 AM   #5
Lorenc_
High-roller
 
Lorenc_'s Avatar
 
Join Date: Jan 2010
Location: Australia
Posts: 3,800
Reputation: 1160
Default Re: Irresistible Anticheat & Weapon Shot Sync System (Lightweight)

Quote:
Originally Posted by Kasichok View Post
For ammo you can hook GivePlayerWeapon

PHP Code:
//hook GivePlayerWeapon
server_ammo[playerid][weaponslot] += ammo
PHP Code:
//OnPlayerWeaponShoot
if(server_ammo[playerid][GetWeaponSlot(weaponid)] < 1)
{
    
server_ammo[playerid][GetWeaponSlot(weaponid)] = 0;
    
server_weapon[playerid][GetWeaponSlot(weaponid)] = 0;
    if(
GetPlayerAmmo(playerid) != server_ammo[playerid][GetWeaponSlot(weaponid)])
    {
         
//ResetAllPlayerWeapons
         //loop 12 slots and give them the server weapons like GivePlayerWeapon(playerid, server_weapon[playerid][i], server_ammo[playerid][i]);
    
}

So when the player is using ammo hack the weapon will still remove.
"If it ain't broke, don't fix it"

Ammo tracking is pretty hard regardless, but I do definitely see the idea of having a "max ammo", and triggering if it goes above
__________________
Join the best Cops And Robbers in SA-MP, today. svr.sfcnr.com:7777

Lorenc_ is offline   Reply With Quote
Old 23/04/2019, 02:57 AM   #6
omcho
Little Clucker
 
Join Date: Dec 2018
Posts: 1
Reputation: 12
Default Re: Irresistible Anticheat & Weapon Shot Sync System (Lightweight)

Checked the code it's cool, but it would be even cooler if u would use ALS Hooking instead of y_hooks for people who don't want to use YSI just saying, but again nice release !

EDIT: I also like how your server's open-source that's cool too
omcho is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[FilterScript] Anti-Lag/Anti-Lead/MTA-Bullet Hit Sync System v0.1 (Weapon Damages Synced) Matz Filterscripts 21 26/05/2018 04:37 PM
0.3.7 weapon shot crasher suni Scripting Help 4 08/07/2015 11:43 PM
[Ajuda] Sync Shot BielCOP Português/Portuguese 4 20/12/2012 07:15 PM


All times are GMT. The time now is 03:36 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.