anticheat fixes

This commit is contained in:
Lorenc Pekaj 2018-07-04 03:34:04 +10:00
parent e7d3b3f105
commit 1e4a40c09b
9 changed files with 67 additions and 55 deletions

View File

@ -46,7 +46,7 @@ stock AC_SetPlayerPos( playerid, Float: x, Float: y, Float: z )
#define _ALS_SetPlayerPos #define _ALS_SetPlayerPos
#endif #endif
#define SetPlayerPos AC_SetPlayerPos #define SetPlayerPos AC_SetPlayerPos
// Function Hook (SetPlayerPosFindZ) // Function Hook (SetPlayerPosFindZ)
stock AC_SetPlayerPosFindZ(playerid, Float:x, Float:y, Float:z) stock AC_SetPlayerPosFindZ(playerid, Float:x, Float:y, Float:z)
@ -61,17 +61,17 @@ stock AC_SetPlayerPosFindZ(playerid, Float:x, Float:y, Float:z)
#define _ALS_SetPlayerPosFindZ #define _ALS_SetPlayerPosFindZ
#endif #endif
#define SetPlayerPosFindZ AC_SetPlayerPosFindZ #define SetPlayerPosFindZ AC_SetPlayerPosFindZ
// Functions // Functions
stock bCheckForAirbrake( playerid, iTicks, iState ) stock bCheckForAirbrake( playerid, iTicks, iState )
{ {
if( iState == 0 || iState == 2 || iState == 3 || iState == 7 || iState == 9 ) if( iState == 0 || iState == 2 || iState == 3 || iState == 7 || iState == 9 )
p_abLastTick[ playerid ] = iTicks + 1000; p_abLastTick[ playerid ] = iTicks + 1000;
else if( !IsPlayerInAnyVehicle( playerid ) && GetPlayerSurfingVehicleID( playerid ) == INVALID_VEHICLE_ID && GetPlayerSurfingObjectID( playerid ) == INVALID_VEHICLE_ID ) // && !IsPlayerNPC( playerid ) else if( !IsPlayerInAnyVehicle( playerid ) && GetPlayerSurfingVehicleID( playerid ) == INVALID_VEHICLE_ID && GetPlayerSurfingObjectID( playerid ) == INVALID_VEHICLE_ID ) // && !IsPlayerNPC( playerid )
{ {
new new
Float: iPacketLoss = NetStats_PacketLossPercent( playerid ); Float: iPacketLoss = NetStats_PacketLossPercent( playerid );
if( iTicks > p_abLastTick[ playerid ] && iPacketLoss < 0.8 ) if( iTicks > p_abLastTick[ playerid ] && iPacketLoss < 0.8 )
@ -89,7 +89,7 @@ stock bCheckForAirbrake( playerid, iTicks, iState )
if( floatabs( distance ) >= 75.0 && ( floatabs( p_abLastPosition[ playerid ] [ 1 ] - y ) >= 50.0 || floatabs( p_abLastPosition[ playerid ] [ 0 ] - x ) >= 50.0 ) ) if( floatabs( distance ) >= 75.0 && ( floatabs( p_abLastPosition[ playerid ] [ 1 ] - y ) >= 50.0 || floatabs( p_abLastPosition[ playerid ] [ 0 ] - x ) >= 50.0 ) )
{ {
if( ++p_abDetected{ playerid } >= 3 ) if( ++p_abDetected{ playerid } >= 3 )
CallLocalFunction( "OnPlayerCheatDetected", "dd", playerid, CHEAT_TYPE_AIRBRAKE ); CallLocalFunction( "OnPlayerCheatDetected", "ddd", playerid, CHEAT_TYPE_AIRBRAKE, 0 );
if( p_abResetTimer[ playerid ] == -1 ) if( p_abResetTimer[ playerid ] == -1 )
p_abResetTimer[ playerid ] = SetTimerEx( "AC_ResetABDetected", 60000, false, "d", playerid ); p_abResetTimer[ playerid ] = SetTimerEx( "AC_ResetABDetected", 60000, false, "d", playerid );

View File

@ -37,7 +37,7 @@
stock vAutoCbugKeyState( playerid, newkeys, oldkeys ) stock vAutoCbugKeyState( playerid, newkeys, oldkeys )
{ {
if( !p_cbugKeyTicks[ playerid ] ) if( !p_cbugKeyTicks[ playerid ] )
p_cbugKeyTicks[ playerid ] = GetTickCount( ), p_cbugWarns{ playerid } = 0; p_cbugKeyTicks[ playerid ] = GetTickCount( ), p_cbugWarns{ playerid } = 0;
if( ( ( ( newkeys & ( KEY_CROUCH ) ) == ( KEY_CROUCH ) ) || ( ( oldkeys & ( KEY_CROUCH ) ) == ( KEY_CROUCH ) ) ) ) if( ( ( ( newkeys & ( KEY_CROUCH ) ) == ( KEY_CROUCH ) ) || ( ( oldkeys & ( KEY_CROUCH ) ) == ( KEY_CROUCH ) ) ) )
@ -48,9 +48,9 @@ stock vCheckForAutoCbug( playerid, weaponid )
{ {
// Anti-Rapid Fire // Anti-Rapid Fire
if( !p_cbugFireTicks[ playerid ] ) p_cbugFireTicks[ playerid ] = GetTickCount( ); if( !p_cbugFireTicks[ playerid ] ) p_cbugFireTicks[ playerid ] = GetTickCount( );
else else
{ {
new new
iTicks = GetTickCount( ), iTicks = GetTickCount( ),
iInterval = iTicks - p_cbugFireTicks[ playerid ], iInterval = iTicks - p_cbugFireTicks[ playerid ],
iKeyInterval = iTicks - p_cbugKeyTicks[ playerid ], iKeyInterval = iTicks - p_cbugKeyTicks[ playerid ],
@ -59,7 +59,7 @@ stock vCheckForAutoCbug( playerid, weaponid )
if( weaponid == WEAPON_DEAGLE || weaponid == WEAPON_SHOTGUN || weaponid == WEAPON_RIFLE || weaponid == WEAPON_SNIPER ) if( weaponid == WEAPON_DEAGLE || weaponid == WEAPON_SHOTGUN || weaponid == WEAPON_RIFLE || weaponid == WEAPON_SNIPER )
{ {
new new
iCompare = iKeyInterval - iInterval, iCompare = iKeyInterval - iInterval,
Float: fOwnPacketLoss = NetStats_PacketLossPercent( playerid ) Float: fOwnPacketLoss = NetStats_PacketLossPercent( playerid )
; ;
@ -75,10 +75,10 @@ stock vCheckForAutoCbug( playerid, weaponid )
if( iInterval < iHardInterval && iCompare > 1500 && fOwnPacketLoss < 0.8 ) { if( iInterval < iHardInterval && iCompare > 1500 && fOwnPacketLoss < 0.8 ) {
if( p_cbugWarns{ playerid }++ >= 2 ) { if( p_cbugWarns{ playerid }++ >= 2 ) {
printf( "[autocbug detect] %d detected (wep %d, interval %d, compare %d, warns %d)", playerid, weaponid, iInterval, iCompare, p_cbugWarns{ playerid }); printf( "[autocbug detect] %d detected (wep %d, interval %d, compare %d, warns %d)", playerid, weaponid, iInterval, iCompare, p_cbugWarns{ playerid });
CallLocalFunction( "OnPlayerCheatDetected", "dd", playerid, CHEAT_TYPE_AUTOCBUG ); CallLocalFunction( "OnPlayerCheatDetected", "ddd", playerid, CHEAT_TYPE_AUTOCBUG, 0 );
} }
} }
} }
p_cbugFireTicks[ playerid ] = iTicks; p_cbugFireTicks[ playerid ] = iTicks;
} }
} }

View File

@ -38,25 +38,25 @@ static const Float: aWaterPlaces[ 20 ] [ 4 ] =
}; };
stock vCheckForFlyHacks( playerid, iTicks ) stock vCheckForFlyHacks( playerid, iTicks )
{ {
if( iTicks > p_FlyHacksTick[ playerid ] ) if( iTicks > p_FlyHacksTick[ playerid ] )
{ {
new new
pSurfingObject = GetPlayerSurfingObjectID( playerid ), pSurfingObject = GetPlayerSurfingObjectID( playerid ),
pSurfingVehicle = GetPlayerSurfingVehicleID( playerid ) pSurfingVehicle = GetPlayerSurfingVehicleID( playerid )
; ;
if( pSurfingVehicle == INVALID_VEHICLE_ID && pSurfingObject == INVALID_OBJECT_ID ) if( pSurfingVehicle == INVALID_VEHICLE_ID && pSurfingObject == INVALID_OBJECT_ID )
{ {
new new
iAnimation = GetPlayerAnimationIndex( playerid ); iAnimation = GetPlayerAnimationIndex( playerid );
if( iAnimation == 1538 || iAnimation == 1539 || iAnimation == 1543 ) if( iAnimation == 1538 || iAnimation == 1539 || iAnimation == 1543 )
{ {
if( !ac_IsPlayerInWater( playerid ) ) if( !ac_IsPlayerInWater( playerid ) )
{ {
if( p_FlyHacksWarns{ playerid }++ >= 2 ) if( p_FlyHacksWarns{ playerid }++ >= 2 )
CallLocalFunction( "OnPlayerCheatDetected", "dd", playerid, CHEAT_TYPE_FLYHACKS ), p_FlyHacksWarns{ playerid } = 3; CallLocalFunction( "OnPlayerCheatDetected", "ddd", playerid, CHEAT_TYPE_FLYHACKS, 0 ), p_FlyHacksWarns{ playerid } = 3;
} }
else p_FlyHacksWarns{ playerid } = 0; else p_FlyHacksWarns{ playerid } = 0;
} }
@ -73,12 +73,12 @@ stock ac_IsPlayerInWater( playerid )
if( GetPlayerPos( playerid, X, Y, Z ) ) if( GetPlayerPos( playerid, X, Y, Z ) )
{ {
if( ac_IsPointInArea( X, Y, 2347.080, 521.70, 2372.65, 545.1971 ) || ac_IsPointInArea( X, Y, 2286.61, 521.70, 2301.45, 545.1971 ) ) if( ac_IsPointInArea( X, Y, 2347.080, 521.70, 2372.65, 545.1971 ) || ac_IsPointInArea( X, Y, 2286.61, 521.70, 2301.45, 545.1971 ) )
return false; // Kar Fix return false; // Kar Fix
if( ac_PointDistance( X, Y, -965.0, 2438.0 ) <= squared( 700.0 ) && Z < 44.0 ) if( ac_PointDistance( X, Y, -965.0, 2438.0 ) <= squared( 700.0 ) && Z < 44.0 )
return true; return true;
for( i = 0; i < sizeof( aWaterPlaces ); i++ ) for( i = 0; i < sizeof( aWaterPlaces ); i++ )
if( ac_PointDistance( X, Y, aWaterPlaces[ i ] [ 1 ], aWaterPlaces[ i ] [ 2 ] ) <= squared( aWaterPlaces[ i ] [ 0 ] ) && Z < aWaterPlaces[ i ] [ 3 ] ) if( ac_PointDistance( X, Y, aWaterPlaces[ i ] [ 1 ], aWaterPlaces[ i ] [ 2 ] ) <= squared( aWaterPlaces[ i ] [ 0 ] ) && Z < aWaterPlaces[ i ] [ 3 ] )
return true; return true;
@ -86,4 +86,4 @@ stock ac_IsPlayerInWater( playerid )
return Z < 1.9 ? !( ac_PointDistance( X, Y, 618.4129, 863.3164 ) < squared( 200.0 ) ) : false; return Z < 1.9 ? !( ac_PointDistance( X, Y, 618.4129, 863.3164 ) < squared( 200.0 ) ) : false;
} }
return false; return false;
} }

View File

@ -238,7 +238,7 @@ stock
// Forwards (Global) // Forwards (Global)
public OnPlayerCheatDetected( playerid, detection ); public OnPlayerCheatDetected( playerid, detection, params );
// Functions (Global) // Functions (Global)

View File

@ -413,21 +413,8 @@ hook OnPlayerDeath(playerid, killerid, reason)
{ {
if ( !IsPlayerNPC( playerid ) ) if ( !IsPlayerNPC( playerid ) )
{ {
// Health/Armour Hack
if( GetPVarInt( playerid, "CustomKill" ) )
{
new
customKiller = GetPVarInt( playerid, "KillerID" );
CallRemoteFunction( "OnPlayerDeathEx", "ddfd", playerid, customKiller != playerid ? customKiller : INVALID_PLAYER_ID, GetPVarInt( playerid, "WeaponID" ), 3.3, 3 );
DeletePVar( playerid, "KillerID" );
DeletePVar( playerid, "WeaponID" );
DeletePVar( playerid, "CustomKill" );
}
// Died in Vehicle // Died in Vehicle
else if( GetPlayerVehicleID( playerid ) && ac_IsPlayerSpawned( playerid ) ) if ( GetPlayerVehicleID( playerid ) && ac_IsPlayerSpawned( playerid ) )
{ {
if( ( GetTickCount( ) - p_LastTookDamage[ playerid ] ) > 2500 ) if( ( GetTickCount( ) - p_LastTookDamage[ playerid ] ) > 2500 )
p_LastDamageIssuer[ playerid ] = INVALID_PLAYER_ID, p_LastWeaponIssuer[ playerid ] = 51; p_LastDamageIssuer[ playerid ] = INVALID_PLAYER_ID, p_LastWeaponIssuer[ playerid ] = 51;
@ -448,9 +435,10 @@ hook OnPlayerDeath(playerid, killerid, reason)
/* ** Functions ** */ /* ** Functions ** */
stock ForcePlayerKill( playerid, killerid, weaponid ) stock ForcePlayerKill( playerid, killerid, weaponid )
{ {
SetPVarInt( playerid, "KillerID", killerid ); p_LastTookDamage[ playerid ] = GetTickCount( );
SetPVarInt( playerid, "WeaponID", weaponid ); p_LastDamageIssuer[ playerid ] = killerid;
SetPVarInt( playerid, "CustomKill", 1 ); p_LastWeaponIssuer[ playerid ] = weaponid;
p_LastDamageIssued[ playerid ] = 100.0;
SetPlayerHealth( playerid, -1 ); SetPlayerHealth( playerid, -1 );
} }

View File

@ -73,7 +73,7 @@ stock vCheckForSilentAimbot( playerid, hittype, hitid )
if( iTicks - p_silentAimbotLastCalled[ playerid ] <= 5000 ) { if( iTicks - p_silentAimbotLastCalled[ playerid ] <= 5000 ) {
printf("[PRO-AIM] Detected %d - last %dms", playerid, iTicks - p_silentAimbotLastCalled[ playerid ]); printf("[PRO-AIM] Detected %d - last %dms", playerid, iTicks - p_silentAimbotLastCalled[ playerid ]);
CallLocalFunction( "OnPlayerCheatDetected", "dd", playerid, CHEAT_TYPE_PROAIM ); CallLocalFunction( "OnPlayerCheatDetected", "ddd", playerid, CHEAT_TYPE_PROAIM, 0 );
} }
p_silentAimbotLastCalled[ playerid ] = iTicks; p_silentAimbotLastCalled[ playerid ] = iTicks;

View File

@ -47,10 +47,10 @@ stock bCheckPlayerRemoteJacking( playerid )
if( ( GetVehicleModel( iVehicle ) == 577 ) || ( GetVehicleModel( iVehicle ) == 592 )) fOffset = 25.0; // Andromanda | AT-400 if( ( GetVehicleModel( iVehicle ) == 577 ) || ( GetVehicleModel( iVehicle ) == 592 )) fOffset = 25.0; // Andromanda | AT-400
if( fDistance > fOffset ) if( fDistance > fOffset )
CallLocalFunction( "OnPlayerCheatDetected", "dd", playerid, CHEAT_TYPE_REMOTE_JACK ); CallLocalFunction( "OnPlayerCheatDetected", "ddd", playerid, CHEAT_TYPE_REMOTE_JACK, 0 );
GetPlayerPos( playerid, p_remoteJackData[ playerid ] [ E_LAST_X ], p_remoteJackData[ playerid ] [ E_LAST_Y ], p_remoteJackData[ playerid ] [ E_LAST_Z ] ); GetPlayerPos( playerid, p_remoteJackData[ playerid ] [ E_LAST_X ], p_remoteJackData[ playerid ] [ E_LAST_Y ], p_remoteJackData[ playerid ] [ E_LAST_Z ] );
p_remoteJackData[ playerid ] [ E_LAST_VEH ] = iVehicle; p_remoteJackData[ playerid ] [ E_LAST_VEH ] = iVehicle;
} }
return 1; return 1;
} }

View File

@ -51,9 +51,9 @@ stock bCheckForSpectatingHacks( playerid, iState, iTicks )
if( iTicks > p_PlayerSpectateUpdateTime[ playerid ] ) if( iTicks > p_PlayerSpectateUpdateTime[ playerid ] )
{ {
if( iState == PLAYER_STATE_SPECTATING && !p_SpectatePermission{ playerid } ) { if( iState == PLAYER_STATE_SPECTATING && !p_SpectatePermission{ playerid } ) {
CallLocalFunction( "OnPlayerCheatDetected", "dd", playerid, CHEAT_TYPE_SPECTATE ); CallLocalFunction( "OnPlayerCheatDetected", "ddd", playerid, CHEAT_TYPE_SPECTATE, 0 );
printf("[spectate] [%d] %d seems to spectate hack (state id %d, perm %d).", GetTickCount( ), playerid, iState, p_SpectatePermission{ playerid } ); printf("[spectate] [%d] %d seems to spectate hack (state id %d, perm %d).", GetTickCount( ), playerid, iState, p_SpectatePermission{ playerid } );
} }
p_PlayerSpectateUpdateTime[ playerid ] = iTicks + 1000; p_PlayerSpectateUpdateTime[ playerid ] = iTicks + 1000;
} }
} }

View File

@ -28,15 +28,21 @@
#include < anticheat\global > #include < anticheat\global >
#include < anticheat\player > #include < anticheat\player >
// Player Variables
static p_PlayerWeaponUpdateTime[ MAX_PLAYERS ];
static p_CurrentArmedWeapon[ MAX_PLAYERS char ];
// Function Hook (GivePlayerWeapon) // Function Hook (GivePlayerWeapon)
stock AC_GivePlayerWeapon( playerid, weaponid, ammo ) stock AC_GivePlayerWeapon( playerid, weaponid, ammo )
{ {
//p_PlayerWeaponUpdateTime[ playerid ] = GetTickCount( ) + 2000; p_PlayerWeaponUpdateTime[ playerid ] = GetTickCount( ) + 2000;
if( weaponid < AC_MAX_WEAPONS ) if( 0 <= weaponid < AC_MAX_WEAPONS ) {
p_PlayerHasWeapon[ playerid ] { weaponid } = true; p_PlayerHasWeapon[ playerid ] { weaponid } = true;
p_CurrentArmedWeapon{ playerid } = weaponid;
}
return GivePlayerWeapon( playerid, weaponid, ammo ); return GivePlayerWeapon( playerid, weaponid, ammo );
} }
@ -47,11 +53,29 @@ stock AC_GivePlayerWeapon( playerid, weaponid, ammo )
#endif #endif
#define GivePlayerWeapon AC_GivePlayerWeapon #define GivePlayerWeapon AC_GivePlayerWeapon
// Function Hook (SetPlayerArmedWeapon)
stock AC_SetPlayerArmedWeapon( playerid, weaponid )
{
if ( 0 <= weaponid <= AC_MAX_WEAPONS && p_CurrentArmedWeapon{ playerid } != weaponid ) {
p_PlayerWeaponUpdateTime[ playerid ] = GetTickCount( ) + 2000;
p_CurrentArmedWeapon{ playerid } = weaponid;
}
return SetPlayerArmedWeapon( playerid, weaponid );
}
#if defined _ALS_SetPlayerArmedWeapon
#undef SetPlayerArmedWeapon
#else
#define _ALS_SetPlayerArmedWeapon
#endif
#define SetPlayerArmedWeapon AC_SetPlayerArmedWeapon
// Function Hook (ResetPlayerWeapons) // Function Hook (ResetPlayerWeapons)
stock AC_ResetPlayerWeapons( playerid ) stock AC_ResetPlayerWeapons( playerid )
{ {
//p_PlayerWeaponUpdateTime[ playerid ] = GetTickCount( ) + 2000; p_PlayerWeaponUpdateTime[ playerid ] = GetTickCount( ) + 2000;
for ( new i = 0; i < AC_MAX_WEAPONS; i++ ) for ( new i = 0; i < AC_MAX_WEAPONS; i++ )
p_PlayerHasWeapon[ playerid ] { i } = false; p_PlayerHasWeapon[ playerid ] { i } = false;
@ -171,15 +195,15 @@ stock AC_CreateDynamicPickup( modelid, type, Float: x, Float: y, Float: z, world
stock vWeaponHackCheck( playerid, keys ) stock vWeaponHackCheck( playerid, keys )
{ {
if( ( keys & KEY_FIRE ) && ac_IsPlayerSpawned( playerid ) ) { if ( ( keys & KEY_FIRE ) && ac_IsPlayerSpawned( playerid ) ) {
new new iWeapon = GetPlayerWeapon( playerid );
iWeapon = GetPlayerWeapon( playerid ); new iTickCount = GetTickCount( );
if( iWeapon > -1 && iWeapon < AC_MAX_WEAPONS ) if ( iTickCount > p_PlayerWeaponUpdateTime[ playerid ] && 0 <= iWeapon < AC_MAX_WEAPONS )
{ {
if( !p_PlayerHasWeapon[ playerid ] { iWeapon } && ( iWeapon != 0 && iWeapon != 40 ) ) { if( !p_PlayerHasWeapon[ playerid ] { iWeapon } && ( iWeapon != 0 && iWeapon != 40 ) && ! ( IsPlayerInAnyVehicle( playerid ) && p_CurrentArmedWeapon{ playerid } != iWeapon ) ) {
CallLocalFunction( "OnPlayerCheatDetected", "dd", playerid, CHEAT_TYPE_WEAPON ); CallLocalFunction( "OnPlayerCheatDetected", "ddd", playerid, CHEAT_TYPE_WEAPON, iWeapon );
printf("[weapon] %d seems to weapon hack (weapon id %d).", playerid, iWeapon ); // printf("[weapon] %d seems to weapon hack (weapon id %d).", playerid, iWeapon );
} }
} }
} }