move thermal vision fix code as an anticheat module

This commit is contained in:
Lorenc Pekaj 2019-01-01 18:30:15 +11:00
parent e64ce92566
commit b19c4be348
3 changed files with 67 additions and 47 deletions

View File

@ -158,6 +158,7 @@ stock AC_SetPlayerSpawned( playerid, bool: spawned ) {
/* ** Modules (remove to disable) ** */
#include "irresistible\anticheat\money.pwn"
#include "irresistible\anticheat\thermal_vision.pwn"
#include "irresistible\anticheat\bot_attack.pwn"
#include "irresistible\anticheat\hitpoints.pwn"
#include "irresistible\anticheat\weapon.pwn"

View File

@ -0,0 +1,64 @@
/*
* Irresistible Gaming (c) 2018
* Developed by wups, Lorenc
* Module: irresistible\anticheat\thermal_vision.pwn
* Purpose: prevents players from randomly enabling thermal vision
*/
/* ** Includes ** */
#include < YSI\y_hooks >
/* ** Hooks ** */
hook OnPlayerUpdate( playerid ) {
if ( ! AC_NightThermalVisionHack( playerid ) ) {
return Y_HOOKS_BREAK_RETURN_1;
} else {
return Y_HOOKS_CONTINUE_RETURN_1;
}
}
/* ** Functions ** */
static stock AC_NightThermalVisionHack( playerid ) // Created by wups
{
static
weapon;
weapon = GetPlayerWeapon( playerid );
if ( weapon == 44 || weapon == 45 )
{
static
HoldingFire[ MAX_PLAYERS ],
IsHoldingFire[ MAX_PLAYERS char ],
CanHoldAgain[ MAX_PLAYERS char ],
keys, lr, tick
;
GetPlayerKeys( playerid, keys, lr, lr);
tick = GetTickCount( );
if ( keys & KEY_FIRE )
{
if ( !IsHoldingFire{ playerid } && CanHoldAgain{ playerid } )
{
IsHoldingFire{ playerid } = 1;
HoldingFire[ playerid ] = tick;
CanHoldAgain{ playerid } = 0;
}
}
else if ( !CanHoldAgain{ playerid } ) CanHoldAgain{ playerid } = 1;
if ( IsHoldingFire{ playerid } )
{
if ( tick - 1500 <= HoldingFire[ playerid ] )
{
return 0;
}
else
{
IsHoldingFire{ playerid } = 0;
return 1;
}
}
}
return 1;
}

View File

@ -5412,7 +5412,7 @@ public OnPlayerUpdate( playerid )
return 0;
}
}
return fix_NightThermalVisionHack( playerid );
return 1;
}
public OnPlayerStreamIn(playerid, forplayerid)
@ -8375,51 +8375,6 @@ function HidePlayerHelpDialog( playerid )
PlayerTextDrawHide( playerid, p_HelpBoxTD[ playerid ] );
}
stock fix_NightThermalVisionHack( playerid ) // Created by wups
{
static
weapon;
weapon = GetPlayerWeapon( playerid );
if ( weapon == 44 || weapon == 45 )
{
static
HoldingFire[ MAX_PLAYERS ],
IsHoldingFire[ MAX_PLAYERS char ],
CanHoldAgain[ MAX_PLAYERS char ],
keys, lr, tick
;
GetPlayerKeys( playerid, keys, lr, lr);
tick = GetTickCount( );
if ( keys & KEY_FIRE )
{
if ( !IsHoldingFire{ playerid } && CanHoldAgain{ playerid } )
{
IsHoldingFire{ playerid } = 1;
HoldingFire[ playerid ] = tick;
CanHoldAgain{ playerid } = 0;
}
}
else if ( !CanHoldAgain{ playerid } ) CanHoldAgain{ playerid } = 1;
if ( IsHoldingFire{ playerid } )
{
if ( tick - 1500 <= HoldingFire[ playerid ] )
{
return 0;
}
else
{
IsHoldingFire{ playerid } = 0;
return 1;
}
}
}
return 1;
}
stock hasBadDrivebyWeapon( playerid )
{
for( new i; i < sizeof g_BannedDrivebyWeapons; i++ )