move fake-kill and car warp code into respective anticheat modules

This commit is contained in:
Lorenc Pekaj 2018-09-19 10:23:00 +10:00
parent 52b7d22ee7
commit 8831de493a
5 changed files with 109 additions and 74 deletions

View File

@ -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"

View File

@ -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;
}

View File

@ -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 );
}

View File

@ -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 ],

View File

@ -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 ) );
@ -5238,8 +5223,6 @@ public OnPlayerDeath( playerid, killerid, reason )
return 1;
}
else
{
if ( !DeathSpam{ playerid } ) // If the player doesn't even have a death-spam count.
{
if ( !IsPlayerInEvent( killerid ) ) // Allow in event
{
@ -5273,7 +5256,6 @@ public OnPlayerDeath( playerid, killerid, reason )
}
}
}
}
if ( p_Class[ playerid ] == CLASS_POLICE && p_Class[ killerid ] == CLASS_CIVILIAN )
{
@ -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
{