diff --git a/gamemodes/irresistible/anticheat/_anticheat.pwn b/gamemodes/irresistible/anticheat/_anticheat.pwn index 997dbb5..1ba101e 100644 --- a/gamemodes/irresistible/anticheat/_anticheat.pwn +++ b/gamemodes/irresistible/anticheat/_anticheat.pwn @@ -22,12 +22,12 @@ enum { CHEAT_TYPE_WEAPON, - //CHEAT_TYPE_CARWARP, + CHEAT_TYPE_CARWARP, //CHEAT_TYPE_MONEY, //CHEAT_TYPE_PLAYERBUGGER, //CHEAT_TYPE_PICKUP_SPAM, //CHEAT_TYPE_SPECTATE, - //CHEAT_TYPE_FAKEKILL, + CHEAT_TYPE_FAKEKILL, CHEAT_TYPE_REMOTE_JACK, //CHEAT_TYPE_PING_LIMIT, CHEAT_TYPE_SPEED_HACK, @@ -165,3 +165,4 @@ stock AC_SetPlayerSpawned( playerid, bool: spawned ) { #include "irresistible\anticheat\flying.pwn" #include "irresistible\anticheat\remotejack.pwn" #include "irresistible\anticheat\rapidfire.pwn" +#include "irresistible\anticheat\carwarp.pwn" diff --git a/gamemodes/irresistible/anticheat/carwarp.pwn b/gamemodes/irresistible/anticheat/carwarp.pwn new file mode 100644 index 0000000..1896ec1 --- /dev/null +++ b/gamemodes/irresistible/anticheat/carwarp.pwn @@ -0,0 +1,38 @@ +/* + * Irresistible Gaming (c) 2018 + * Developed by Lorenc Pekaj + * Module: + * Purpose: + */ + +/* ** Includes ** */ +#include < YSI\y_hooks > + +/* ** Variables ** */ +static stock + p_ac_CarWarpTime [ MAX_PLAYERS ], + p_ac_CarWarpVehicleID [ MAX_PLAYERS ] +; + +/* ** Hooks ** */ +hook OnPlayerStateChange( playerid, newstate, oldstate ) +{ + if ( newstate == PLAYER_STATE_DRIVER ) + { + if ( GetPlayerVehicleID( playerid ) != p_ac_CarWarpVehicleID[ playerid ] ) + { + new + server_time = gettime( ); + + if ( p_ac_CarWarpTime[ playerid ] > server_time ) + { + CallLocalFunction( "OnPlayerCheatDetected", "ddd", playerid, CHEAT_TYPE_RAPIDFIRE, 0 ); + return Y_HOOKS_BREAK_RETURN_1; + } + + p_ac_CarWarpTime[ playerid ] = server_time + 1; + p_ac_CarWarpVehicleID[ playerid ] = GetPlayerVehicleID( playerid ); + } + } + return 1; +} diff --git a/gamemodes/irresistible/anticheat/hitpoints.pwn b/gamemodes/irresistible/anticheat/hitpoints.pwn index adea691..3ccd60c 100644 --- a/gamemodes/irresistible/anticheat/hitpoints.pwn +++ b/gamemodes/irresistible/anticheat/hitpoints.pwn @@ -184,7 +184,9 @@ static stock Float: p_LastDamageIssued [ MAX_PLAYERS ], p_LastTookDamage [ MAX_PLAYERS ], p_LastDamageIssuer [ MAX_PLAYERS ] = { INVALID_PLAYER_ID, ... }, - p_LastWeaponIssuer [ MAX_PLAYERS ] + p_LastWeaponIssuer [ MAX_PLAYERS ], + p_LastDeath [ MAX_PLAYERS ], + p_DeathSpam [ MAX_PLAYERS char ] ; /* ** Forwards ** */ @@ -283,6 +285,7 @@ hook OnPlayerConnect( playerid ) // Reset variables p_PlayerHealth[ playerid ] [ E_UPDATE_FAIL ] = 0; p_PlayerArmour[ playerid ] [ E_UPDATE_FAIL ] = 0; + p_DeathSpam{ playerid } = 0; } return 1; } @@ -563,16 +566,36 @@ stock AC_CheckForHealthHacks( playerid, iTicks ) hook OnPlayerDeath( playerid, killerid, reason ) { - if ( !IsPlayerNPC( playerid ) ) + if ( ! IsPlayerNPC( playerid ) ) { + new + server_time = gettime( ); + // Reset spawned variable AC_SetPlayerSpawned( playerid, false ); + // Anti-fakekill + switch( server_time - p_LastDeath[ playerid ] ) + { + case 0 .. 3: + { + if ( p_DeathSpam{ playerid } ++ == 3 ) + { + CallLocalFunction( "OnPlayerCheatDetected", "ddd", playerid, CHEAT_TYPE_FAKEKILL, p_DeathSpam{ playerid } ); + return Y_HOOKS_BREAK_RETURN_1; + } + } + default: p_DeathSpam{ playerid } = 0; + } + + p_LastDeath[ playerid ] = server_time; + // Died in Vehicle 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; + } CallRemoteFunction( "OnPlayerDeathEx", "ddfd", playerid, p_LastDamageIssuer[ playerid ], p_LastWeaponIssuer[ playerid ], 3.3, 3 ); } diff --git a/gamemodes/irresistible/cnr/player.pwn b/gamemodes/irresistible/cnr/player.pwn index d4f8173..2cd70fb 100644 --- a/gamemodes/irresistible/cnr/player.pwn +++ b/gamemodes/irresistible/cnr/player.pwn @@ -114,8 +114,6 @@ new bool: p_AidsVaccine [ MAX_PLAYERS char ], bool: p_CantUseAsk [ MAX_PLAYERS char ], bool: p_AdminLog [ MAX_PLAYERS char ], - LastDeath [ MAX_PLAYERS ], - DeathSpam [ MAX_PLAYERS char ], bool: p_beingSpectated [ MAX_PLAYERS ], p_whomSpectating [ MAX_PLAYERS ], bool: p_InAnimation [ MAX_PLAYERS char ], @@ -135,8 +133,6 @@ new p_IncorrectLogins [ MAX_PLAYERS char ], p_Robberies [ MAX_PLAYERS ], p_ViewingStats [ MAX_PLAYERS ] = { INVALID_PLAYER_ID, ... }, - p_CarWarpTime [ MAX_PLAYERS ], - p_CarWarpVehicleID [ MAX_PLAYERS ], p_AntiTextSpamCount [ MAX_PLAYERS char ], Float: p_PlayerBuggerX [ MAX_PLAYERS ], Float: p_PlayerBuggerY [ MAX_PLAYERS ], diff --git a/gamemodes/sf-cnr.pwn b/gamemodes/sf-cnr.pwn index b095342..ab1b080 100644 --- a/gamemodes/sf-cnr.pwn +++ b/gamemodes/sf-cnr.pwn @@ -4044,7 +4044,6 @@ public OnPlayerDisconnect( playerid, reason ) p_FPSCounter { playerid } = false; p_Ropes [ playerid ] = 0; p_Scissors [ playerid ] = 0; - DeathSpam { playerid } = 0; p_Fires [ playerid ] = 0; p_PingImmunity { playerid } = 0; p_Robberies [ playerid ] = 0; @@ -5063,20 +5062,6 @@ public OnPlayerDeath( playerid, killerid, reason ) return SendServerMessage( playerid, "Possible Fake-kill detected - 0x0A" ), KickPlayerTimed( playerid ); } - switch( g_iTime - LastDeath[ playerid ] ) - { - case 0 .. 3: - { - if ( DeathSpam{ playerid }++ == 3 ) - { - SendGlobalMessage( -1, ""COL_PINK"[ANTI-CHEAT]{FFFFFF} %s(%d) has been banned for fake-killing.", ReturnPlayerName( playerid ), playerid ); - BanEx( playerid, "Fake-kill" ); - return 1; - } - } - default: DeathSpam{ playerid } = 0; - } - // Robbery system if ( IsPlayerNPC( killerid ) ) { @@ -5089,7 +5074,6 @@ public OnPlayerDeath( playerid, killerid, reason ) } // Reset player variables - LastDeath[ playerid ] = g_iTime; p_Spawned{ playerid } = false; p_QuitToAvoidTimestamp[ playerid ] = 0; CutSpectation( playerid ); @@ -5225,7 +5209,8 @@ public OnPlayerDeath( playerid, killerid, reason ) if ( p_Class[ killerid ] == CLASS_POLICE ) { - if ( p_Class[ killerid ] == p_Class[ playerid ] ) { + if ( p_Class[ killerid ] == p_Class[ playerid ] ) + { // SendClientMessageToAdmins( -1, ""COL_PINK"[FAKE-KILL]{FFFFFF} Traces of fake-kill have came from %s: "COL_GREY"%s", ReturnPlayerName( playerid ), ReturnPlayerIP( playerid ) ); // KickPlayerTimed( playerid ); SendClientMessageFormatted( killerid, -1, ""COL_BLUE"[INNOCENT KILL]{FFFFFF} You have killed a team mate %s, you have lost 2 score and "COL_GOLD"$10,000{FFFFFF}.", ReturnPlayerName( playerid ) ); @@ -5239,38 +5224,35 @@ public OnPlayerDeath( playerid, killerid, reason ) } else { - if ( !DeathSpam{ playerid } ) // If the player doesn't even have a death-spam count. + if ( !IsPlayerInEvent( killerid ) ) // Allow in event { - if ( !IsPlayerInEvent( killerid ) ) // Allow in event + if ( p_WantedLevel[ playerid ] > 5 ) { - if ( p_WantedLevel[ playerid ] > 5 ) - { - static const killedWords[ ] [ ] = { { "murked" }, { "killed" }, { "ended" }, { "slain" }, { "massacred" }, { "destroyed" }, { "screwed" } }; - new cashEarned = ( p_WantedLevel[ playerid ] < MAX_WANTED_LVL ? p_WantedLevel[ playerid ] : MAX_WANTED_LVL ) * ( reason == 38 ? 170 : 270 ); - GivePlayerCash( killerid, cashEarned ); - GivePlayerScore( killerid, 2 ); - if ( cashEarned > 20000 ) printf("[police kill] %s -> %s - %s", ReturnPlayerName( killerid ), ReturnPlayerName( playerid ), cash_format( cashEarned ) ); // 8hska7082bmahu - if ( p_WantedLevel[ playerid ] > 64 ) SendGlobalMessage( -1, ""COL_GOLD"[POLICE KILL]{FFFFFF} %s(%d) has %s %s(%d) who had a wanted level of %d!", ReturnPlayerName( killerid ), killerid, killedWords[ random( sizeof( killedWords ) ) ], ReturnPlayerName( playerid ), playerid, p_WantedLevel[ playerid ] ); - SendClientMessageFormatted( killerid, -1, ""COL_GOLD"[ACHIEVE]{FFFFFF} You have killed %s(%d) with a wanted level of %d; earning you "COL_GOLD"%s{FFFFFF} and 2 score!", ReturnPlayerName( playerid ), playerid, p_WantedLevel[ playerid ], cash_format( cashEarned ) ); - } - else - { - if ( p_WantedLevel[ playerid ] <= 0 ) { - SendClientMessageFormatted( killerid, -1, ""COL_BLUE"[INNOCENT KILL]{FFFFFF} You have killed innocent %s, you have lost 2 score and "COL_GOLD"$10,000{FFFFFF}.", ReturnPlayerName( playerid ) ); - GivePlayerCash( killerid, -10000 ); - GivePlayerScore( killerid, -2 ); - JailPlayer( killerid, 200, 1 ); - cmd_rules( killerid, "" ); - WarnPlayerClass( killerid, p_inArmy{ killerid } ); - SendGlobalMessage( -1, ""COL_GOLD"[JAIL]{FFFFFF} %s(%d) has been sent to jail for 200 seconds by the server "COL_GREEN"[REASON: Killing Innocent(s)]", ReturnPlayerName( killerid ), killerid ); - } - else if ( p_WantedLevel[ playerid ] <= 5 ) { - SendClientMessageFormatted( killerid, -1, ""COL_BLUE"[INNOCENT KILL]{FFFFFF} You have killed low suspect %s, you have lost 2 score and "COL_GOLD"$5,000{FFFFFF}.", ReturnPlayerName( playerid ) ); - GivePlayerCash( killerid, -5000 ); - GivePlayerScore( killerid, -2 ); - } - } - } + static const killedWords[ ] [ ] = { { "murked" }, { "killed" }, { "ended" }, { "slain" }, { "massacred" }, { "destroyed" }, { "screwed" } }; + new cashEarned = ( p_WantedLevel[ playerid ] < MAX_WANTED_LVL ? p_WantedLevel[ playerid ] : MAX_WANTED_LVL ) * ( reason == 38 ? 170 : 270 ); + GivePlayerCash( killerid, cashEarned ); + GivePlayerScore( killerid, 2 ); + if ( cashEarned > 20000 ) printf("[police kill] %s -> %s - %s", ReturnPlayerName( killerid ), ReturnPlayerName( playerid ), cash_format( cashEarned ) ); // 8hska7082bmahu + if ( p_WantedLevel[ playerid ] > 64 ) SendGlobalMessage( -1, ""COL_GOLD"[POLICE KILL]{FFFFFF} %s(%d) has %s %s(%d) who had a wanted level of %d!", ReturnPlayerName( killerid ), killerid, killedWords[ random( sizeof( killedWords ) ) ], ReturnPlayerName( playerid ), playerid, p_WantedLevel[ playerid ] ); + SendClientMessageFormatted( killerid, -1, ""COL_GOLD"[ACHIEVE]{FFFFFF} You have killed %s(%d) with a wanted level of %d; earning you "COL_GOLD"%s{FFFFFF} and 2 score!", ReturnPlayerName( playerid ), playerid, p_WantedLevel[ playerid ], cash_format( cashEarned ) ); + } + else + { + if ( p_WantedLevel[ playerid ] <= 0 ) { + SendClientMessageFormatted( killerid, -1, ""COL_BLUE"[INNOCENT KILL]{FFFFFF} You have killed innocent %s, you have lost 2 score and "COL_GOLD"$10,000{FFFFFF}.", ReturnPlayerName( playerid ) ); + GivePlayerCash( killerid, -10000 ); + GivePlayerScore( killerid, -2 ); + JailPlayer( killerid, 200, 1 ); + cmd_rules( killerid, "" ); + WarnPlayerClass( killerid, p_inArmy{ killerid } ); + SendGlobalMessage( -1, ""COL_GOLD"[JAIL]{FFFFFF} %s(%d) has been sent to jail for 200 seconds by the server "COL_GREEN"[REASON: Killing Innocent(s)]", ReturnPlayerName( killerid ), killerid ); + } + else if ( p_WantedLevel[ playerid ] <= 5 ) { + SendClientMessageFormatted( killerid, -1, ""COL_BLUE"[INNOCENT KILL]{FFFFFF} You have killed low suspect %s, you have lost 2 score and "COL_GOLD"$5,000{FFFFFF}.", ReturnPlayerName( playerid ) ); + GivePlayerCash( killerid, -5000 ); + GivePlayerScore( killerid, -2 ); + } + } } } } @@ -11966,20 +11948,6 @@ public OnPlayerStateChange(playerid, newstate, oldstate) p_LastPlayerState{ playerid } = oldstate; - if ( newstate == PLAYER_STATE_DRIVER && p_AdminLevel[ playerid ] <= 0 ) - { - if ( GetPlayerVehicleID( playerid ) != p_CarWarpVehicleID[ playerid ] ) - { - if ( p_CarWarpTime[ playerid ] > g_iTime ) - { - SendGlobalMessage( -1, ""COL_PINK"[ANTI-CHEAT]{FFFFFF} %s(%d) has been banned for car warping.", ReturnPlayerName( playerid ), playerid ); - BanEx( playerid, "Car Warp" ); - return 1; - } - p_CarWarpTime[ playerid ] = g_iTime + 1; - p_CarWarpVehicleID[ playerid ] = GetPlayerVehicleID( playerid ); - } - } if ( oldstate == PLAYER_STATE_SPECTATING ) { @@ -13715,20 +13683,30 @@ function unpause_Player( 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 ); - return 1; } 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 ); - return 1; + } + 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 ); - return 1; } else if ( detection == CHEAT_TYPE_FLYHACKS ) { @@ -13739,7 +13717,6 @@ function unpause_Player( 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 ) ); - return 1; } else {