diff --git a/pawno/include/anticheat/airbrake.inc b/pawno/include/anticheat/airbrake.inc index 81300da..58c3832 100644 --- a/pawno/include/anticheat/airbrake.inc +++ b/pawno/include/anticheat/airbrake.inc @@ -46,7 +46,7 @@ stock AC_SetPlayerPos( playerid, Float: x, Float: y, Float: z ) #define _ALS_SetPlayerPos #endif #define SetPlayerPos AC_SetPlayerPos - + // Function Hook (SetPlayerPosFindZ) 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 #endif #define SetPlayerPosFindZ AC_SetPlayerPosFindZ - + // Functions stock bCheckForAirbrake( playerid, iTicks, iState ) -{ +{ if( iState == 0 || iState == 2 || iState == 3 || iState == 7 || iState == 9 ) p_abLastTick[ playerid ] = iTicks + 1000; else if( !IsPlayerInAnyVehicle( playerid ) && GetPlayerSurfingVehicleID( playerid ) == INVALID_VEHICLE_ID && GetPlayerSurfingObjectID( playerid ) == INVALID_VEHICLE_ID ) // && !IsPlayerNPC( playerid ) { - new + new Float: iPacketLoss = NetStats_PacketLossPercent( playerid ); 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( ++p_abDetected{ playerid } >= 3 ) - CallLocalFunction( "OnPlayerCheatDetected", "dd", playerid, CHEAT_TYPE_AIRBRAKE ); + CallLocalFunction( "OnPlayerCheatDetected", "ddd", playerid, CHEAT_TYPE_AIRBRAKE, 0 ); if( p_abResetTimer[ playerid ] == -1 ) p_abResetTimer[ playerid ] = SetTimerEx( "AC_ResetABDetected", 60000, false, "d", playerid ); diff --git a/pawno/include/anticheat/autocbug.inc b/pawno/include/anticheat/autocbug.inc index 6b7e064..ff0ba25 100644 --- a/pawno/include/anticheat/autocbug.inc +++ b/pawno/include/anticheat/autocbug.inc @@ -37,7 +37,7 @@ stock vAutoCbugKeyState( playerid, newkeys, oldkeys ) { - if( !p_cbugKeyTicks[ playerid ] ) + if( !p_cbugKeyTicks[ playerid ] ) p_cbugKeyTicks[ playerid ] = GetTickCount( ), p_cbugWarns{ playerid } = 0; if( ( ( ( newkeys & ( KEY_CROUCH ) ) == ( KEY_CROUCH ) ) || ( ( oldkeys & ( KEY_CROUCH ) ) == ( KEY_CROUCH ) ) ) ) @@ -48,9 +48,9 @@ stock vCheckForAutoCbug( playerid, weaponid ) { // Anti-Rapid Fire if( !p_cbugFireTicks[ playerid ] ) p_cbugFireTicks[ playerid ] = GetTickCount( ); - else + else { - new + new iTicks = GetTickCount( ), iInterval = iTicks - p_cbugFireTicks[ 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 ) { - new + new iCompare = iKeyInterval - iInterval, Float: fOwnPacketLoss = NetStats_PacketLossPercent( playerid ) ; @@ -75,10 +75,10 @@ stock vCheckForAutoCbug( playerid, weaponid ) if( iInterval < iHardInterval && iCompare > 1500 && fOwnPacketLoss < 0.8 ) { 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 }); - CallLocalFunction( "OnPlayerCheatDetected", "dd", playerid, CHEAT_TYPE_AUTOCBUG ); + CallLocalFunction( "OnPlayerCheatDetected", "ddd", playerid, CHEAT_TYPE_AUTOCBUG, 0 ); } } } - p_cbugFireTicks[ playerid ] = iTicks; + p_cbugFireTicks[ playerid ] = iTicks; } -} \ No newline at end of file +} diff --git a/pawno/include/anticheat/flying.inc b/pawno/include/anticheat/flying.inc index 7532131..5d46909 100644 --- a/pawno/include/anticheat/flying.inc +++ b/pawno/include/anticheat/flying.inc @@ -38,25 +38,25 @@ static const Float: aWaterPlaces[ 20 ] [ 4 ] = }; stock vCheckForFlyHacks( playerid, iTicks ) -{ +{ if( iTicks > p_FlyHacksTick[ playerid ] ) { new pSurfingObject = GetPlayerSurfingObjectID( playerid ), pSurfingVehicle = GetPlayerSurfingVehicleID( playerid ) ; - + if( pSurfingVehicle == INVALID_VEHICLE_ID && pSurfingObject == INVALID_OBJECT_ID ) { - new + new iAnimation = GetPlayerAnimationIndex( playerid ); - + if( iAnimation == 1538 || iAnimation == 1539 || iAnimation == 1543 ) { - if( !ac_IsPlayerInWater( playerid ) ) + if( !ac_IsPlayerInWater( playerid ) ) { 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; } @@ -73,12 +73,12 @@ stock ac_IsPlayerInWater( playerid ) 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 if( ac_PointDistance( X, Y, -965.0, 2438.0 ) <= squared( 700.0 ) && Z < 44.0 ) return true; - + 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 ] ) 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 false; -} \ No newline at end of file +} diff --git a/pawno/include/anticheat/global.inc b/pawno/include/anticheat/global.inc index 455db45..306bb57 100644 --- a/pawno/include/anticheat/global.inc +++ b/pawno/include/anticheat/global.inc @@ -238,7 +238,7 @@ stock // Forwards (Global) -public OnPlayerCheatDetected( playerid, detection ); +public OnPlayerCheatDetected( playerid, detection, params ); // Functions (Global) diff --git a/pawno/include/anticheat/hitpoints.inc b/pawno/include/anticheat/hitpoints.inc index fe30f9e..147d763 100644 --- a/pawno/include/anticheat/hitpoints.inc +++ b/pawno/include/anticheat/hitpoints.inc @@ -413,21 +413,8 @@ hook OnPlayerDeath(playerid, killerid, reason) { 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 - else if( GetPlayerVehicleID( playerid ) && ac_IsPlayerSpawned( playerid ) ) + if ( GetPlayerVehicleID( playerid ) && ac_IsPlayerSpawned( playerid ) ) { if( ( GetTickCount( ) - p_LastTookDamage[ playerid ] ) > 2500 ) p_LastDamageIssuer[ playerid ] = INVALID_PLAYER_ID, p_LastWeaponIssuer[ playerid ] = 51; @@ -448,9 +435,10 @@ hook OnPlayerDeath(playerid, killerid, reason) /* ** Functions ** */ stock ForcePlayerKill( playerid, killerid, weaponid ) { - SetPVarInt( playerid, "KillerID", killerid ); - SetPVarInt( playerid, "WeaponID", weaponid ); - SetPVarInt( playerid, "CustomKill", 1 ); + p_LastTookDamage[ playerid ] = GetTickCount( ); + p_LastDamageIssuer[ playerid ] = killerid; + p_LastWeaponIssuer[ playerid ] = weaponid; + p_LastDamageIssued[ playerid ] = 100.0; SetPlayerHealth( playerid, -1 ); } diff --git a/pawno/include/anticheat/proaim.inc b/pawno/include/anticheat/proaim.inc index 9e2029a..eef1538 100644 --- a/pawno/include/anticheat/proaim.inc +++ b/pawno/include/anticheat/proaim.inc @@ -73,7 +73,7 @@ stock vCheckForSilentAimbot( playerid, hittype, hitid ) if( iTicks - p_silentAimbotLastCalled[ playerid ] <= 5000 ) { 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; diff --git a/pawno/include/anticheat/remotejack.inc b/pawno/include/anticheat/remotejack.inc index 8f663bb..eb666cc 100644 --- a/pawno/include/anticheat/remotejack.inc +++ b/pawno/include/anticheat/remotejack.inc @@ -47,10 +47,10 @@ stock bCheckPlayerRemoteJacking( playerid ) if( ( GetVehicleModel( iVehicle ) == 577 ) || ( GetVehicleModel( iVehicle ) == 592 )) fOffset = 25.0; // Andromanda | AT-400 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 ] ); p_remoteJackData[ playerid ] [ E_LAST_VEH ] = iVehicle; } return 1; -} \ No newline at end of file +} diff --git a/pawno/include/anticheat/spectate.inc b/pawno/include/anticheat/spectate.inc index 431f4f3..bf976a9 100644 --- a/pawno/include/anticheat/spectate.inc +++ b/pawno/include/anticheat/spectate.inc @@ -51,9 +51,9 @@ stock bCheckForSpectatingHacks( playerid, iState, iTicks ) if( iTicks > p_PlayerSpectateUpdateTime[ 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 } ); } p_PlayerSpectateUpdateTime[ playerid ] = iTicks + 1000; } -} \ No newline at end of file +} diff --git a/pawno/include/anticheat/weapon.inc b/pawno/include/anticheat/weapon.inc index ef0e431..dbbb97c 100644 --- a/pawno/include/anticheat/weapon.inc +++ b/pawno/include/anticheat/weapon.inc @@ -28,15 +28,21 @@ #include < anticheat\global > #include < anticheat\player > +// Player Variables + +static p_PlayerWeaponUpdateTime[ MAX_PLAYERS ]; +static p_CurrentArmedWeapon[ MAX_PLAYERS char ]; + // Function Hook (GivePlayerWeapon) 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_CurrentArmedWeapon{ playerid } = weaponid; + } return GivePlayerWeapon( playerid, weaponid, ammo ); } @@ -47,11 +53,29 @@ stock AC_GivePlayerWeapon( playerid, weaponid, ammo ) #endif #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) stock AC_ResetPlayerWeapons( playerid ) { - //p_PlayerWeaponUpdateTime[ playerid ] = GetTickCount( ) + 2000; + p_PlayerWeaponUpdateTime[ playerid ] = GetTickCount( ) + 2000; for ( new i = 0; i < AC_MAX_WEAPONS; i++ ) 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 ) { - if( ( keys & KEY_FIRE ) && ac_IsPlayerSpawned( playerid ) ) { - new - iWeapon = GetPlayerWeapon( playerid ); + if ( ( keys & KEY_FIRE ) && ac_IsPlayerSpawned( playerid ) ) { + new 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 ) ) { - CallLocalFunction( "OnPlayerCheatDetected", "dd", playerid, CHEAT_TYPE_WEAPON ); - printf("[weapon] %d seems to weapon hack (weapon id %d).", playerid, iWeapon ); + if( !p_PlayerHasWeapon[ playerid ] { iWeapon } && ( iWeapon != 0 && iWeapon != 40 ) && ! ( IsPlayerInAnyVehicle( playerid ) && p_CurrentArmedWeapon{ playerid } != iWeapon ) ) { + CallLocalFunction( "OnPlayerCheatDetected", "ddd", playerid, CHEAT_TYPE_WEAPON, iWeapon ); + // printf("[weapon] %d seems to weapon hack (weapon id %d).", playerid, iWeapon ); } } }