2017-03-01 21:05:40 +01:00
//====================================================================================================
//
// Name: [entWatch] Restrictions
// Author: zaCade & Prometheum
// Description: Handle the restrictions of [entWatch]
//
//====================================================================================================
2017-11-21 02:42:43 +01:00
# include <multicolors>
2017-03-01 21:05:40 +01:00
# pragma newdecls required
# include <sourcemod>
# include <clientprefs>
# include <entWatch_core>
2019-04-08 12:19:03 +02:00
# include <entWatch_helpers>
2017-03-01 21:05:40 +01:00
/* FORWARDS */
Handle g_hFwd_OnClientRestricted ;
Handle g_hFwd_OnClientUnrestricted ;
/* COOKIES */
2017-10-12 21:53:17 +02:00
Handle g_hCookie_RestrictIssued ;
Handle g_hCookie_RestrictExpire ;
2019-04-27 20:11:18 +02:00
Handle g_hCookie_RestrictLength ;
/* BOOLEANS */
bool g_bRestrictedTemp [ MAXPLAYERS + 1 ] ;
2017-03-01 21:05:40 +01:00
/* INTERGERS */
2017-10-12 21:53:17 +02:00
int g_iRestrictIssued [ MAXPLAYERS + 1 ] ;
int g_iRestrictLength [ MAXPLAYERS + 1 ] ;
int g_iRestrictExpire [ MAXPLAYERS + 1 ] ;
2017-03-01 21:05:40 +01:00
2019-04-27 20:11:18 +02:00
/* STRINGMAPS */
StringMap g_hTrie_Storage ;
2017-03-01 21:05:40 +01:00
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public Plugin myinfo =
{
name = " [entWatch] Restrictions " ,
author = " zaCade & Prometheum " ,
description = " Handle the restrictions of [entWatch] " ,
version = " 4.0.0 "
} ;
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public APLRes AskPluginLoad2 ( Handle hMyself , bool bLate , char [ ] sError , int errorSize )
{
CreateNative ( " EW_ClientRestrict " , Native_ClientRestrict ) ;
CreateNative ( " EW_ClientUnrestrict " , Native_ClientUnrestrict ) ;
CreateNative ( " EW_ClientRestricted " , Native_ClientRestricted ) ;
2018-08-08 17:31:50 +02:00
2017-03-01 21:05:40 +01:00
RegPluginLibrary ( " entWatch-restrictions " ) ;
return APLRes_Success ;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnPluginStart ( )
{
LoadTranslations ( " common.phrases " ) ;
LoadTranslations ( " entWatch.restrictions.phrases " ) ;
2018-08-08 17:31:50 +02:00
2017-03-01 21:05:40 +01:00
g_hFwd_OnClientRestricted = CreateGlobalForward ( " EW_OnClientRestricted " , ET_Ignore , Param_Cell , Param_Cell , Param_Cell ) ;
g_hFwd_OnClientUnrestricted = CreateGlobalForward ( " EW_OnClientUnrestricted " , ET_Ignore , Param_Cell , Param_Cell ) ;
2018-08-08 17:31:50 +02:00
2017-10-12 21:53:17 +02:00
g_hCookie_RestrictIssued = RegClientCookie ( " EW_RestrictIssued " , " " , CookieAccess_Private ) ;
g_hCookie_RestrictExpire = RegClientCookie ( " EW_RestrictExpire " , " " , CookieAccess_Private ) ;
2019-04-27 20:11:18 +02:00
g_hCookie_RestrictLength = RegClientCookie ( " EW_RestrictLength " , " " , CookieAccess_Private ) ;
g_hTrie_Storage = new StringMap ( ) ;
2018-08-08 17:31:50 +02:00
2017-03-01 21:05:40 +01:00
RegAdminCmd ( " sm_eban " , Command_ClientRestrict , ADMFLAG_BAN ) ;
RegAdminCmd ( " sm_eunban " , Command_ClientUnrestrict , ADMFLAG_UNBAN ) ;
2019-04-10 14:15:23 +02:00
RegConsoleCmd ( " sm_restrictions " , Command_DisplayRestrictions ) ;
2019-11-19 21:05:00 +01:00
RegConsoleCmd ( " sm_ebanlist " , Command_DisplayRestrictions ) ;
2019-06-09 11:11:04 +02:00
RegConsoleCmd ( " sm_status " , Command_DisplayStatus ) ;
2019-06-11 19:42:40 +02:00
for ( int client = 1 ; client < = MaxClients ; client + + )
{
2019-06-15 15:45:07 +02:00
if ( IsClientConnected ( client ) )
2019-06-11 19:42:40 +02:00
OnClientPutInServer ( client ) ;
2019-06-15 15:45:07 +02:00
if ( AreClientCookiesCached ( client ) )
2019-06-11 19:42:40 +02:00
OnClientCookiesCached ( client ) ;
}
2017-03-01 21:05:40 +01:00
}
2019-04-27 20:11:18 +02:00
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnMapStart ( )
{
g_hTrie_Storage . Clear ( ) ;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnClientPutInServer ( int client )
{
char sAddress [ 32 ] ;
GetClientIP ( client , sAddress , sizeof ( sAddress ) ) ;
bool bRestrictedTemp ;
if ( g_hTrie_Storage . GetValue ( sAddress , bRestrictedTemp ) )
{
g_bRestrictedTemp [ client ] = bRestrictedTemp ;
}
}
2017-03-01 21:05:40 +01:00
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnClientCookiesCached ( int client )
{
2017-10-12 21:53:17 +02:00
g_iRestrictIssued [ client ] = GetClientCookieInt ( client , g_hCookie_RestrictIssued ) ;
g_iRestrictExpire [ client ] = GetClientCookieInt ( client , g_hCookie_RestrictExpire ) ;
2019-04-27 20:11:18 +02:00
g_iRestrictLength [ client ] = GetClientCookieInt ( client , g_hCookie_RestrictLength ) ;
2017-03-01 21:05:40 +01:00
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnClientDisconnect ( int client )
{
2019-04-27 20:11:18 +02:00
if ( g_bRestrictedTemp [ client ] )
{
char sAddress [ 32 ] ;
GetClientIP ( client , sAddress , sizeof ( sAddress ) ) ;
g_hTrie_Storage . SetArray ( sAddress , g_bRestrictedTemp [ client ] , true ) ;
}
g_bRestrictedTemp [ client ] = false ;
2017-10-12 21:53:17 +02:00
g_iRestrictIssued [ client ] = 0 ;
g_iRestrictExpire [ client ] = 0 ;
2019-04-27 20:11:18 +02:00
g_iRestrictLength [ client ] = 0 ;
2017-03-01 21:05:40 +01:00
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public Action Command_ClientRestrict ( int client , int args )
{
if ( ! GetCmdArgs ( ) )
{
CReplyToCommand ( client , " \x07 %s[entWatch] \x07 %sUsage: sm_eban <#userid/name> [duration] " , " E01B5D " , " F16767 " ) ;
return Plugin_Handled ;
}
2018-08-08 17:31:50 +02:00
2019-04-27 20:11:18 +02:00
char sArguments [ 2 ] [ 32 ] ;
GetCmdArg ( 1 , sArguments [ 0 ] , sizeof ( sArguments [ ] ) ) ;
GetCmdArg ( 2 , sArguments [ 1 ] , sizeof ( sArguments [ ] ) ) ;
2018-08-08 17:31:50 +02:00
2017-03-01 21:05:40 +01:00
int target ;
2019-04-27 20:11:18 +02:00
if ( ( target = FindTarget ( client , sArguments [ 0 ] , true ) ) = = - 1 )
2017-03-01 21:05:40 +01:00
return Plugin_Handled ;
2018-08-08 17:31:50 +02:00
2019-04-27 20:11:18 +02:00
if ( GetCmdArgs ( ) > = 2 )
2017-03-01 21:05:40 +01:00
{
2019-04-27 20:11:18 +02:00
int length = StringToInt ( sArguments [ 1 ] ) ;
if ( ClientRestrict ( client , target , length ) )
2017-03-01 21:05:40 +01:00
{
2019-04-27 20:11:18 +02:00
if ( length )
{
CPrintToChatAll ( " \x07 %s[entWatch] \x07 %s%N \x07 %s restricted \x07 %s%N \x07 %s for \x07 %s%d \x07 %s minutes. " , " E01B5D " , " EDEDED " , client , " F16767 " , " EDEDED " , target , " F16767 " , " EDEDED " , length , " F16767 " ) ;
LogAction ( client , target , " %L restricted %L for %d minutes. " , client , target , length ) ;
}
else
{
CPrintToChatAll ( " \x07 %s[entWatch] \x07 %s%N \x07 %s restricted \x07 %s%N \x07 %s permanently. " , " E01B5D " , " EDEDED " , client , " F16767 " , " EDEDED " , target , " F16767 " ) ;
LogAction ( client , target , " %L restricted %L permanently. " , client , target ) ;
}
2017-03-01 21:05:40 +01:00
}
2019-04-27 20:11:18 +02:00
}
else
{
if ( ClientRestrict ( client , target , - 1 ) )
2017-03-01 21:05:40 +01:00
{
2019-04-27 20:11:18 +02:00
CPrintToChatAll ( " \x07 %s[entWatch] \x07 %s%N \x07 %s restricted \x07 %s%N \x07 %s temporarily. " , " E01B5D " , " EDEDED " , client , " F16767 " , " EDEDED " , target , " F16767 " ) ;
LogAction ( client , target , " %L restricted %L temporarily. " , client , target ) ;
2017-03-01 21:05:40 +01:00
}
}
2018-08-08 17:31:50 +02:00
2017-03-01 21:05:40 +01:00
return Plugin_Handled ;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public Action Command_ClientUnrestrict ( int client , int args )
{
if ( ! GetCmdArgs ( ) )
{
CReplyToCommand ( client , " \x07 %s[entWatch] \x07 %sUsage: sm_eunban <#userid/name> " , " E01B5D " , " F16767 " ) ;
return Plugin_Handled ;
}
2018-08-08 17:31:50 +02:00
2019-04-27 20:11:18 +02:00
char sArguments [ 1 ] [ 32 ] ;
GetCmdArg ( 1 , sArguments [ 0 ] , sizeof ( sArguments [ ] ) ) ;
2018-08-08 17:31:50 +02:00
2017-03-01 21:05:40 +01:00
int target ;
2019-04-27 20:11:18 +02:00
if ( ( target = FindTarget ( client , sArguments [ 0 ] , true ) ) = = - 1 )
2017-03-01 21:05:40 +01:00
return Plugin_Handled ;
2018-08-08 17:31:50 +02:00
2017-03-01 21:05:40 +01:00
if ( ClientUnrestrict ( client , target ) )
{
CPrintToChatAll ( " \x07 %s[entWatch] \x07 %s%N \x07 %s unrestricted \x07 %s%N \x07 %s. " , " E01B5D " , " EDEDED " , client , " F16767 " , " EDEDED " , target , " F16767 " ) ;
LogAction ( client , target , " %L unrestricted %L. " , client , target ) ;
}
2018-08-08 17:31:50 +02:00
2017-03-01 21:05:40 +01:00
return Plugin_Handled ;
}
2019-04-10 14:15:23 +02:00
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public Action Command_DisplayRestrictions ( int client , int args )
{
char aBuf [ 1024 ] ;
char aBuf2 [ MAX_NAME_LENGTH ] ;
2019-06-11 19:19:09 +02:00
for ( int i = 1 ; i < = MaxClients ; i + + )
2019-04-10 14:15:23 +02:00
{
2019-06-11 19:19:09 +02:00
if ( IsClientInGame ( i ) & & ! IsFakeClient ( i ) )
2019-04-10 14:15:23 +02:00
{
2019-06-11 19:19:09 +02:00
if ( ClientRestricted ( i ) )
2019-04-10 14:15:23 +02:00
{
GetClientName ( i , aBuf2 , sizeof ( aBuf2 ) ) ;
StrCat ( aBuf , sizeof ( aBuf ) , aBuf2 ) ;
StrCat ( aBuf , sizeof ( aBuf ) , " , " ) ;
}
}
}
2019-06-11 19:19:09 +02:00
if ( strlen ( aBuf ) )
2019-04-10 14:15:23 +02:00
{
aBuf [ strlen ( aBuf ) - 2 ] = 0 ;
2019-06-11 19:19:09 +02:00
CReplyToCommand ( client , " \x07 %s[entWatch] \x07 %sCurrently restricted clients: \x07 %s%s " , " E01B5D " , " F16767 " , " EDEDED " , aBuf ) ;
2019-04-10 14:15:23 +02:00
}
else
2019-06-11 19:19:09 +02:00
CReplyToCommand ( client , " \x07 %s[entWatch] \x07 %sCurrently restricted clients: \x07 %snone " , " E01B5D " , " F16767 " , " EDEDED " ) ;
2019-04-10 14:15:23 +02:00
return Plugin_Handled ;
}
2019-06-09 11:11:04 +02:00
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public Action Command_DisplayStatus ( int client , int args )
{
2019-06-11 19:19:09 +02:00
if ( CheckCommandAccess ( client , " " , ADMFLAG_BAN ) & & GetCmdArgs ( ) )
{
char sArguments [ 1 ] [ 32 ] ;
GetCmdArg ( 1 , sArguments [ 0 ] , sizeof ( sArguments [ ] ) ) ;
int target ;
if ( ( target = FindTarget ( client , sArguments [ 0 ] , true ) ) = = - 1 )
return Plugin_Handled ;
if ( ! AreClientCookiesCached ( target ) )
{
CReplyToCommand ( client , " \x07 %s[entWatch] \x07 %s%N \x07 %s their cookies are still loading. " , " E01B5D " , " EDEDED " , target , " F16767 " ) ;
return Plugin_Handled ;
}
else if ( g_bRestrictedTemp [ target ] )
{
CReplyToCommand ( client , " \x07 %s[entWatch] \x07 %s%N \x07 %s is currently temporarily restricted. " , " E01B5D " , " EDEDED " , target , " F16767 " ) ;
return Plugin_Handled ;
}
else if ( g_iRestrictIssued [ target ] & & g_iRestrictExpire [ target ] = = 0 )
{
CReplyToCommand ( client , " \x07 %s[entWatch] \x07 %s%N \x07 %s is currently permanently restricted. " , " E01B5D " , " EDEDED " , target , " F16767 " ) ;
return Plugin_Handled ;
}
else if ( g_iRestrictIssued [ target ] & & g_iRestrictExpire [ target ] > = GetTime ( ) )
{
2019-07-16 00:44:48 +02:00
char sTimeRemaining [ 64 ] ;
2019-06-11 19:19:09 +02:00
int iTimeRemaining = g_iRestrictExpire [ target ] - GetTime ( ) ;
int iDays = ( iTimeRemaining / 86400 ) ;
int iHours = ( iTimeRemaining / 3600 ) % 24 ;
int iMinutes = ( iTimeRemaining / 60 ) % 60 ;
int iSeconds = ( iTimeRemaining % 60 ) ;
if ( iDays )
2019-07-16 00:44:48 +02:00
Format ( sTimeRemaining , sizeof ( sTimeRemaining ) , " %d Days %d Hours %d Minutes %d Seconds " , iDays , iHours , iMinutes , iSeconds ) ;
2019-06-11 19:19:09 +02:00
else if ( iHours )
2019-07-16 00:44:48 +02:00
Format ( sTimeRemaining , sizeof ( sTimeRemaining ) , " %d Hours %d Minutes %d Seconds " , iHours , iMinutes , iSeconds ) ;
2019-06-11 19:19:09 +02:00
else if ( iMinutes )
2019-07-16 00:44:48 +02:00
Format ( sTimeRemaining , sizeof ( sTimeRemaining ) , " %d Minutes %d Seconds " , iMinutes , iSeconds ) ;
2019-06-11 19:19:09 +02:00
else
2019-07-16 00:44:48 +02:00
Format ( sTimeRemaining , sizeof ( sTimeRemaining ) , " %d Seconds " , iSeconds ) ;
2019-06-11 19:19:09 +02:00
2019-07-16 00:44:48 +02:00
CReplyToCommand ( client , " \x07 %s[entWatch] \x07 %s%N \x07 %s is currently restricted for another \x07 %s%s \x07 %s. " , " E01B5D " , " EDEDED " , target , " F16767 " , " EDEDED " , sTimeRemaining , " F16767 " ) ;
2019-06-11 19:19:09 +02:00
return Plugin_Handled ;
}
else
{
CReplyToCommand ( client , " \x07 %s[entWatch] \x07 %s%N \x07 %s is currently not restricted. " , " E01B5D " , " EDEDED " , target , " F16767 " ) ;
return Plugin_Handled ;
}
}
else
{
if ( ! AreClientCookiesCached ( client ) )
{
CReplyToCommand ( client , " \x07 %s[entWatch] \x07 %sYour cookies are still loading. " , " E01B5D " , " F16767 " ) ;
return Plugin_Handled ;
}
else if ( g_bRestrictedTemp [ client ] )
{
CReplyToCommand ( client , " \x07 %s[entWatch] \x07 %sYou are currently temporarily restricted. " , " E01B5D " , " F16767 " ) ;
return Plugin_Handled ;
}
else if ( g_iRestrictIssued [ client ] & & g_iRestrictExpire [ client ] = = 0 )
{
CReplyToCommand ( client , " \x07 %s[entWatch] \x07 %sYou are currently permanently restricted. " , " E01B5D " , " F16767 " ) ;
return Plugin_Handled ;
}
else if ( g_iRestrictIssued [ client ] & & g_iRestrictExpire [ client ] > = GetTime ( ) )
{
2019-07-16 00:44:48 +02:00
char sTimeRemaining [ 64 ] ;
2019-06-11 19:19:09 +02:00
int iTimeRemaining = g_iRestrictExpire [ client ] - GetTime ( ) ;
int iDays = ( iTimeRemaining / 86400 ) ;
int iHours = ( iTimeRemaining / 3600 ) % 24 ;
int iMinutes = ( iTimeRemaining / 60 ) % 60 ;
int iSeconds = ( iTimeRemaining % 60 ) ;
if ( iDays )
2019-07-16 00:44:48 +02:00
Format ( sTimeRemaining , sizeof ( sTimeRemaining ) , " %d Days %d Hours %d Minutes %d Seconds " , iDays , iHours , iMinutes , iSeconds ) ;
2019-06-11 19:19:09 +02:00
else if ( iHours )
2019-07-16 00:44:48 +02:00
Format ( sTimeRemaining , sizeof ( sTimeRemaining ) , " %d Hours %d Minutes %d Seconds " , iHours , iMinutes , iSeconds ) ;
2019-06-11 19:19:09 +02:00
else if ( iMinutes )
2019-07-16 00:44:48 +02:00
Format ( sTimeRemaining , sizeof ( sTimeRemaining ) , " %d Minutes %d Seconds " , iMinutes , iSeconds ) ;
2019-06-11 19:19:09 +02:00
else
2019-07-16 00:44:48 +02:00
Format ( sTimeRemaining , sizeof ( sTimeRemaining ) , " %d Seconds " , iSeconds ) ;
2019-06-11 19:19:09 +02:00
2019-07-16 00:44:48 +02:00
CReplyToCommand ( client , " \x07 %s[entWatch] \x07 %sYou are currently restricted for another \x07 %s%s \x07 %s. " , " E01B5D " , " F16767 " , " EDEDED " , sTimeRemaining , " F16767 " ) ;
2019-06-11 19:19:09 +02:00
return Plugin_Handled ;
}
else
{
CReplyToCommand ( client , " \x07 %s[entWatch] \x07 %sYou are currently not restricted. " , " E01B5D " , " F16767 " ) ;
return Plugin_Handled ;
}
}
2019-06-09 11:11:04 +02:00
}
2017-03-01 21:05:40 +01:00
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
2018-11-13 17:34:17 +01:00
public Action EW_OnClientItemCanPickup ( int client , int index )
2017-03-01 21:05:40 +01:00
{
return ClientRestricted ( client ) ? Plugin_Handled : Plugin_Continue ;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
2018-11-13 17:34:17 +01:00
public Action EW_OnClientItemCanActivate ( int client , int index )
2017-03-01 21:05:40 +01:00
{
return ClientRestricted ( client ) ? Plugin_Handled : Plugin_Continue ;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
stock bool ClientRestrict ( int client , int target , int length )
{
if ( ! Client_IsValid ( client ) | | ! Client_IsValid ( target ) | | ! AreClientCookiesCached ( target ) | | ClientRestricted ( target ) )
return false ;
2018-08-08 17:31:50 +02:00
2019-04-27 20:11:18 +02:00
if ( length = = - 1 )
{
g_bRestrictedTemp [ target ] = true ;
}
else if ( length = = 0 )
{
g_bRestrictedTemp [ target ] = false ;
g_iRestrictIssued [ target ] = GetTime ( ) ;
g_iRestrictExpire [ target ] = 0 ;
g_iRestrictLength [ target ] = 0 ;
SetClientCookieInt ( target , g_hCookie_RestrictIssued , GetTime ( ) ) ;
SetClientCookieInt ( target , g_hCookie_RestrictExpire , 0 ) ;
SetClientCookieInt ( target , g_hCookie_RestrictLength , 0 ) ;
}
else
{
g_bRestrictedTemp [ target ] = false ;
g_iRestrictIssued [ target ] = GetTime ( ) ;
g_iRestrictExpire [ target ] = GetTime ( ) + ( length * 60 ) ;
g_iRestrictLength [ target ] = length ;
SetClientCookieInt ( target , g_hCookie_RestrictIssued , GetTime ( ) ) ;
SetClientCookieInt ( target , g_hCookie_RestrictExpire , GetTime ( ) + ( length * 60 ) ) ;
SetClientCookieInt ( target , g_hCookie_RestrictLength , length ) ;
}
2018-08-08 17:31:50 +02:00
2017-03-01 21:05:40 +01:00
Call_StartForward ( g_hFwd_OnClientRestricted ) ;
Call_PushCell ( client ) ;
Call_PushCell ( target ) ;
Call_PushCell ( length ) ;
Call_Finish ( ) ;
2018-08-08 17:31:50 +02:00
2017-03-01 21:05:40 +01:00
return true ;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
stock bool ClientUnrestrict ( int client , int target )
{
if ( ! Client_IsValid ( client ) | | ! Client_IsValid ( target ) | | ! AreClientCookiesCached ( target ) | | ! ClientRestricted ( target ) )
return false ;
2018-08-08 17:31:50 +02:00
2019-04-27 20:11:18 +02:00
g_bRestrictedTemp [ target ] = false ;
2017-10-12 21:53:17 +02:00
g_iRestrictIssued [ target ] = 0 ;
g_iRestrictExpire [ target ] = 0 ;
2019-04-27 20:11:18 +02:00
g_iRestrictLength [ target ] = 0 ;
2018-08-08 17:31:50 +02:00
2017-10-12 21:53:17 +02:00
SetClientCookieInt ( target , g_hCookie_RestrictIssued , 0 ) ;
SetClientCookieInt ( target , g_hCookie_RestrictExpire , 0 ) ;
2019-04-27 20:11:18 +02:00
SetClientCookieInt ( target , g_hCookie_RestrictLength , 0 ) ;
2018-08-08 17:31:50 +02:00
2017-03-01 21:05:40 +01:00
Call_StartForward ( g_hFwd_OnClientUnrestricted ) ;
Call_PushCell ( client ) ;
Call_PushCell ( target ) ;
Call_Finish ( ) ;
2018-08-08 17:31:50 +02:00
2017-03-01 21:05:40 +01:00
return true ;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
stock bool ClientRestricted ( int client )
{
if ( ! Client_IsValid ( client ) )
return false ;
2018-08-08 17:31:50 +02:00
2017-03-01 21:05:40 +01:00
//Block them when loading cookies..
if ( ! AreClientCookiesCached ( client ) )
return true ;
2018-08-08 17:31:50 +02:00
2019-04-27 20:11:18 +02:00
//Temporary restriction.
if ( g_bRestrictedTemp [ client ] )
return true ;
//Permanent restriction.
2019-06-11 19:19:09 +02:00
if ( g_iRestrictIssued [ client ] & & g_iRestrictExpire [ client ] = = 0 )
2017-03-01 21:05:40 +01:00
return true ;
2018-08-08 17:31:50 +02:00
2019-04-27 20:11:18 +02:00
//Normal restriction.
if ( g_iRestrictIssued [ client ] & & g_iRestrictExpire [ client ] > = GetTime ( ) )
2017-03-01 21:05:40 +01:00
return true ;
2018-08-08 17:31:50 +02:00
2017-03-01 21:05:40 +01:00
return false ;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public int Native_ClientRestrict ( Handle hPlugin , int numParams )
{
return ClientRestrict ( GetNativeCell ( 1 ) , GetNativeCell ( 2 ) , GetNativeCell ( 3 ) ) ;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public int Native_ClientUnrestrict ( Handle hPlugin , int numParams )
{
return ClientUnrestrict ( GetNativeCell ( 1 ) , GetNativeCell ( 2 ) ) ;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public int Native_ClientRestricted ( Handle hPlugin , int numParams )
{
return ClientRestricted ( GetNativeCell ( 1 ) ) ;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
stock void SetClientCookieInt ( int client , Handle hCookie , int value )
{
char sValue [ 32 ] ;
IntToString ( value , sValue , sizeof ( sValue ) ) ;
2018-08-08 17:31:50 +02:00
2017-03-01 21:05:40 +01:00
SetClientCookie ( client , hCookie , sValue ) ;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
stock int GetClientCookieInt ( int client , Handle hCookie )
{
char sValue [ 32 ] ;
GetClientCookie ( client , hCookie , sValue , sizeof ( sValue ) ) ;
2018-08-08 17:31:50 +02:00
2017-03-01 21:05:40 +01:00
return StringToInt ( sValue ) ;
}