2016-05-08 02:46:46 +02:00
# pragma semicolon 1
# include <sourcemod>
# include <sdktools>
# include <cstrike>
# undef REQUIRE_PLUGIN
# include <adminmenu>
2016-05-10 12:57:25 +02:00
# define REQUIRE_PLUGIN
2016-05-08 02:46:46 +02:00
# pragma newdecls required
enum
{
AABBMinX = 0 ,
AABBMaxX = 1 ,
AABBMinY = 2 ,
AABBMaxY = 3 ,
AABBMinZ = 4 ,
AABBMaxZ = 5 ,
AABBTotalPoints = 6
}
Handle g_hDatabase = null ;
Handle g_hTraceTimer = null ;
2016-12-02 12:55:09 +01:00
Handle g_hRoundEndTimer = null ;
2016-05-08 02:46:46 +02:00
Handle g_hTopMenu = null ;
ConVar g_cvarHookedDecalFrequency = null ;
ConVar g_cvarDecalFrequency = null ;
ConVar g_cvarUseProximityCheck = null ;
2016-12-02 12:55:09 +01:00
ConVar g_cvarSendSpraysToConnectingClients = null ;
ConVar g_cvarUsePersistentSprays = null ;
ConVar g_cvarMaxSprayLifetime = null ;
2016-05-08 02:46:46 +02:00
2016-12-02 12:55:09 +01:00
int g_iOldDecalFreqVal ;
2016-11-30 20:40:59 +01:00
int g_iAllowSpray ;
2016-05-08 02:46:46 +02:00
bool g_bLoadedLate ;
bool g_bSQLite ;
bool g_bGotBans ;
bool g_bGotBlacklist ;
bool g_bFullyConnected ;
2016-12-02 12:55:09 +01:00
bool g_bSkipDecalHook ;
2016-05-08 02:46:46 +02:00
char g_sBanIssuer [ MAXPLAYERS + 1 ] [ 64 ] ;
char g_sBanIssuerSID [ MAXPLAYERS + 1 ] [ 32 ] ;
char g_sBanReason [ MAXPLAYERS + 1 ] [ 32 ] ;
char g_sSprayHash [ MAXPLAYERS + 1 ] [ 16 ] ;
bool g_bSprayBanned [ MAXPLAYERS + 1 ] ;
bool g_bSprayHashBanned [ MAXPLAYERS + 1 ] ;
bool g_bInvokedThroughTopMenu [ MAXPLAYERS + 1 ] ;
bool g_bInvokedThroughListMenu [ MAXPLAYERS + 1 ] ;
2016-12-02 12:55:09 +01:00
int g_iClientToClientSprayLifetime [ MAXPLAYERS + 1 ] [ MAXPLAYERS + 1 ] ;
int g_iClientSprayLifetime [ MAXPLAYERS + 1 ] = { 2 , . . . } ;
2016-05-08 02:46:46 +02:00
int g_iSprayLifetime [ MAXPLAYERS + 1 ] ;
int g_iSprayBanTimestamp [ MAXPLAYERS + 1 ] ;
int g_iSprayUnbanTimestamp [ MAXPLAYERS + 1 ] = { - 1 , . . . } ;
int g_iSprayBanTarget [ MAXPLAYERS + 1 ] ;
int g_iSprayUnbanTarget [ MAXPLAYERS + 1 ] ;
int g_iSprayTraceTarget [ MAXPLAYERS + 1 ] ;
int g_iBanTarget [ MAXPLAYERS + 1 ] ;
2016-11-19 21:09:30 +01:00
int g_iDecalEntity [ MAXPLAYERS + 1 ] ;
2016-05-08 02:46:46 +02:00
2016-05-08 21:15:38 +02:00
float ACTUAL_NULL_VECTOR [ 3 ] ;
2016-05-08 02:46:46 +02:00
float g_fNextSprayTime [ MAXPLAYERS + 1 ] ;
float g_vecSprayOrigin [ MAXPLAYERS + 1 ] [ 3 ] ;
float g_SprayAABB [ MAXPLAYERS + 1 ] [ AABBTotalPoints ] ;
public Plugin myinfo =
{
2016-05-10 12:57:25 +02:00
name = " Spray Manager " ,
description = " A plugin to help manage player sprays. " ,
author = " Obus " ,
2017-01-29 08:44:35 +01:00
version = " 2.0.5 " ,
2016-05-10 12:57:25 +02:00
url = " https://github.com/CSSZombieEscape/sm-plugins/tree/master/SprayManager "
2016-05-08 02:46:46 +02:00
}
public APLRes AskPluginLoad2 ( Handle hThis , bool bLate , char [ ] err , int iErrLen )
{
g_bLoadedLate = bLate ;
return APLRes_Success ;
}
public void OnPluginStart ( )
{
LoadTranslations ( " common.phrases " ) ;
2016-05-08 21:15:38 +02:00
RegAdminCmd ( " sm_spray " , Command_AdminSpray , ADMFLAG_GENERIC , " Spray a clients spray " ) ;
2016-05-08 02:46:46 +02:00
RegAdminCmd ( " sm_sprayban " , Command_SprayBan , ADMFLAG_GENERIC , " Ban a client from spraying " ) ;
RegAdminCmd ( " sm_sprayunban " , Command_SprayUnban , ADMFLAG_GENERIC , " Unban a client and allow them to spray " ) ;
RegAdminCmd ( " sm_banspray " , Command_BanSpray , ADMFLAG_GENERIC , " Ban a clients spray from being sprayed (Note: This will not spray-ban the client, it will only ban the spray which they are currently using) " ) ;
RegAdminCmd ( " sm_unbanspray " , Command_UnbanSpray , ADMFLAG_GENERIC , " Unban a clients spray (Note: This will not spray-unban the client, it will only unban the spray which they are currently using) " ) ;
RegAdminCmd ( " sm_tracespray " , Command_TraceSpray , ADMFLAG_GENERIC , " Finds a spray under your crosshair " ) ;
RegAdminCmd ( " sm_spraytrace " , Command_TraceSpray , ADMFLAG_GENERIC , " Finds a spray under your crosshair " ) ;
RegAdminCmd ( " sm_removespray " , Command_RemoveSpray , ADMFLAG_GENERIC , " Finds and removes a spray under your crosshair " ) ;
RegAdminCmd ( " sm_spraymanagerupdatedb " , Command_SprayManager_UpdateInfo , ADMFLAG_CHEATS , " Updates all clients info " ) ;
RegAdminCmd ( " sm_spraymanagerrefreshdb " , Command_SprayManager_UpdateInfo , ADMFLAG_CHEATS , " Updates all clients info " ) ;
RegAdminCmd ( " sm_spraymanagerreloaddb " , Command_SprayManager_UpdateInfo , ADMFLAG_CHEATS , " Updates all clients info " ) ;
AddTempEntHook ( " Player Decal " , HookDecal ) ;
AddNormalSoundHook ( HookSprayer ) ;
TopMenu hTopMenu ;
2016-11-30 20:40:59 +01:00
if ( LibraryExists ( " adminmenu " ) & & ( ( hTopMenu = GetAdminTopMenu ( ) ) ! = null ) )
2016-05-08 02:46:46 +02:00
OnAdminMenuReady ( hTopMenu ) ;
2016-12-02 12:55:09 +01:00
g_cvarHookedDecalFrequency = FindConVar ( " decalfrequency " ) ;
g_iOldDecalFreqVal = g_cvarHookedDecalFrequency . IntValue ;
g_cvarHookedDecalFrequency . IntValue = 0 ;
2016-05-08 02:46:46 +02:00
2016-12-02 12:55:09 +01:00
g_cvarDecalFrequency = CreateConVar ( " sm_decalfrequency " , " 10.0 " , " Controls how often clients can spray " , FCVAR_NOTIFY ) ;
2016-05-08 02:46:46 +02:00
2016-12-02 12:55:09 +01:00
HookConVarChange ( g_cvarHookedDecalFrequency , ConVarChanged_DecalFrequency ) ;
2016-05-08 02:46:46 +02:00
2016-12-02 12:55:09 +01:00
g_cvarUseProximityCheck = CreateConVar ( " sm_spraymanager_blockoverspraying " , " 1 " , " Blocks people from overspraying each other " , FCVAR_NOTIFY ) ;
2016-05-08 02:46:46 +02:00
2016-12-02 12:55:09 +01:00
g_cvarSendSpraysToConnectingClients = CreateConVar ( " sm_spraymanager_sendspraystoconnectingclients " , " 1 " , " Try to send active sprays to connecting clients " ) ;
2016-05-08 02:46:46 +02:00
2016-12-02 12:55:09 +01:00
g_cvarUsePersistentSprays = CreateConVar ( " sm_spraymanager_persistentsprays " , " 1 " , " Re-spray sprays when their client-sided lifetime (in rounds) expires " ) ;
2016-05-08 02:46:46 +02:00
2016-12-02 12:55:09 +01:00
g_cvarMaxSprayLifetime = CreateConVar ( " sm_spraymanager_maxspraylifetime " , " 2 " , " If not using persistent sprays, remove sprays after their global lifetime (in rounds) exceeds this number " ) ;
2016-05-08 02:46:46 +02:00
2017-01-29 08:44:35 +01:00
AutoExecConfig ( true , " plugin.SprayManager " ) ;
2016-05-08 02:46:46 +02:00
2016-12-02 12:55:09 +01:00
g_hTraceTimer = CreateTimer ( 0.25 , Timer_PerformPlayerTraces , _ , TIMER_REPEAT ) ;
2016-05-08 02:46:46 +02:00
InitializeSQL ( ) ;
2016-12-02 12:55:09 +01:00
if ( g_bLoadedLate )
{
for ( int i = 1 ; i < = MaxClients ; i + + )
{
if ( ! IsClientInGame ( i ) | | IsFakeClient ( i ) )
continue ;
OnClientPutInServer ( i ) ;
}
}
2016-05-08 02:46:46 +02:00
}
public void OnPluginEnd ( )
{
2016-05-10 12:57:25 +02:00
for ( int i = 1 ; i < = MaxClients ; i + + )
{
if ( ! IsValidClient ( i ) | | IsFakeClient ( i ) )
continue ;
2016-12-02 12:55:09 +01:00
if ( IsVectorZero ( g_vecSprayOrigin [ i ] ) )
2016-05-10 12:57:25 +02:00
continue ;
2016-11-30 20:40:59 +01:00
g_iAllowSpray = i ;
2016-12-02 12:55:09 +01:00
SprayClientDecalToAll ( i , 0 , ACTUAL_NULL_VECTOR ) ;
2016-05-10 12:57:25 +02:00
}
2016-05-08 02:46:46 +02:00
RemoveTempEntHook ( " Player Decal " , HookDecal ) ;
RemoveNormalSoundHook ( HookSprayer ) ;
2017-01-29 08:44:35 +01:00
UnhookConVarChange ( g_cvarHookedDecalFrequency , ConVarChanged_DecalFrequency ) ;
2016-05-08 02:46:46 +02:00
if ( g_hDatabase ! = null )
{
SQL_UnlockDatabase ( g_hDatabase ) ;
delete g_hDatabase ;
}
if ( g_hTraceTimer ! = null )
2016-12-02 12:55:09 +01:00
delete g_hTraceTimer ;
if ( g_hRoundEndTimer ! = null )
delete g_hRoundEndTimer ;
g_cvarHookedDecalFrequency . IntValue = g_iOldDecalFreqVal ;
}
public void OnMapEnd ( )
{
if ( g_hRoundEndTimer ! = null )
delete g_hRoundEndTimer ;
}
public void OnClientPutInServer ( int client )
{
if ( QueryClientConVar ( client , " r_spray_lifetime " , CvarQueryFinished_SprayLifeTime ) = = QUERYCOOKIE_FAILED )
g_iClientSprayLifetime [ client ] = 2 ;
if ( g_cvarSendSpraysToConnectingClients . BoolValue )
{
for ( int i = 1 ; i < = MaxClients ; i + + )
{
if ( ! IsValidClient ( i ) | | IsFakeClient ( i ) )
continue ;
if ( IsVectorZero ( g_vecSprayOrigin [ i ] ) )
continue ;
g_bSkipDecalHook = true ;
SprayClientDecalToOne ( i , client , g_iDecalEntity [ i ] , g_vecSprayOrigin [ i ] ) ;
g_iClientToClientSprayLifetime [ client ] [ i ] = 0 ;
g_bSkipDecalHook = false ;
}
}
}
public void CvarQueryFinished_SprayLifeTime ( QueryCookie cookie , int client , ConVarQueryResult res , const char [ ] sCvarName , const char [ ] sCvarVal )
{
if ( res ! = ConVarQuery_Okay )
{
g_iClientSprayLifetime [ client ] = 2 ;
return ;
}
int iVal = StringToInt ( sCvarVal ) ;
iVal = iVal < = 0 ? 1 : iVal > 1000 ? 1000 : iVal ;
g_iClientSprayLifetime [ client ] = iVal ;
2016-05-08 02:46:46 +02:00
}
public void OnClientPostAdminCheck ( int client )
{
if ( g_hDatabase ! = null )
{
ClearPlayerInfo ( client ) ;
UpdatePlayerInfo ( client ) ;
UpdateSprayHashInfo ( client ) ;
}
}
public void OnClientDisconnect ( int client )
{
2016-12-02 12:55:09 +01:00
if ( IsValidClient ( client ) )
{
2017-01-29 08:44:35 +01:00
g_bSkipDecalHook = true ;
2016-12-02 12:55:09 +01:00
SprayClientDecalToAll ( client , 0 , ACTUAL_NULL_VECTOR ) ;
2017-01-29 08:44:35 +01:00
g_bSkipDecalHook = false ;
2016-12-02 12:55:09 +01:00
}
2016-05-08 02:46:46 +02:00
ClearPlayerInfo ( client ) ;
}
public Action CS_OnTerminateRound ( float & fDelay , CSRoundEndReason & reason )
{
2016-12-02 12:55:09 +01:00
if ( g_cvarUsePersistentSprays . BoolValue )
2016-05-08 02:46:46 +02:00
{
2016-12-02 12:55:09 +01:00
g_hRoundEndTimer = CreateTimer ( fDelay , Timer_ProcessPersistentSprays ) ;
2016-05-08 02:46:46 +02:00
2016-12-02 12:55:09 +01:00
return Plugin_Continue ;
2016-05-08 02:46:46 +02:00
}
2016-12-02 12:55:09 +01:00
g_hRoundEndTimer = CreateTimer ( fDelay , Timer_ResetOldSprays ) ;
return Plugin_Continue ;
2016-05-08 02:46:46 +02:00
}
public Action OnPlayerRunCmd ( int client , int & buttons , int & impulse )
{
if ( ! impulse | | impulse ! = 201 )
return Plugin_Continue ;
if ( CheckCommandAccess ( client , " sm_sprayban " , ADMFLAG_GENERIC ) )
{
if ( ! g_bSprayBanned [ client ] & & ! g_bSprayHashBanned [ client ] )
{
2016-08-16 22:03:59 +02:00
if ( IsPlayerAlive ( client ) )
if ( TracePlayerAnglesRanged ( client , 128.0 ) )
return Plugin_Continue ;
2016-05-08 02:46:46 +02:00
ForceSpray ( client , client , false ) ;
g_fNextSprayTime [ client ] = 0.0 ;
2016-12-02 13:49:24 +01:00
impulse = 0 ; //wow
return Plugin_Changed ;
2016-05-08 02:46:46 +02:00
}
}
2016-12-02 13:49:24 +01:00
return Plugin_Continue ;
2016-05-08 02:46:46 +02:00
}
public void OnAdminMenuReady ( Handle hAdminMenu )
{
if ( hAdminMenu = = g_hTopMenu )
return ;
g_hTopMenu = CloneHandle ( hAdminMenu ) ;
TopMenuObject hMenuObj = AddToTopMenu ( g_hTopMenu , " SprayManagerCommands " , TopMenuObject_Category , TopMenu_Main_Handler , INVALID_TOPMENUOBJECT ) ;
if ( hMenuObj = = INVALID_TOPMENUOBJECT )
return ;
2016-11-19 21:09:30 +01:00
AddToTopMenu ( g_hTopMenu , " SprayManager_Spraybanlist " , TopMenuObject_Item , Handler_SprayBanList , hMenuObj , " " , ADMFLAG_GENERIC ) ;
2016-05-08 02:46:46 +02:00
AddToTopMenu ( g_hTopMenu , " SprayManager_Tracespray " , TopMenuObject_Item , Handler_TraceSpray , hMenuObj , " sm_tracespray " , ADMFLAG_GENERIC ) ;
2016-05-09 00:31:27 +02:00
AddToTopMenu ( g_hTopMenu , " SprayManager_Spray " , TopMenuObject_Item , Handler_Spray , hMenuObj , " sm_spray " , ADMFLAG_GENERIC ) ;
2016-05-08 02:46:46 +02:00
AddToTopMenu ( g_hTopMenu , " SprayManager_Sprayban " , TopMenuObject_Item , Handler_SprayBan , hMenuObj , " sm_sprayban " , ADMFLAG_GENERIC ) ;
AddToTopMenu ( g_hTopMenu , " SprayManager_Banspray " , TopMenuObject_Item , Handler_BanSpray , hMenuObj , " sm_banspray " , ADMFLAG_GENERIC ) ;
2016-11-19 21:09:30 +01:00
AddToTopMenu ( g_hTopMenu , " SprayManager_Unban " , TopMenuObject_Item , Handler_UnbanSpray , hMenuObj , " sm_unbanspray " , ADMFLAG_GENERIC ) ;
2016-05-08 02:46:46 +02:00
}
public void OnLibraryRemoved ( const char [ ] sLibraryName )
{
2016-12-02 12:55:09 +01:00
if ( strcmp ( sLibraryName , " adminmenu " ) = = 0 )
2016-05-08 02:46:46 +02:00
delete g_hTopMenu ;
}
public void TopMenu_Main_Handler ( Handle hMenu , TopMenuAction hAction , TopMenuObject hObjID , int iParam1 , char [ ] sBuffer , int iBufflen )
{
if ( hAction = = TopMenuAction_DisplayOption )
Format ( sBuffer , iBufflen , " %s " , " SprayManager Commands " , iParam1 ) ;
else if ( hAction = = TopMenuAction_DisplayTitle )
Format ( sBuffer , iBufflen , " %s " , " SprayManager Commands: " , iParam1 ) ;
}
public void Handler_SprayBanList ( Handle hMenu , TopMenuAction hAction , TopMenuObject hObjID , int iParam1 , char [ ] sBuffer , int iBufflen )
{
if ( hAction = = TopMenuAction_DisplayOption )
Format ( sBuffer , iBufflen , " %s " , " List Spray Banned Clients " , iParam1 ) ;
else if ( hAction = = TopMenuAction_SelectOption )
Menu_ListBans ( iParam1 ) ;
}
public void Handler_TraceSpray ( Handle hMenu , TopMenuAction hAction , TopMenuObject hObjID , int iParam1 , char [ ] sBuffer , int iBufflen )
{
if ( hAction = = TopMenuAction_DisplayOption )
2016-05-09 00:31:27 +02:00
{
2016-05-08 02:46:46 +02:00
Format ( sBuffer , iBufflen , " %s " , " Trace a Spray " , iParam1 ) ;
2016-05-09 00:31:27 +02:00
}
2016-05-08 02:46:46 +02:00
else if ( hAction = = TopMenuAction_SelectOption )
{
float vecEndPos [ 3 ] ;
if ( TracePlayerAngles ( iParam1 , vecEndPos ) )
{
for ( int i = 1 ; i < = MaxClients ; i + + )
{
if ( IsPointInsideAABB ( vecEndPos , g_SprayAABB [ i ] ) )
{
g_bInvokedThroughTopMenu [ iParam1 ] = true ;
Menu_Trace ( iParam1 , i ) ;
return ;
}
}
}
PrintToChat ( iParam1 , " \x01 \x04 [SprayManager] \x01 Trace did not hit any sprays. " ) ;
2016-11-30 20:40:59 +01:00
if ( g_hTopMenu ! = null )
2016-05-08 02:46:46 +02:00
DisplayTopMenu ( g_hTopMenu , iParam1 , TopMenuPosition_LastCategory ) ;
}
}
2016-05-09 00:31:27 +02:00
public void Handler_Spray ( Handle hMenu , TopMenuAction hAction , TopMenuObject hObjID , int iParam1 , char [ ] sBuffer , int iBufflen )
{
if ( hAction = = TopMenuAction_DisplayOption )
Format ( sBuffer , iBufflen , " %s " , " Spray a Client's Spray " , iParam1 ) ;
else if ( hAction = = TopMenuAction_SelectOption )
Menu_Spray ( iParam1 ) ;
}
2016-05-08 02:46:46 +02:00
public void Handler_SprayBan ( Handle hMenu , TopMenuAction hAction , TopMenuObject hObjID , int iParam1 , char [ ] sBuffer , int iBufflen )
{
if ( hAction = = TopMenuAction_DisplayOption )
Format ( sBuffer , iBufflen , " %s " , " Spray Ban a Client " , iParam1 ) ;
else if ( hAction = = TopMenuAction_SelectOption )
Menu_SprayBan ( iParam1 ) ;
}
public void Handler_BanSpray ( Handle hMenu , TopMenuAction hAction , TopMenuObject hObjID , int iParam1 , char [ ] sBuffer , int iBufflen )
{
if ( hAction = = TopMenuAction_DisplayOption )
Format ( sBuffer , iBufflen , " %s " , " Ban a Client's Spray " , iParam1 ) ;
else if ( hAction = = TopMenuAction_SelectOption )
Menu_BanSpray ( iParam1 ) ;
}
public void Handler_UnbanSpray ( Handle hMenu , TopMenuAction hAction , TopMenuObject hObjID , int iParam1 , char [ ] sBuffer , int iBufflen )
{
if ( hAction = = TopMenuAction_DisplayOption )
2016-11-19 21:09:30 +01:00
Format ( sBuffer , iBufflen , " %s " , " Unban a Client " , iParam1 ) ;
2016-05-08 02:46:46 +02:00
else if ( hAction = = TopMenuAction_SelectOption )
2016-11-19 21:09:30 +01:00
Menu_Unban ( iParam1 ) ;
2016-05-08 02:46:46 +02:00
}
void Menu_ListBans ( int client )
{
if ( ! IsValidClient ( client ) )
return ;
int iBannedClients ;
Menu ListMenu = new Menu ( MenuHandler_Menu_ListBans ) ;
ListMenu . SetTitle ( " [SprayManager] Banned Clients: " ) ;
ListMenu . ExitBackButton = true ;
for ( int i = 1 ; i < = MaxClients ; i + + )
{
2016-11-19 21:09:30 +01:00
if ( ! IsValidClient ( i ) | | IsFakeClient ( i ) )
2016-05-08 02:46:46 +02:00
continue ;
if ( g_bSprayBanned [ i ] | | g_bSprayHashBanned [ i ] )
{
char sUserID [ 16 ] ;
char sBuff [ 64 ] ;
int iUserID = GetClientUserId ( i ) ;
2016-11-19 21:09:30 +01:00
Format ( sBuff , sizeof ( sBuff ) , " %N (#%d) " , i , iUserID ) ;
2016-05-08 02:46:46 +02:00
Format ( sUserID , sizeof ( sUserID ) , " %d " , iUserID ) ;
ListMenu . AddItem ( sUserID , sBuff ) ;
iBannedClients + + ;
}
}
if ( ! iBannedClients )
ListMenu . AddItem ( " " , " No Banned Clients. " , ITEMDRAW_DISABLED ) ;
ListMenu . Display ( client , MENU_TIME_FOREVER ) ;
}
int MenuHandler_Menu_ListBans ( Menu hMenu , MenuAction action , int iParam1 , int iParam2 )
{
switch ( action )
{
case MenuAction_End :
2016-11-19 21:09:30 +01:00
delete hMenu ;
2016-05-08 02:46:46 +02:00
case MenuAction_Cancel :
{
2016-11-30 20:40:59 +01:00
if ( iParam2 = = MenuCancel_ExitBack & & g_hTopMenu ! = null )
2016-05-08 02:46:46 +02:00
DisplayTopMenu ( g_hTopMenu , iParam1 , TopMenuPosition_LastCategory ) ;
}
case MenuAction_Select :
{
char sOption [ 32 ] ;
hMenu . GetItem ( iParam2 , sOption , sizeof ( sOption ) ) ;
int target = GetClientOfUserId ( StringToInt ( sOption ) ) ;
if ( ! IsValidClient ( target ) )
{
PrintToChat ( iParam1 , " \x01 \x04 [SprayManager] \x01 Target no longer available. " ) ;
2016-11-30 20:40:59 +01:00
if ( g_hTopMenu ! = null )
2016-05-08 02:46:46 +02:00
DisplayTopMenu ( g_hTopMenu , iParam1 , TopMenuPosition_LastCategory ) ;
else
2016-11-19 21:09:30 +01:00
delete hMenu ;
2016-05-08 02:46:46 +02:00
}
else
{
g_bInvokedThroughListMenu [ iParam1 ] = true ;
Menu_ListBans_Target ( iParam1 , target ) ;
}
}
}
}
void Menu_Trace ( int client , int target )
{
char sSteamID [ 32 ] ;
GetClientAuthId ( target , AuthId_Steam2 , sSteamID , sizeof ( sSteamID ) ) ;
Menu TraceMenu = new Menu ( MenuHandler_Menu_Trace ) ;
TraceMenu . SetTitle ( " Sprayed by: %N (%s) " , target , sSteamID ) ;
if ( g_bInvokedThroughTopMenu [ client ] )
TraceMenu . ExitBackButton = true ;
TraceMenu . AddItem ( " 1 " , " Warn Client " ) ;
TraceMenu . AddItem ( " 2 " , " Slap and Warn Client " ) ;
TraceMenu . AddItem ( " 3 " , " Kick Client " ) ;
TraceMenu . AddItem ( " 4 " , " Spray Ban Client " ) ;
TraceMenu . AddItem ( " 5 " , " Ban Clients Spray " ) ;
TraceMenu . AddItem ( " " , " " , ITEMDRAW_SPACER ) ;
TraceMenu . AddItem ( " 6 " , " Ban Client " ) ;
g_iSprayTraceTarget [ client ] = target ;
TraceMenu . Display ( client , MENU_TIME_FOREVER ) ;
}
int MenuHandler_Menu_Trace ( Menu hMenu , MenuAction action , int iParam1 , int iParam2 )
{
switch ( action )
{
case MenuAction_End :
2016-11-19 21:09:30 +01:00
delete hMenu ;
2016-05-08 02:46:46 +02:00
case MenuAction_Cancel :
{
2016-11-30 20:40:59 +01:00
if ( iParam2 = = MenuCancel_ExitBack & & g_hTopMenu ! = null )
2016-05-08 02:46:46 +02:00
DisplayTopMenu ( g_hTopMenu , iParam1 , TopMenuPosition_LastCategory ) ;
}
case MenuAction_Select :
{
char sOption [ 2 ] ;
hMenu . GetItem ( iParam2 , sOption , sizeof ( sOption ) ) ;
int target = g_iSprayTraceTarget [ iParam1 ] ;
if ( ! IsValidClient ( target ) )
{
PrintToChat ( iParam1 , " \x01 \x04 [SprayManager] \x01 Target no longer available. " ) ;
g_bInvokedThroughTopMenu [ iParam1 ] = false ;
2016-11-30 20:40:59 +01:00
if ( g_hTopMenu ! = null )
2016-05-08 02:46:46 +02:00
DisplayTopMenu ( g_hTopMenu , iParam1 , TopMenuPosition_LastCategory ) ;
else
2016-11-19 21:09:30 +01:00
delete hMenu ;
2016-05-08 02:46:46 +02:00
}
else
{
switch ( StringToInt ( sOption ) )
{
case 1 :
{
PrintToChat ( target , " \x01 \x04 [SprayManager] \x01 Your spray is not allowed, change it. " ) ;
Menu_Trace ( iParam1 , target ) ;
}
case 2 :
{
SlapPlayer ( target , 0 ) ;
PrintToChat ( target , " \x01 \x04 [SprayManager] \x01 Your spray is not allowed, change it. " ) ;
Menu_Trace ( iParam1 , target ) ;
}
case 3 :
{
g_bInvokedThroughTopMenu [ iParam1 ] = false ;
KickClient ( target , " Your spray is not allowed, change it " ) ;
}
case 4 :
{
Menu TraceSpraySprayBan = new Menu ( MenuHandler_Menu_Trace_SprayBan ) ;
2016-11-19 21:09:30 +01:00
TraceSpraySprayBan . SetTitle ( " [SprayManager] Select a Spray Ban Length for %N (#%d) " , target , GetClientUserId ( target ) ) ;
2016-05-08 02:46:46 +02:00
TraceSpraySprayBan . ExitBackButton = true ;
TraceSpraySprayBan . AddItem ( " 10 " , " 10 Minutes " ) ;
TraceSpraySprayBan . AddItem ( " 30 " , " 30 Minutes " ) ;
TraceSpraySprayBan . AddItem ( " 60 " , " 1 Hour " ) ;
TraceSpraySprayBan . AddItem ( " 1440 " , " 1 Day " ) ;
TraceSpraySprayBan . AddItem ( " 10080 " , " 1 Week " ) ;
TraceSpraySprayBan . AddItem ( " 40320 " , " 1 Month " ) ;
TraceSpraySprayBan . AddItem ( " 0 " , " Permanent " ) ;
g_iSprayBanTarget [ iParam1 ] = target ;
TraceSpraySprayBan . Display ( iParam1 , MENU_TIME_FOREVER ) ;
}
case 5 :
{
2017-01-29 08:44:35 +01:00
if ( BanClientSpray ( iParam1 , target ) )
2016-11-19 21:09:30 +01:00
{
ShowActivity2 ( iParam1 , " \x01 \x04 [SprayManager] " , " \x01Ba nned \x04 %N \x01 's spray " , target ) ;
LogAction ( iParam1 , target , " \" %L \" banned \" %L \" 's spray " , iParam1 , target ) ;
}
2016-05-08 02:46:46 +02:00
}
case 6 :
{
Menu TraceSprayBan = new Menu ( MenuHandler_Menu_Trace_Ban ) ;
2016-11-19 21:09:30 +01:00
TraceSprayBan . SetTitle ( " [SprayManager] Select a Ban Length for %N (#%d) " , target , GetClientUserId ( target ) ) ;
2016-05-08 02:46:46 +02:00
TraceSprayBan . ExitBackButton = true ;
TraceSprayBan . AddItem ( " 10 " , " 10 Minutes " ) ;
TraceSprayBan . AddItem ( " 30 " , " 30 Minutes " ) ;
TraceSprayBan . AddItem ( " 60 " , " 1 Hour " ) ;
TraceSprayBan . AddItem ( " 1440 " , " 1 Day " ) ;
TraceSprayBan . AddItem ( " 10080 " , " 1 Week " ) ;
TraceSprayBan . AddItem ( " 40320 " , " 1 Month " ) ;
TraceSprayBan . AddItem ( " 0 " , " Permanent " ) ;
g_iBanTarget [ iParam1 ] = target ;
TraceSprayBan . Display ( iParam1 , MENU_TIME_FOREVER ) ;
}
}
}
}
}
}
int MenuHandler_Menu_Trace_SprayBan ( Menu hMenu , MenuAction action , int iParam1 , int iParam2 )
{
switch ( action )
{
case MenuAction_End :
2016-11-19 21:09:30 +01:00
delete hMenu ;
2016-05-08 02:46:46 +02:00
case MenuAction_Cancel :
{
if ( iParam2 = = MenuCancel_ExitBack )
{
if ( IsValidClient ( g_iSprayBanTarget [ iParam1 ] ) )
2016-05-09 00:31:27 +02:00
{
2016-05-08 02:46:46 +02:00
Menu_Trace ( iParam1 , g_iSprayBanTarget [ iParam1 ] ) ;
2016-05-09 00:31:27 +02:00
}
2016-11-30 20:40:59 +01:00
else if ( g_hTopMenu ! = null )
2016-05-08 02:46:46 +02:00
{
g_bInvokedThroughTopMenu [ iParam1 ] = false ;
DisplayTopMenu ( g_hTopMenu , iParam1 , TopMenuPosition_LastCategory ) ;
}
else
{
g_bInvokedThroughTopMenu [ iParam1 ] = false ;
2016-11-19 21:09:30 +01:00
delete hMenu ;
2016-05-08 02:46:46 +02:00
}
}
}
case MenuAction_Select :
{
char sOption [ 8 ] ;
hMenu . GetItem ( iParam2 , sOption , sizeof ( sOption ) ) ;
int target = g_iSprayBanTarget [ iParam1 ] ;
if ( ! IsValidClient ( target ) )
{
PrintToChat ( iParam1 , " \x01 \x04 [SprayManager] \x01 Target no longer available. " ) ;
g_iSprayBanTarget [ iParam1 ] = 0 ;
g_bInvokedThroughTopMenu [ iParam1 ] = false ;
2016-11-30 20:40:59 +01:00
if ( g_hTopMenu ! = null )
2016-05-08 02:46:46 +02:00
DisplayTopMenu ( g_hTopMenu , iParam1 , TopMenuPosition_LastCategory ) ;
else
2016-11-19 21:09:30 +01:00
delete hMenu ;
2016-05-08 02:46:46 +02:00
}
else
{
if ( SprayBanClient ( iParam1 , target , StringToInt ( sOption ) , " Inappropriate Spray " ) )
2016-11-19 21:09:30 +01:00
{
ShowActivity2 ( iParam1 , " \x01 \x04 [SprayManager] " , " \x01 Spray banned \x04 %N " , target ) ;
2017-01-29 08:44:35 +01:00
LogAction ( iParam1 , target , " \" %L \" spray banned \" %L \" (Hash: \" %s \" ) " , iParam1 , target , g_sSprayHash [ target ] ) ;
2016-11-19 21:09:30 +01:00
}
2016-05-08 02:46:46 +02:00
g_iSprayBanTarget [ iParam1 ] = 0 ;
g_bInvokedThroughTopMenu [ iParam1 ] = false ;
}
}
}
}
int MenuHandler_Menu_Trace_Ban ( Menu hMenu , MenuAction action , int iParam1 , int iParam2 )
{
switch ( action )
{
case MenuAction_End :
2016-11-19 21:09:30 +01:00
delete hMenu ;
2016-05-08 02:46:46 +02:00
case MenuAction_Cancel :
{
if ( iParam2 = = MenuCancel_ExitBack )
{
if ( IsValidClient ( g_iBanTarget [ iParam1 ] ) )
2016-05-09 00:31:27 +02:00
{
2016-05-08 02:46:46 +02:00
Menu_Trace ( iParam1 , g_iBanTarget [ iParam1 ] ) ;
2016-05-09 00:31:27 +02:00
}
2016-11-30 20:40:59 +01:00
else if ( g_hTopMenu ! = null )
2016-05-08 02:46:46 +02:00
{
g_bInvokedThroughTopMenu [ iParam1 ] = false ;
DisplayTopMenu ( g_hTopMenu , iParam1 , TopMenuPosition_LastCategory ) ;
}
else
{
g_bInvokedThroughTopMenu [ iParam1 ] = false ;
2016-11-19 21:09:30 +01:00
delete hMenu ;
2016-05-08 02:46:46 +02:00
}
}
}
case MenuAction_Select :
{
char sOption [ 8 ] ;
hMenu . GetItem ( iParam2 , sOption , sizeof ( sOption ) ) ;
int target = g_iBanTarget [ iParam1 ] ;
if ( ! IsValidClient ( target ) )
{
PrintToChat ( iParam1 , " \x01 \x04 [SprayManager] \x01 Target no longer available. " ) ;
g_iBanTarget [ iParam1 ] = 0 ;
g_bInvokedThroughTopMenu [ iParam1 ] = false ;
2016-11-30 20:40:59 +01:00
if ( g_hTopMenu ! = null )
2016-05-08 02:46:46 +02:00
DisplayTopMenu ( g_hTopMenu , iParam1 , TopMenuPosition_LastCategory ) ;
else
2016-11-19 21:09:30 +01:00
delete hMenu ;
2016-05-08 02:46:46 +02:00
}
else
{
2016-11-19 21:09:30 +01:00
FakeClientCommandEx ( iParam1 , " sm_ban \" #%d \" \" %s \" \" Inappropriate spray \" " , GetClientUserId ( g_iBanTarget [ iParam1 ] ) , sOption ) ;
2016-05-08 02:46:46 +02:00
g_iBanTarget [ iParam1 ] = 0 ;
g_bInvokedThroughTopMenu [ iParam1 ] = false ;
}
}
}
}
2016-05-09 00:31:27 +02:00
void Menu_Spray ( int client )
{
if ( ! IsValidClient ( client ) )
return ;
Menu SprayMenu = new Menu ( MenuHandler_Menu_Spray ) ;
SprayMenu . SetTitle ( " [SprayManager] Select a Client to Force Spray: " ) ;
SprayMenu . ExitBackButton = true ;
for ( int i = 1 ; i < = MaxClients ; i + + )
{
2016-05-10 12:57:25 +02:00
if ( ! IsValidClient ( i ) | | IsFakeClient ( i ) )
2016-05-09 00:31:27 +02:00
continue ;
char sUserID [ 16 ] ;
char sBuff [ 64 ] ;
int iUserID = GetClientUserId ( i ) ;
Format ( sUserID , sizeof ( sUserID ) , " %d " , iUserID ) ;
if ( g_bSprayBanned [ i ] & & g_bSprayHashBanned [ i ] )
{
2016-11-19 21:09:30 +01:00
Format ( sBuff , sizeof ( sBuff ) , " %N (#%d) [Spray & Hash Banned] " , i , iUserID ) ;
2016-05-09 00:31:27 +02:00
SprayMenu . AddItem ( sUserID , sBuff ) ;
}
else if ( g_bSprayBanned [ i ] )
{
2016-11-19 21:09:30 +01:00
Format ( sBuff , sizeof ( sBuff ) , " %N (#%d) [Spray Banned] " , i , iUserID ) ;
2016-05-09 00:31:27 +02:00
SprayMenu . AddItem ( sUserID , sBuff ) ;
}
else if ( g_bSprayHashBanned [ i ] )
{
2016-11-19 21:09:30 +01:00
Format ( sBuff , sizeof ( sBuff ) , " %N (#%d) [Hash Banned] " , i , iUserID ) ;
2016-05-09 00:31:27 +02:00
SprayMenu . AddItem ( sUserID , sBuff ) ;
}
else
{
2016-11-19 21:09:30 +01:00
Format ( sBuff , sizeof ( sBuff ) , " %N (#%d) " , i , iUserID ) ;
2016-05-09 00:31:27 +02:00
SprayMenu . AddItem ( sUserID , sBuff ) ;
}
}
SprayMenu . Display ( client , MENU_TIME_FOREVER ) ;
}
int MenuHandler_Menu_Spray ( Menu hMenu , MenuAction action , int iParam1 , int iParam2 )
{
switch ( action )
{
case MenuAction_End :
2016-11-19 21:09:30 +01:00
delete hMenu ;
2016-05-09 00:31:27 +02:00
case MenuAction_Cancel :
{
2016-11-30 20:40:59 +01:00
if ( iParam2 = = MenuCancel_ExitBack & & g_hTopMenu ! = null )
2016-05-09 00:31:27 +02:00
DisplayTopMenu ( g_hTopMenu , iParam1 , TopMenuPosition_LastCategory ) ;
}
case MenuAction_Select :
{
char sOption [ 8 ] ;
hMenu . GetItem ( iParam2 , sOption , sizeof ( sOption ) ) ;
int target = GetClientOfUserId ( StringToInt ( sOption ) ) ;
if ( ! IsValidClient ( target ) )
{
PrintToChat ( iParam1 , " \x01 \x04 [SprayManager] \x01 Target no longer available. " ) ;
2016-11-30 20:40:59 +01:00
if ( g_hTopMenu ! = null )
2016-05-09 00:31:27 +02:00
DisplayTopMenu ( g_hTopMenu , iParam1 , TopMenuPosition_LastCategory ) ;
else
2016-11-19 21:09:30 +01:00
delete hMenu ;
2016-05-09 00:31:27 +02:00
}
else
{
2016-11-30 20:40:59 +01:00
g_iAllowSpray = target ;
2016-05-09 00:31:27 +02:00
ForceSpray ( iParam1 , target ) ;
PrintToChat ( iParam1 , " \x01 \x04 [SprayManager] \x01 Sprayed \x04 %N \x01 's spray(s). " , target ) ;
Menu_Spray ( iParam1 ) ;
}
}
}
}
2016-05-08 02:46:46 +02:00
void Menu_SprayBan ( int client )
{
if ( ! IsValidClient ( client ) )
return ;
2016-11-19 21:09:30 +01:00
int iClientsToDisplay ;
2016-05-08 02:46:46 +02:00
Menu SprayBanMenu = new Menu ( MenuHandler_Menu_SprayBan ) ;
SprayBanMenu . SetTitle ( " [SprayManager] Select a Client to Spray Ban: " ) ;
SprayBanMenu . ExitBackButton = true ;
for ( int i = 1 ; i < = MaxClients ; i + + )
{
2016-11-19 21:09:30 +01:00
if ( ! IsValidClient ( i ) | | IsFakeClient ( i ) )
continue ;
2016-05-08 02:46:46 +02:00
2016-11-19 21:09:30 +01:00
if ( g_bSprayBanned [ i ] )
continue ;
2016-05-08 02:46:46 +02:00
2016-11-19 21:09:30 +01:00
char sUserID [ 16 ] ;
char sBuff [ 64 ] ;
int iUserID = GetClientUserId ( i ) ;
Format ( sBuff , sizeof ( sBuff ) , " %N (#%d) " , i , iUserID ) ;
Format ( sUserID , sizeof ( sUserID ) , " %d " , iUserID ) ;
SprayBanMenu . AddItem ( sUserID , sBuff ) ;
iClientsToDisplay + + ;
2016-05-08 02:46:46 +02:00
}
if ( ! iClientsToDisplay )
2016-11-19 21:09:30 +01:00
SprayBanMenu . AddItem ( " " , " No eligible Clients found. " , ITEMDRAW_DISABLED ) ;
2016-05-08 02:46:46 +02:00
SprayBanMenu . Display ( client , MENU_TIME_FOREVER ) ;
}
int MenuHandler_Menu_SprayBan ( Menu hMenu , MenuAction action , int iParam1 , int iParam2 )
{
switch ( action )
{
case MenuAction_End :
2016-11-19 21:09:30 +01:00
delete hMenu ;
2016-05-08 02:46:46 +02:00
case MenuAction_Cancel :
{
2016-11-30 20:40:59 +01:00
if ( iParam2 = = MenuCancel_ExitBack & & g_hTopMenu ! = null )
2016-05-08 02:46:46 +02:00
DisplayTopMenu ( g_hTopMenu , iParam1 , TopMenuPosition_LastCategory ) ;
}
case MenuAction_Select :
{
char sOption [ 32 ] ;
hMenu . GetItem ( iParam2 , sOption , sizeof ( sOption ) ) ;
int target = GetClientOfUserId ( StringToInt ( sOption ) ) ;
if ( ! IsValidClient ( target ) )
{
PrintToChat ( iParam1 , " \x01 \x04 [SprayManager] \x01 Target no longer available. " ) ;
2016-11-30 20:40:59 +01:00
if ( g_hTopMenu ! = null )
2016-05-08 02:46:46 +02:00
DisplayTopMenu ( g_hTopMenu , iParam1 , TopMenuPosition_LastCategory ) ;
else
2016-11-19 21:09:30 +01:00
delete hMenu ;
2016-05-08 02:46:46 +02:00
}
else
{
Menu SprayBanLengthMenu = new Menu ( MenuHandler_Menu_SprayBan_Length ) ;
2016-11-19 21:09:30 +01:00
SprayBanLengthMenu . SetTitle ( " [SprayManager] Choose a Spray Ban Length for %N (#%d) " , target , GetClientUserId ( target ) ) ;
2016-05-08 02:46:46 +02:00
SprayBanLengthMenu . ExitBackButton = true ;
SprayBanLengthMenu . AddItem ( " 10 " , " 10 Minutes " ) ;
SprayBanLengthMenu . AddItem ( " 30 " , " 30 Minutes " ) ;
SprayBanLengthMenu . AddItem ( " 60 " , " 1 Hour " ) ;
SprayBanLengthMenu . AddItem ( " 1440 " , " 1 Day " ) ;
SprayBanLengthMenu . AddItem ( " 10080 " , " 1 Week " ) ;
SprayBanLengthMenu . AddItem ( " 40320 " , " 1 Month " ) ;
SprayBanLengthMenu . AddItem ( " 0 " , " Permanent " ) ;
g_iSprayBanTarget [ iParam1 ] = target ;
SprayBanLengthMenu . Display ( iParam1 , MENU_TIME_FOREVER ) ;
}
}
}
}
int MenuHandler_Menu_SprayBan_Length ( Menu hMenu , MenuAction action , int iParam1 , int iParam2 )
{
switch ( action )
{
case MenuAction_End :
2016-11-19 21:09:30 +01:00
delete hMenu ;
2016-05-08 02:46:46 +02:00
case MenuAction_Cancel :
{
if ( iParam2 = = MenuCancel_ExitBack )
Menu_SprayBan ( iParam1 ) ;
}
case MenuAction_Select :
{
char sOption [ 8 ] ;
hMenu . GetItem ( iParam2 , sOption , sizeof ( sOption ) ) ;
int target = g_iSprayBanTarget [ iParam1 ] ;
if ( ! IsValidClient ( target ) )
{
PrintToChat ( iParam1 , " \x01 \x04 [SprayManager] \x01 Target no longer available. " ) ;
g_iSprayBanTarget [ iParam1 ] = 0 ;
Menu_SprayBan ( iParam1 ) ;
}
else
{
if ( SprayBanClient ( iParam1 , target , StringToInt ( sOption ) , " Inappropriate Spray " ) )
2016-11-19 21:09:30 +01:00
{
ShowActivity2 ( iParam1 , " \x01 \x04 [SprayManager] " , " \x01 Spray banned \x04 %N " , target ) ;
2017-01-29 08:44:35 +01:00
LogAction ( iParam1 , target , " \" %L \" spray banned \" %L \" (Hash: \" %s \" ) " , iParam1 , target , g_sSprayHash [ target ] ) ;
2016-11-19 21:09:30 +01:00
}
2016-05-08 02:46:46 +02:00
g_iSprayBanTarget [ iParam1 ] = 0 ;
}
}
}
}
void Menu_BanSpray ( int client )
{
if ( ! IsValidClient ( client ) )
return ;
int iClientsToDisplay ;
Menu BanSprayMenu = new Menu ( MenuHandler_Menu_BanSpray ) ;
BanSprayMenu . SetTitle ( " [SprayManager] Select a Client to Ban their Spray: " ) ;
BanSprayMenu . ExitBackButton = true ;
for ( int i = 1 ; i < = MaxClients ; i + + )
{
2016-11-19 21:09:30 +01:00
if ( ! IsValidClient ( i ) | | IsFakeClient ( i ) )
continue ;
2016-05-08 02:46:46 +02:00
2016-11-19 21:09:30 +01:00
if ( g_bSprayHashBanned [ i ] )
continue ;
2016-05-08 02:46:46 +02:00
2016-11-19 21:09:30 +01:00
char sUserID [ 16 ] ;
char sBuff [ 64 ] ;
int iUserID = GetClientUserId ( i ) ;
Format ( sBuff , sizeof ( sBuff ) , " %N (#%d) " , i , iUserID ) ;
Format ( sUserID , sizeof ( sUserID ) , " %d " , iUserID ) ;
BanSprayMenu . AddItem ( sUserID , sBuff ) ;
iClientsToDisplay + + ;
2016-05-08 02:46:46 +02:00
}
if ( ! iClientsToDisplay )
2016-11-19 21:09:30 +01:00
BanSprayMenu . AddItem ( " " , " No eligible Clients found. " , ITEMDRAW_DISABLED ) ;
2016-05-08 02:46:46 +02:00
BanSprayMenu . Display ( client , MENU_TIME_FOREVER ) ;
}
int MenuHandler_Menu_BanSpray ( Menu hMenu , MenuAction action , int iParam1 , int iParam2 )
{
switch ( action )
{
case MenuAction_End :
2016-11-19 21:09:30 +01:00
delete hMenu ;
2016-05-08 02:46:46 +02:00
case MenuAction_Cancel :
{
2016-11-30 20:40:59 +01:00
if ( iParam2 = = MenuCancel_ExitBack & & g_hTopMenu ! = null )
2016-05-08 02:46:46 +02:00
DisplayTopMenu ( g_hTopMenu , iParam1 , TopMenuPosition_LastCategory ) ;
}
case MenuAction_Select :
{
char sOption [ 32 ] ;
hMenu . GetItem ( iParam2 , sOption , sizeof ( sOption ) ) ;
int target = GetClientOfUserId ( StringToInt ( sOption ) ) ;
if ( ! IsValidClient ( target ) )
{
PrintToChat ( iParam1 , " \x01 \x04 [SprayManager] \x01 Target no longer available. " ) ;
Menu_BanSpray ( iParam1 ) ;
}
else
{
2017-01-29 08:44:35 +01:00
if ( BanClientSpray ( iParam1 , target ) )
2016-11-19 21:09:30 +01:00
{
ShowActivity2 ( iParam1 , " \x01 \x04 [SprayManager] " , " \x01Ba nned \x04 %N \x01 's spray " , target ) ;
LogAction ( iParam1 , target , " \" %L \" banned \" %L \" 's spray " , iParam1 , target ) ;
}
2016-05-08 02:46:46 +02:00
}
}
}
}
2016-11-19 21:09:30 +01:00
void Menu_Unban ( int client )
2016-05-08 02:46:46 +02:00
{
if ( ! IsValidClient ( client ) )
return ;
2016-11-19 21:09:30 +01:00
int iBannedClients ;
2016-05-08 02:46:46 +02:00
Menu UnbanSprayMenu = new Menu ( MenuHandler_Menu_UnbanSpray ) ;
2016-11-19 21:09:30 +01:00
UnbanSprayMenu . SetTitle ( " [SprayManager] Select a Client for more information: " ) ;
2016-05-08 02:46:46 +02:00
UnbanSprayMenu . ExitBackButton = true ;
for ( int i = 1 ; i < = MaxClients ; i + + )
{
2016-11-19 21:09:30 +01:00
if ( ! IsValidClient ( i ) | | IsFakeClient ( i ) )
continue ;
2016-05-08 02:46:46 +02:00
2016-11-19 21:09:30 +01:00
if ( ! g_bSprayHashBanned [ i ] & & ! g_bSprayBanned [ i ] )
continue ;
2016-05-08 02:46:46 +02:00
2016-11-19 21:09:30 +01:00
char sUserID [ 16 ] ;
char sBuff [ 64 ] ;
int iUserID = GetClientUserId ( i ) ;
Format ( sBuff , sizeof ( sBuff ) , " %N (#%d) " , i , iUserID ) ;
Format ( sUserID , sizeof ( sUserID ) , " %d " , iUserID ) ;
UnbanSprayMenu . AddItem ( sUserID , sBuff ) ;
iBannedClients + + ;
2016-05-08 02:46:46 +02:00
}
if ( ! iBannedClients )
UnbanSprayMenu . AddItem ( " " , " No Banned Clients. " , ITEMDRAW_DISABLED ) ;
UnbanSprayMenu . Display ( client , MENU_TIME_FOREVER ) ;
}
int MenuHandler_Menu_UnbanSpray ( Menu hMenu , MenuAction action , int iParam1 , int iParam2 )
{
switch ( action )
{
case MenuAction_End :
2016-11-19 21:09:30 +01:00
delete hMenu ;
2016-05-08 02:46:46 +02:00
case MenuAction_Cancel :
{
2016-11-30 20:40:59 +01:00
if ( iParam2 = = MenuCancel_ExitBack & & g_hTopMenu ! = null )
2016-05-08 02:46:46 +02:00
DisplayTopMenu ( g_hTopMenu , iParam1 , TopMenuPosition_LastCategory ) ;
}
case MenuAction_Select :
{
char sOption [ 32 ] ;
hMenu . GetItem ( iParam2 , sOption , sizeof ( sOption ) ) ;
int target = GetClientOfUserId ( StringToInt ( sOption ) ) ;
if ( ! IsValidClient ( target ) )
{
PrintToChat ( iParam1 , " \x01 \x04 [SprayManager] \x01 Target no longer available. " ) ;
2016-11-19 21:09:30 +01:00
Menu_Unban ( iParam1 ) ;
2016-05-08 02:46:46 +02:00
}
else
{
2016-11-19 21:09:30 +01:00
g_bInvokedThroughListMenu [ iParam1 ] = false ;
Menu_ListBans_Target ( iParam1 , target ) ;
2016-05-08 02:46:46 +02:00
}
}
}
}
void Menu_ListBans_Target ( int client , int target )
{
Menu ListTargetMenu = new Menu ( MenuHandler_Menu_ListBans_Target ) ;
2016-11-19 21:09:30 +01:00
ListTargetMenu . SetTitle ( " [SprayManager] Banned Client: %N (#%d) " , target , GetClientUserId ( target ) ) ;
2016-05-08 02:46:46 +02:00
ListTargetMenu . ExitBackButton = true ;
char sBanType [ 32 ] ;
char sUserID [ 32 ] ;
int iUserID = GetClientUserId ( target ) ;
Format ( sUserID , sizeof ( sUserID ) , " %d " , iUserID ) ;
if ( g_bSprayHashBanned [ target ] & & ! g_bSprayBanned [ target ] )
{
strcopy ( sBanType , sizeof ( sBanType ) , " Type: Hash " ) ;
ListTargetMenu . AddItem ( " " , sBanType , ITEMDRAW_DISABLED ) ;
ListTargetMenu . AddItem ( " " , " " , ITEMDRAW_SPACER ) ;
ListTargetMenu . AddItem ( sUserID , " Unban Client? " ) ;
ListTargetMenu . Display ( client , MENU_TIME_FOREVER ) ;
return ;
}
char sBanExpiryDate [ 64 ] ;
char sBanIssuedDate [ 64 ] ;
char sBanDuration [ 64 ] ;
char sBannedBy [ 128 ] ;
char sBanReason [ 64 ] ;
int iBanExpiryDate = g_iSprayUnbanTimestamp [ target ] ;
int iBanIssuedDate = g_iSprayBanTimestamp [ target ] ;
int iBanDuration = iBanExpiryDate ? ( ( iBanExpiryDate - iBanIssuedDate ) / 60 ) : 0 ;
if ( iBanExpiryDate )
{
FormatTime ( sBanExpiryDate , sizeof ( sBanExpiryDate ) , NULL_STRING , iBanExpiryDate ) ;
2016-11-19 21:09:30 +01:00
Format ( sBanDuration , sizeof ( sBanDuration ) , " %d %s " , iBanDuration , SingularOrMultiple ( iBanDuration ) ? " Minutes " : " Minute " ) ;
2016-05-08 02:46:46 +02:00
}
else
{
strcopy ( sBanExpiryDate , sizeof ( sBanExpiryDate ) , " Never " ) ;
strcopy ( sBanDuration , sizeof ( sBanDuration ) , " Permanent " ) ;
}
FormatTime ( sBanIssuedDate , sizeof ( sBanIssuedDate ) , NULL_STRING , iBanIssuedDate ) ;
Format ( sBannedBy , sizeof ( sBannedBy ) , " Banned by: %s (%s) " , g_sBanIssuer [ target ] , g_sBanIssuerSID [ target ] ) ;
Format ( sBanDuration , sizeof ( sBanDuration ) , " Duration: %s " , sBanDuration ) ;
Format ( sBanExpiryDate , sizeof ( sBanExpiryDate ) , " Expires: %s " , sBanExpiryDate ) ;
Format ( sBanIssuedDate , sizeof ( sBanIssuedDate ) , " Issued on: %s " , sBanIssuedDate ) ;
Format ( sBanReason , sizeof ( sBanReason ) , " Reason: %s " , g_sBanReason [ target ] ) ;
if ( g_bSprayBanned [ target ] & & g_bSprayHashBanned [ target ] )
strcopy ( sBanType , sizeof ( sBanType ) , " Type: Spray & Hash " ) ;
else if ( g_bSprayBanned [ target ] )
strcopy ( sBanType , sizeof ( sBanType ) , " Type: Spray " ) ;
ListTargetMenu . AddItem ( " " , sBanType , ITEMDRAW_DISABLED ) ;
ListTargetMenu . AddItem ( " " , sBannedBy , ITEMDRAW_DISABLED ) ;
ListTargetMenu . AddItem ( " " , sBanIssuedDate , ITEMDRAW_DISABLED ) ;
ListTargetMenu . AddItem ( " " , sBanExpiryDate , ITEMDRAW_DISABLED ) ;
ListTargetMenu . AddItem ( " " , sBanDuration , ITEMDRAW_DISABLED ) ;
ListTargetMenu . AddItem ( " " , sBanReason , ITEMDRAW_DISABLED ) ;
ListTargetMenu . AddItem ( sUserID , " Unban Client? " ) ;
ListTargetMenu . Display ( client , MENU_TIME_FOREVER ) ;
}
int MenuHandler_Menu_ListBans_Target ( Menu hMenu , MenuAction action , int iParam1 , int iParam2 )
{
switch ( action )
{
case MenuAction_End :
2016-11-19 21:09:30 +01:00
delete hMenu ;
2016-05-08 02:46:46 +02:00
case MenuAction_Cancel :
{
if ( iParam2 = = MenuCancel_ExitBack )
{
if ( g_bInvokedThroughListMenu [ iParam1 ] )
Menu_ListBans ( iParam1 ) ;
else
2016-11-19 21:09:30 +01:00
Menu_Unban ( iParam1 ) ;
2016-05-08 02:46:46 +02:00
}
}
case MenuAction_Select :
{
char sOption [ 32 ] ;
hMenu . GetItem ( iParam2 , sOption , sizeof ( sOption ) ) ;
int target = GetClientOfUserId ( StringToInt ( sOption ) ) ;
if ( ! IsValidClient ( target ) )
{
PrintToChat ( iParam1 , " \x01 \x04 [SprayManager] \x01 Target no longer available. " ) ;
Menu_ListBans ( iParam1 ) ;
}
else
{
2016-11-19 21:09:30 +01:00
if ( g_bSprayBanned [ target ] & & g_bSprayHashBanned [ target ] )
{
Menu MenuUnbanMode = new Menu ( MenuHandler_Menu_UnbanMode ) ;
MenuUnbanMode . SetTitle ( " [SprayManager] Unban %N? " , target ) ;
MenuUnbanMode . ExitBackButton = true ;
MenuUnbanMode . AddItem ( " H " , " Remove Hash Ban. " ) ;
MenuUnbanMode . AddItem ( " S " , " Remove Spray Ban. " ) ;
MenuUnbanMode . AddItem ( " B " , " Remove Both. " ) ;
g_iSprayUnbanTarget [ iParam1 ] = target ;
MenuUnbanMode . Display ( iParam1 , MENU_TIME_FOREVER ) ;
return ;
}
2016-05-08 02:46:46 +02:00
Menu MenuConfirmUnban = new Menu ( MenuHandler_Menu_ConfirmUnban ) ;
MenuConfirmUnban . SetTitle ( " [SprayManager] Unban %N? " , target ) ;
MenuConfirmUnban . ExitBackButton = true ;
MenuConfirmUnban . AddItem ( " Y " , " Yes. " ) ;
MenuConfirmUnban . AddItem ( " N " , " No. " ) ;
g_iSprayUnbanTarget [ iParam1 ] = target ;
MenuConfirmUnban . Display ( iParam1 , MENU_TIME_FOREVER ) ;
}
}
}
}
2016-11-19 21:09:30 +01:00
int MenuHandler_Menu_UnbanMode ( Menu hMenu , MenuAction action , int iParam1 , int iParam2 )
{
switch ( action )
{
case MenuAction_End :
delete hMenu ;
case MenuAction_Cancel :
{
if ( iParam2 = = MenuCancel_ExitBack )
{
if ( IsValidClient ( g_iSprayUnbanTarget [ iParam1 ] ) )
Menu_ListBans_Target ( iParam1 , g_iSprayUnbanTarget [ iParam1 ] ) ;
2016-11-30 20:40:59 +01:00
else if ( g_hTopMenu ! = null )
2016-11-19 21:09:30 +01:00
DisplayTopMenu ( g_hTopMenu , iParam1 , TopMenuPosition_LastCategory ) ;
else
delete hMenu ;
}
}
case MenuAction_Select :
{
char sOption [ 2 ] ;
hMenu . GetItem ( iParam2 , sOption , sizeof ( sOption ) ) ;
int target = g_iSprayUnbanTarget [ iParam1 ] ;
if ( ! IsValidClient ( target ) )
{
PrintToChat ( iParam1 , " \x01 \x04 [SprayManager] \x01 Target no longer available. " ) ;
g_iSprayUnbanTarget [ iParam1 ] = 0 ;
2016-11-30 20:40:59 +01:00
if ( g_hTopMenu ! = null )
2016-11-19 21:09:30 +01:00
DisplayTopMenu ( g_hTopMenu , iParam1 , TopMenuPosition_LastCategory ) ;
else
delete hMenu ;
}
else
{
if ( sOption [ 0 ] = = 'H' )
{
if ( UnbanClientSpray ( iParam1 , target ) )
{
ShowActivity2 ( iParam1 , " \x01 \x04 [SprayManager] " , " \x01 Unbanned \x04 %N \x01 's spray " , target ) ;
LogAction ( iParam1 , target , " \" %L \" unbanned \" %L \" 's spray " , iParam1 , target ) ;
}
}
else if ( sOption [ 0 ] = = 'S' )
{
if ( SprayUnbanClient ( target , iParam1 ) )
{
ShowActivity2 ( iParam1 , " \x01 \x04 [SprayManager] " , " \x01 Spray unbanned \x04 %N " , target ) ;
LogAction ( iParam1 , target , " \" %L \" spray unbanned \" %L \" " , iParam1 , target ) ;
}
}
else if ( sOption [ 0 ] = = 'B' )
{
if ( SprayUnbanClient ( target , iParam1 ) & & UnbanClientSpray ( iParam1 , target ) )
{
ShowActivity2 ( iParam1 , " \x01 \x04 [SprayManager] " , " \x01 Spray unbanned \x04 %N " , target ) ;
LogAction ( iParam1 , target , " \" %L \" spray unbanned \" %L \" " , iParam1 , target ) ;
}
}
g_iSprayUnbanTarget [ iParam1 ] = 0 ;
}
}
}
}
2016-05-08 02:46:46 +02:00
int MenuHandler_Menu_ConfirmUnban ( Menu hMenu , MenuAction action , int iParam1 , int iParam2 )
{
switch ( action )
{
case MenuAction_End :
2016-11-19 21:09:30 +01:00
delete hMenu ;
2016-05-08 02:46:46 +02:00
case MenuAction_Cancel :
{
if ( iParam2 = = MenuCancel_ExitBack )
{
if ( IsValidClient ( g_iSprayUnbanTarget [ iParam1 ] ) )
Menu_ListBans_Target ( iParam1 , g_iSprayUnbanTarget [ iParam1 ] ) ;
2016-11-30 20:40:59 +01:00
else if ( g_hTopMenu ! = null )
2016-05-08 02:46:46 +02:00
DisplayTopMenu ( g_hTopMenu , iParam1 , TopMenuPosition_LastCategory ) ;
else
2016-11-19 21:09:30 +01:00
delete hMenu ;
2016-05-08 02:46:46 +02:00
}
}
case MenuAction_Select :
{
char sOption [ 2 ] ;
hMenu . GetItem ( iParam2 , sOption , sizeof ( sOption ) ) ;
int target = g_iSprayUnbanTarget [ iParam1 ] ;
if ( ! IsValidClient ( target ) )
{
PrintToChat ( iParam1 , " \x01 \x04 [SprayManager] \x01 Target no longer available. " ) ;
g_iSprayUnbanTarget [ iParam1 ] = 0 ;
2016-11-30 20:40:59 +01:00
if ( g_hTopMenu ! = null )
2016-05-08 02:46:46 +02:00
DisplayTopMenu ( g_hTopMenu , iParam1 , TopMenuPosition_LastCategory ) ;
else
2016-11-19 21:09:30 +01:00
delete hMenu ;
2016-05-08 02:46:46 +02:00
}
else
{
if ( sOption [ 0 ] = = 'Y' )
{
if ( g_bSprayHashBanned [ target ] & & g_bSprayBanned [ target ] )
{
2016-11-19 21:09:30 +01:00
if ( SprayUnbanClient ( target , iParam1 ) & & UnbanClientSpray ( iParam1 , target ) )
{
ShowActivity2 ( iParam1 , " \x01 \x04 [SprayManager] " , " \x01 Spray unbanned \x04 %N " , target ) ;
LogAction ( iParam1 , target , " \" %L \" spray unbanned \" %L \" " , iParam1 , target ) ;
}
2016-05-08 02:46:46 +02:00
}
else if ( g_bSprayBanned [ target ] )
{
2016-11-19 21:09:30 +01:00
if ( SprayUnbanClient ( target , iParam1 ) )
{
ShowActivity2 ( iParam1 , " \x01 \x04 [SprayManager] " , " \x01 Spray unbanned \x04 %N " , target ) ;
LogAction ( iParam1 , target , " \" %L \" spray unbanned \" %L \" " , iParam1 , target ) ;
}
2016-05-08 02:46:46 +02:00
}
else if ( g_bSprayHashBanned [ target ] )
{
2016-11-19 21:09:30 +01:00
if ( UnbanClientSpray ( iParam1 , target ) )
{
ShowActivity2 ( iParam1 , " \x01 \x04 [SprayManager] " , " \x01 Unbanned \x04 %N \x01 's spray " , target ) ;
LogAction ( iParam1 , target , " \" %L \" unbanned \" %L \" 's spray " , iParam1 , target ) ;
}
2016-05-08 02:46:46 +02:00
}
g_iSprayUnbanTarget [ iParam1 ] = 0 ;
}
else if ( sOption [ 0 ] = = 'N' )
{
Menu_ListBans_Target ( iParam1 , g_iSprayUnbanTarget [ iParam1 ] ) ;
g_iSprayUnbanTarget [ iParam1 ] = 0 ;
}
}
}
}
}
public Action Command_AdminSpray ( int client , int argc )
{
if ( ! client )
{
PrintToServer ( " [SprayManager] Cannot use command from server console. " ) ;
return Plugin_Handled ;
}
if ( argc > 0 )
{
char sArgs [ 64 ] ;
char sTargetName [ MAX_TARGET_LENGTH ] ;
int iTargets [ MAXPLAYERS ] ;
int iTargetCount ;
bool bIsML ;
GetCmdArg ( 1 , sArgs , sizeof ( sArgs ) ) ;
2016-05-10 12:57:25 +02:00
if ( ( iTargetCount = ProcessTargetString ( sArgs , client , iTargets , MAXPLAYERS , COMMAND_FILTER_NO_BOTS , sTargetName , sizeof ( sTargetName ) , bIsML ) ) < = 0 )
2016-05-08 02:46:46 +02:00
{
ReplyToTargetError ( client , iTargetCount ) ;
return Plugin_Handled ;
}
for ( int i = 0 ; i < iTargetCount ; i + + )
{
2016-11-30 20:40:59 +01:00
g_iAllowSpray = iTargets [ i ] ;
2016-08-16 22:03:59 +02:00
ForceSpray ( client , iTargets [ i ] , false ) ;
2016-05-08 02:46:46 +02:00
}
PrintToChat ( client , " \x01 \x04 [SprayManager] \x01 Sprayed \x04 %s \x01 's spray(s). " , sTargetName ) ;
return Plugin_Handled ;
}
2016-11-30 20:40:59 +01:00
g_iAllowSpray = client ;
2016-08-16 22:03:59 +02:00
ForceSpray ( client , client , false ) ;
2016-05-10 12:57:25 +02:00
PrintToChat ( client , " \x01 \x04 [SprayManager] \x01 Sprayed your own spray. " ) ;
2016-05-08 02:46:46 +02:00
return Plugin_Handled ;
}
public Action Command_SprayBan ( int client , int argc )
{
2016-05-14 13:20:31 +02:00
if ( argc < 2 )
2016-05-08 02:46:46 +02:00
{
2016-05-14 13:20:31 +02:00
ReplyToCommand ( client , " [SprayManager] Usage: sm_sprayban <target> <time> <reason:optional> " ) ;
2016-05-08 02:46:46 +02:00
return Plugin_Handled ;
}
int iTarget ;
char sTarget [ 32 ] ;
char sLength [ 32 ] ;
char sReason [ 32 ] ;
GetCmdArg ( 1 , sTarget , sizeof ( sTarget ) ) ;
2016-05-14 13:20:31 +02:00
GetCmdArg ( 2 , sLength , sizeof ( sLength ) ) ;
2016-05-08 02:46:46 +02:00
2016-05-14 13:20:31 +02:00
if ( argc > 2 )
GetCmdArg ( 3 , sReason , sizeof ( sReason ) ) ;
2016-05-08 02:46:46 +02:00
2016-05-10 23:34:17 +02:00
if ( ( iTarget = FindTarget ( client , sTarget ) ) < = 0 )
2016-05-08 02:46:46 +02:00
return Plugin_Handled ;
2016-11-19 21:09:30 +01:00
if ( ! SprayBanClient ( client , iTarget , StringToInt ( sLength ) , sReason ) )
return Plugin_Handled ;
ShowActivity2 ( client , " \x01 \x04 [SprayManager] " , " \x01 Spray banned \x04 %N " , iTarget ) ;
2017-01-29 08:44:35 +01:00
LogAction ( client , iTarget , " \" %L \" spray banned \" %L \" (Hash: \" %s \" ) " , client , iTarget , g_sSprayHash [ iTarget ] ) ;
2016-05-08 02:46:46 +02:00
return Plugin_Handled ;
}
public Action Command_SprayUnban ( int client , int argc )
{
if ( argc < 1 )
{
ReplyToCommand ( client , " [SprayManager] Usage: sm_sprayunban <target> " ) ;
return Plugin_Handled ;
}
int iTarget ;
char sTarget [ 32 ] ;
GetCmdArg ( 1 , sTarget , sizeof ( sTarget ) ) ;
2016-05-10 23:34:17 +02:00
if ( ( iTarget = FindTarget ( client , sTarget ) ) < = 0 )
2016-05-08 02:46:46 +02:00
return Plugin_Handled ;
2016-11-19 21:09:30 +01:00
if ( ! SprayUnbanClient ( iTarget , client ) )
2016-05-08 02:46:46 +02:00
return Plugin_Handled ;
2016-11-19 21:09:30 +01:00
ShowActivity2 ( client , " \x01 \x04 [SprayManager] " , " \x01 Spray unbanned \x04 %N " , iTarget ) ;
LogAction ( client , iTarget , " \" %L \" spray unbanned \" %L \" " , client , iTarget ) ;
2016-05-08 02:46:46 +02:00
return Plugin_Handled ;
}
public Action Command_BanSpray ( int client , int argc )
{
2016-08-16 22:03:59 +02:00
if ( argc > 0 )
2016-05-08 02:46:46 +02:00
{
2016-08-16 22:03:59 +02:00
int iTarget ;
char sTarget [ 32 ] ;
2016-05-08 02:46:46 +02:00
2016-08-16 22:03:59 +02:00
GetCmdArg ( 1 , sTarget , sizeof ( sTarget ) ) ;
2016-05-08 02:46:46 +02:00
2016-08-16 22:03:59 +02:00
if ( ( iTarget = FindTarget ( client , sTarget ) ) < = 0 )
return Plugin_Handled ;
2016-05-08 02:46:46 +02:00
2016-11-19 21:09:30 +01:00
if ( ! BanClientSpray ( client , iTarget ) )
2016-08-16 22:03:59 +02:00
return Plugin_Handled ;
2016-05-08 02:46:46 +02:00
2016-11-19 21:09:30 +01:00
ShowActivity2 ( client , " \x01 \x04 [SprayManager] " , " \x01Ba nned \x04 %N \x01 's spray " , iTarget ) ;
LogAction ( client , iTarget , " \" %L \" banned \" %L \" 's spray " , client , iTarget ) ;
2016-08-21 11:01:23 +02:00
return Plugin_Handled ;
2016-08-16 22:03:59 +02:00
}
2016-11-19 21:09:30 +01:00
2016-08-16 22:03:59 +02:00
float vecEndPos [ 3 ] ;
if ( TracePlayerAngles ( client , vecEndPos ) )
2016-05-08 02:46:46 +02:00
{
2016-08-16 22:03:59 +02:00
for ( int i = 1 ; i < = MaxClients ; i + + )
{
if ( ! IsPointInsideAABB ( vecEndPos , g_SprayAABB [ i ] ) )
continue ;
2016-11-19 21:09:30 +01:00
if ( ! BanClientSpray ( client , i ) )
2016-08-16 22:03:59 +02:00
return Plugin_Handled ;
2016-11-19 21:09:30 +01:00
ShowActivity2 ( client , " \x01 \x04 [SprayManager] " , " \x01Ba nned \x04 %N \x01 's spray " , i ) ;
LogAction ( client , i , " \" %L \" banned \" %L \" 's spray " , client , i ) ;
2016-08-16 22:03:59 +02:00
return Plugin_Handled ;
}
2016-05-08 02:46:46 +02:00
}
2016-08-16 22:03:59 +02:00
PrintToChat ( client , " \x01 \x04 [SprayManager] \x01 No spray could be found. " ) ;
2016-05-08 02:46:46 +02:00
return Plugin_Handled ;
}
public Action Command_UnbanSpray ( int client , int argc )
{
if ( argc < 1 )
{
ReplyToCommand ( client , " [SprayManager] Usage: sm_unbanspray <target> " ) ;
return Plugin_Handled ;
}
int iTarget ;
char sTarget [ 32 ] ;
GetCmdArg ( 1 , sTarget , sizeof ( sTarget ) ) ;
2016-05-10 23:34:17 +02:00
if ( ( iTarget = FindTarget ( client , sTarget ) ) < = 0 )
2016-05-08 02:46:46 +02:00
return Plugin_Handled ;
2016-11-19 21:09:30 +01:00
if ( ! UnbanClientSpray ( client , iTarget ) )
2016-05-08 02:46:46 +02:00
return Plugin_Handled ;
2016-11-19 21:09:30 +01:00
ShowActivity2 ( client , " \x01 \x04 [SprayManager] " , " \x01 Unbanned \x04 %N \x01 's spray " , iTarget ) ;
LogAction ( client , iTarget , " \" %L \" unbanned \" %L \" 's spray " , client , iTarget ) ;
2016-05-08 02:46:46 +02:00
return Plugin_Handled ;
}
public Action Command_TraceSpray ( int client , int argc )
{
if ( ! client )
{
PrintToServer ( " [SprayManager] Cannot use command from server console. " ) ;
return Plugin_Handled ;
}
float vecEndPos [ 3 ] ;
if ( TracePlayerAngles ( client , vecEndPos ) )
{
for ( int i = 1 ; i < = MaxClients ; i + + )
{
2016-11-19 21:09:30 +01:00
if ( ! IsPointInsideAABB ( vecEndPos , g_SprayAABB [ i ] ) )
continue ;
2016-05-08 02:46:46 +02:00
2016-11-19 21:09:30 +01:00
g_bInvokedThroughTopMenu [ client ] = false ;
Menu_Trace ( client , i ) ;
return Plugin_Handled ;
2016-05-08 02:46:46 +02:00
}
}
PrintToChat ( client , " \x01 \x04 [SprayManager] \x01 Trace did not hit any sprays. " ) ;
return Plugin_Handled ;
}
public Action Command_RemoveSpray ( int client , int argc )
{
if ( ! client )
{
PrintToServer ( " [SprayManager] Cannot use command from server console. " ) ;
return Plugin_Handled ;
}
2016-05-10 12:57:25 +02:00
if ( argc > 0 )
{
char sArgs [ 64 ] ;
char sTargetName [ MAX_TARGET_LENGTH ] ;
int iTargets [ MAXPLAYERS ] ;
int iTargetCount ;
bool bIsML ;
GetCmdArg ( 1 , sArgs , sizeof ( sArgs ) ) ;
if ( ( iTargetCount = ProcessTargetString ( sArgs , client , iTargets , MAXPLAYERS , COMMAND_FILTER_NO_BOTS , sTargetName , sizeof ( sTargetName ) , bIsML ) ) < = 0 )
{
ReplyToTargetError ( client , iTargetCount ) ;
return Plugin_Handled ;
}
for ( int i = 0 ; i < iTargetCount ; i + + )
{
2016-11-30 20:40:59 +01:00
g_iAllowSpray = iTargets [ i ] ;
2016-12-02 12:55:09 +01:00
SprayClientDecalToAll ( iTargets [ i ] , 0 , ACTUAL_NULL_VECTOR ) ;
2016-05-10 12:57:25 +02:00
}
PrintToChat ( client , " \x01 \x04 [SprayManager] \x01 Removed \x04 %s \x01 's spray(s). " , sTargetName ) ;
return Plugin_Handled ;
}
2016-05-08 02:46:46 +02:00
float vecEndPos [ 3 ] ;
2016-05-10 12:57:25 +02:00
2016-05-08 02:46:46 +02:00
if ( TracePlayerAngles ( client , vecEndPos ) )
{
for ( int i = 1 ; i < = MaxClients ; i + + )
{
2016-05-10 12:57:25 +02:00
if ( ! IsPointInsideAABB ( vecEndPos , g_SprayAABB [ i ] ) )
continue ;
2016-05-08 02:46:46 +02:00
2016-11-30 20:40:59 +01:00
g_iAllowSpray = i ;
2016-12-02 12:55:09 +01:00
SprayClientDecalToAll ( i , 0 , ACTUAL_NULL_VECTOR ) ;
2016-05-08 02:46:46 +02:00
2016-05-10 12:57:25 +02:00
PrintToChat ( client , " \x01 \x04 [SprayManager] \x01 Removed \x04 %N \x01 's spray. " , i ) ;
return Plugin_Handled ;
2016-05-08 02:46:46 +02:00
}
}
PrintToChat ( client , " \x01 \x04 [SprayManager] \x01 No spray could be found. " ) ;
return Plugin_Handled ;
}
public Action Command_SprayManager_UpdateInfo ( int client , int argc )
{
for ( int i = 1 ; i < = MaxClients ; i + + )
{
2016-11-19 21:09:30 +01:00
if ( ! IsValidClient ( i ) | | IsFakeClient ( i ) )
continue ;
2016-12-02 12:55:09 +01:00
ClearPlayerInfo ( i ) ;
2016-11-19 21:09:30 +01:00
UpdatePlayerInfo ( i ) ;
UpdateSprayHashInfo ( i ) ;
2016-05-08 02:46:46 +02:00
}
ReplyToCommand ( client , " [SprayManager] Refreshed database. " ) ;
}
public Action HookDecal ( const char [ ] sTEName , const int [ ] iClients , int iNumClients , float fSendDelay )
{
2016-12-02 12:55:09 +01:00
if ( g_bSkipDecalHook )
return Plugin_Continue ;
2016-05-08 02:46:46 +02:00
int client = TE_ReadNum ( " m_nPlayer " ) ;
if ( ! IsValidClient ( client ) )
2016-11-30 20:40:59 +01:00
{
if ( g_iAllowSpray = = client )
g_iAllowSpray = 0 ;
2016-11-19 21:09:30 +01:00
return Plugin_Handled ;
2016-11-30 20:40:59 +01:00
}
2016-05-08 02:46:46 +02:00
float vecOrigin [ 3 ] ;
float AABBTemp [ AABBTotalPoints ] ;
TE_ReadVector ( " m_vecOrigin " , vecOrigin ) ;
AABBTemp [ AABBMinX ] = vecOrigin [ 0 ] - 32.0 ;
AABBTemp [ AABBMaxX ] = vecOrigin [ 0 ] + 32.0 ;
AABBTemp [ AABBMinY ] = vecOrigin [ 1 ] - 32.0 ;
AABBTemp [ AABBMaxY ] = vecOrigin [ 1 ] + 32.0 ;
AABBTemp [ AABBMinZ ] = vecOrigin [ 2 ] - 32.0 ;
AABBTemp [ AABBMaxZ ] = vecOrigin [ 2 ] + 32.0 ;
2016-11-30 20:40:59 +01:00
if ( g_iAllowSpray ! = client )
2016-05-08 02:46:46 +02:00
{
if ( g_bSprayHashBanned [ client ] )
{
PrintToChat ( client , " \x01 \x04 [SprayManager] \x01 Your spray is blacklisted, change it. " ) ;
return Plugin_Handled ;
}
if ( g_iSprayUnbanTimestamp [ client ] ! = 0 & & g_iSprayUnbanTimestamp [ client ] ! = - 1 )
{
if ( g_iSprayUnbanTimestamp [ client ] < GetTime ( ) )
SprayUnbanClient ( client ) ;
}
if ( g_bSprayBanned [ client ] )
{
char sRemainingTime [ 512 ] ;
FormatRemainingTime ( g_iSprayUnbanTimestamp [ client ] , sRemainingTime , sizeof ( sRemainingTime ) ) ;
PrintToChat ( client , " \x01 \x04 [SprayManager] \x01 You are currently spray banned. ( \x04 %s \x01 ) " , sRemainingTime ) ;
return Plugin_Handled ;
}
if ( g_fNextSprayTime [ client ] > GetGameTime ( ) )
return Plugin_Handled ;
2016-11-19 21:09:30 +01:00
char sSteamID [ 32 ] ;
GetClientAuthId ( client , AuthId_Steam2 , sSteamID , sizeof ( sSteamID ) ) ;
2016-05-08 02:46:46 +02:00
if ( ! CheckCommandAccess ( client , " sm_sprayban " , ADMFLAG_GENERIC ) )
{
2016-12-02 12:55:09 +01:00
if ( g_cvarUseProximityCheck . BoolValue )
2016-05-08 02:46:46 +02:00
{
for ( int i = 1 ; i < = MaxClients ; i + + )
{
if ( ! IsValidClient ( i ) | | i = = client )
continue ;
if ( IsVectorZero ( g_vecSprayOrigin [ i ] ) )
continue ;
2016-11-19 23:31:37 +01:00
if ( ! IsPointInsideAABB ( vecOrigin , g_SprayAABB [ i ] ) & & ! CheckForAABBCollision ( AABBTemp , g_SprayAABB [ i ] ) )
2016-05-08 02:46:46 +02:00
continue ;
if ( CheckCommandAccess ( i , " " , ADMFLAG_CUSTOM1 , true ) | | CheckCommandAccess ( i , " sm_sprayban " , ADMFLAG_GENERIC ) )
{
PrintToChat ( client , " \x01 \x04 [SprayManager] \x01 Your spray is too close to \x04 %N \x01 's spray. " , i ) ;
return Plugin_Handled ;
}
}
}
if ( CheckCommandAccess ( client , " " , ADMFLAG_CUSTOM1 ) )
g_fNextSprayTime [ client ] = GetGameTime ( ) + ( g_cvarDecalFrequency . FloatValue / 2 ) ;
else
g_fNextSprayTime [ client ] = GetGameTime ( ) + g_cvarDecalFrequency . FloatValue ;
}
}
2016-11-30 20:40:59 +01:00
g_iAllowSpray = 0 ;
2016-05-08 02:46:46 +02:00
2016-05-10 12:57:25 +02:00
g_iSprayLifetime [ client ] = 0 ;
2016-12-02 12:55:09 +01:00
UpdateClientToClientSprayLifeTime ( client , 0 ) ;
2016-11-19 21:09:30 +01:00
g_vecSprayOrigin [ client ] = vecOrigin ;
2016-05-08 02:46:46 +02:00
2016-11-19 21:09:30 +01:00
g_SprayAABB [ client ] = AABBTemp ;
2016-05-08 02:46:46 +02:00
ArrayList PosArray = new ArrayList ( 3 , 0 ) ;
PosArray . PushArray ( vecOrigin , 3 ) ;
RequestFrame ( FrameAfterSpray , PosArray ) ;
return Plugin_Continue ;
}
public void FrameAfterSpray ( ArrayList Data )
{
float vecPos [ 3 ] ;
Data . GetArray ( 0 , vecPos , 3 ) ;
EmitSoundToAll ( " player/sprayer.wav " , SOUND_FROM_WORLD , SNDCHAN_AUTO , SNDLEVEL_NORMAL , SND_NOFLAGS , _ , _ , _ , vecPos ) ;
delete Data ;
}
2016-05-08 21:15:38 +02:00
public Action HookSprayer ( int iClients [ MAXPLAYERS ] , int & iNumClients , char sSoundName [ PLATFORM_MAX_PATH ] , int & iEntity , int & iChannel , float & flVolume , int & iLevel , int & iPitch , int & iFlags , char sSoundEntry [ PLATFORM_MAX_PATH ] , int & seed )
2016-05-08 02:46:46 +02:00
{
2016-12-02 12:55:09 +01:00
if ( strcmp ( sSoundName , " player/sprayer.wav " ) = = 0 & & iEntity > 0 )
2016-05-08 02:46:46 +02:00
return Plugin_Handled ;
return Plugin_Continue ;
}
2016-12-02 12:55:09 +01:00
public Action Timer_PerformPlayerTraces ( Handle hTimer )
2016-05-08 02:46:46 +02:00
{
static bool bLookingatSpray [ MAXPLAYERS + 1 ] ;
static bool bOnce [ MAXPLAYERS + 1 ] ;
float vecPos [ 3 ] ;
for ( int i = 1 ; i < = MaxClients ; i + + )
{
if ( ! IsValidClient ( i ) | | IsFakeClient ( i ) )
continue ;
if ( ! TracePlayerAngles ( i , vecPos ) )
continue ;
2016-12-02 12:55:09 +01:00
for ( int x = 1 ; x < = MaxClients ; x + + )
2016-05-08 02:46:46 +02:00
{
2016-12-02 12:55:09 +01:00
if ( ! IsValidClient ( x ) )
2016-05-08 02:46:46 +02:00
continue ;
2016-12-02 12:55:09 +01:00
if ( IsPointInsideAABB ( vecPos , g_SprayAABB [ x ] ) )
2016-05-08 02:46:46 +02:00
{
char sSteamID [ 32 ] ;
2016-12-02 12:55:09 +01:00
GetClientAuthId ( x , AuthId_Steam2 , sSteamID , sizeof ( sSteamID ) ) ;
2016-05-08 02:46:46 +02:00
2016-12-02 12:55:09 +01:00
PrintHintText ( i , " Sprayed by: %N (%s) " , x , sSteamID ) ;
2016-05-08 02:46:46 +02:00
StopSound ( i , SNDCHAN_STATIC , " UI/hint.wav " ) ;
bLookingatSpray [ i ] = true ;
bOnce [ i ] = false ;
break ;
}
else
bLookingatSpray [ i ] = false ;
}
}
2016-12-02 12:55:09 +01:00
for ( int i = 1 ; i < = MaxClients ; i + + )
{
if ( ! IsValidClient ( i ) | | IsFakeClient ( i ) )
continue ;
if ( ! bLookingatSpray [ i ] & & ! bOnce [ i ] )
{
PrintHintText ( i , " " ) ;
StopSound ( i , SNDCHAN_STATIC , " UI/hint.wav " ) ;
bOnce [ i ] = true ;
}
}
}
public Action Timer_ProcessPersistentSprays ( Handle hThis )
{
for ( int i = 1 ; i < = MaxClients ; i + + )
2016-05-08 02:46:46 +02:00
{
2016-12-02 12:55:09 +01:00
if ( ! IsValidClient ( i ) | | IsFakeClient ( i ) )
2016-05-08 02:46:46 +02:00
continue ;
2016-12-02 12:55:09 +01:00
for ( int x = 1 ; x < = MaxClients ; x + + )
2016-05-08 02:46:46 +02:00
{
2016-12-02 12:55:09 +01:00
if ( ! IsValidClient ( x ) | | IsFakeClient ( x ) )
continue ;
2017-01-29 08:44:35 +01:00
if ( ! IsVectorZero ( g_vecSprayOrigin [ x ] ) )
g_iClientToClientSprayLifetime [ i ] [ x ] + + ;
2016-12-02 12:55:09 +01:00
2017-01-29 08:44:35 +01:00
if ( g_iClientToClientSprayLifetime [ i ] [ x ] > = g_iClientSprayLifetime [ i ] )
2016-12-02 12:55:09 +01:00
{
g_bSkipDecalHook = true ;
2017-01-29 08:44:35 +01:00
SprayClientDecalToOne ( x , i , g_iDecalEntity [ x ] , g_vecSprayOrigin [ x ] ) ;
g_iClientToClientSprayLifetime [ i ] [ x ] = 0 ;
2016-12-02 12:55:09 +01:00
g_bSkipDecalHook = false ;
}
}
}
g_hRoundEndTimer = null ;
}
public Action Timer_ResetOldSprays ( Handle hThis )
{
for ( int i = 1 ; i < = MaxClients ; i + + )
{
if ( ! IsValidClient ( i ) | | IsFakeClient ( i ) )
continue ;
2016-05-08 02:46:46 +02:00
2016-12-02 12:55:09 +01:00
if ( ! IsVectorZero ( g_vecSprayOrigin [ i ] ) )
g_iSprayLifetime [ i ] + + ;
if ( g_iSprayLifetime [ i ] > = g_cvarMaxSprayLifetime . IntValue )
{
g_iAllowSpray = i ;
SprayClientDecalToAll ( i , 0 , ACTUAL_NULL_VECTOR ) ;
g_iSprayLifetime [ i ] = 0 ;
2016-05-08 02:46:46 +02:00
}
}
2016-12-02 12:55:09 +01:00
g_hRoundEndTimer = null ;
2016-05-08 02:46:46 +02:00
}
void InitializeSQL ( )
{
if ( g_hDatabase ! = null )
delete g_hDatabase ;
if ( SQL_CheckConfig ( " spraymanager " ) )
SQL_TConnect ( OnSQLConnected , " spraymanager " ) ;
else
SetFailState ( " Could not find \" spraymanager \" entry in databases.cfg. " ) ;
}
public void OnSQLConnected ( Handle hParent , Handle hChild , const char [ ] err , any data )
{
if ( hChild = = null )
{
LogError ( " Failed to connect to database, retrying in 10 seconds. (%s) " , err ) ;
if ( CreateTimer ( 10.0 , ReconnectSQL ) = = null )
{
LogError ( " Failed to create re-connector timer, trying to reconnect now. " ) ;
InitializeSQL ( ) ;
}
return ;
}
char sDriver [ 16 ] ;
g_hDatabase = CloneHandle ( hChild ) ;
SQL_GetDriverIdent ( hParent , sDriver , sizeof ( sDriver ) ) ;
if ( ! strncmp ( sDriver , " my " , 2 , false ) )
{
SQL_TQuery ( g_hDatabase , DummyCallback , " SET NAMES \" UTF8 \" " ) ;
SQL_TQuery ( g_hDatabase , OnSQLTableCreated , " CREATE TABLE IF NOT EXISTS `spraymanager` (`steamid` VARCHAR(32) NOT NULL, `name` VARCHAR(32) NOT NULL, `unbantime` INT, `issuersteamid` VARCHAR(32), `issuername` VARCHAR(32) NOT NULL, `issuedtime` INT, `issuedreason` VARCHAR(64) NOT NULL, PRIMARY KEY(steamid)) CHARACTER SET utf8 COLLATE utf8_general_ci; " ) ;
SQL_TQuery ( g_hDatabase , OnSQLSprayBlacklistCreated , " CREATE TABLE IF NOT EXISTS `sprayblacklist` (`sprayhash` VARCHAR(16) NOT NULL, `sprayer` VARCHAR(32) NOT NULL, `sprayersteamid` VARCHAR(32), PRIMARY KEY(sprayhash)) CHARACTER SET utf8 COLLATE utf8_general_ci; " ) ;
g_bSQLite = false ;
}
else
{
SQL_TQuery ( g_hDatabase , OnSQLTableCreated , " CREATE TABLE IF NOT EXISTS `spraymanager` (`steamid` TEXT NOT NULL, `name` TEXT DEFAULT 'unknown', `unbantime` INTEGER, `issuersteamid` TEXT, `issuername` TEXT DEFAULT 'unknown', `issuedtime` INTEGER NOT NULL, `issuedreason` TEXT DEFAULT 'none', PRIMARY KEY(steamid)); " ) ;
SQL_TQuery ( g_hDatabase , OnSQLSprayBlacklistCreated , " CREATE TABLE IF NOT EXISTS `sprayblacklist` (`sprayhash` TEXT NOT NULL, `sprayer` TEXT DEFAULT 'unknown', `sprayersteamid` TEXT, PRIMARY KEY(sprayhash)); " ) ;
g_bSQLite = true ;
}
}
public Action ReconnectSQL ( Handle hTimer )
{
InitializeSQL ( ) ;
return Plugin_Handled ;
}
public void OnSQLTableCreated ( Handle hParent , Handle hChild , const char [ ] err , any data )
{
if ( hChild = = null )
{
LogError ( " Database error while creating/checking for \" spraymanager \" table, retrying in 10 seconds. (%s) " , err ) ;
if ( CreateTimer ( 10.0 , RetryMainTableCreation ) = = null )
{
LogError ( " Failed to create re-query timer, trying to query now. " ) ;
if ( g_bSQLite )
SQL_TQuery ( g_hDatabase , OnSQLTableCreated , " CREATE TABLE IF NOT EXISTS `spraymanager` (`steamid` TEXT NOT NULL, `name` TEXT DEFAULT 'unknown', `unbantime` INTEGER, `issuersteamid` TEXT, `issuername` TEXT DEFAULT 'unknown', `issuedtime` INTEGER NOT NULL, `issuedreason` TEXT DEFAULT 'none', PRIMARY KEY(steamid)); " ) ;
else
SQL_TQuery ( g_hDatabase , OnSQLTableCreated , " CREATE TABLE IF NOT EXISTS `spraymanager` (`steamid` VARCHAR(32) NOT NULL, `name` VARCHAR(32) NOT NULL, `unbantime` INT, `issuersteamid` VARCHAR(32), `issuername` VARCHAR(32) NOT NULL, `issuedtime` INT, `issuedreason` VARCHAR(64) NOT NULL, PRIMARY KEY(steamid)) CHARACTER SET utf8 COLLATE utf8_general_ci; " ) ;
}
return ;
}
g_bGotBans = true ;
if ( g_bGotBlacklist )
{
if ( g_bLoadedLate )
{
2016-05-10 12:57:25 +02:00
if ( CreateTimer ( 2.5 , RetryUpdatingPlayerInfo ) = = null )
2016-05-08 02:46:46 +02:00
{
2016-05-10 12:57:25 +02:00
LogError ( " Failed to create player info updater timer, attempting to update info now. " ) ;
for ( int i = 1 ; i < = MaxClients ; i + + )
{
if ( ! IsValidClient )
continue ;
2016-05-08 02:46:46 +02:00
OnClientPostAdminCheck ( i ) ;
2016-05-10 12:57:25 +02:00
}
2016-05-08 02:46:46 +02:00
}
}
LogMessage ( " Successfully connected to %s database! " , g_bSQLite ? " SQLite " : " mySQL " ) ;
g_bFullyConnected = true ;
}
}
public Action RetryMainTableCreation ( Handle hTimer )
{
if ( g_bSQLite )
SQL_TQuery ( g_hDatabase , OnSQLTableCreated , " CREATE TABLE IF NOT EXISTS `spraymanager` (`steamid` TEXT NOT NULL, `name` TEXT DEFAULT 'unknown', `unbantime` INTEGER, `issuersteamid` TEXT, `issuername` TEXT DEFAULT 'unknown', `issuedtime` INTEGER NOT NULL, `issuedreason` TEXT DEFAULT 'none', PRIMARY KEY(steamid)); " ) ;
else
SQL_TQuery ( g_hDatabase , OnSQLTableCreated , " CREATE TABLE IF NOT EXISTS `spraymanager` (`steamid` VARCHAR(32) NOT NULL, `name` VARCHAR(32) NOT NULL, `unbantime` INT, `issuersteamid` VARCHAR(32), `issuername` VARCHAR(32) NOT NULL, `issuedtime` INT, `issuedreason` VARCHAR(64) NOT NULL, PRIMARY KEY(steamid)) CHARACTER SET utf8 COLLATE utf8_general_ci; " ) ;
}
public void OnSQLSprayBlacklistCreated ( Handle hParent , Handle hChild , const char [ ] err , any data )
{
if ( hChild = = null )
{
LogError ( " Database error while creating/checking for \" sprayblacklist \" table, retrying in 10 seconds. (%s) " , err ) ;
if ( CreateTimer ( 10.0 , RetryBlacklistTableCreation ) = = null )
{
LogError ( " Failed to create re-query timer, trying to query now. " ) ;
if ( g_bSQLite )
SQL_TQuery ( g_hDatabase , OnSQLSprayBlacklistCreated , " CREATE TABLE IF NOT EXISTS `sprayblacklist` (`sprayhash` TEXT NOT NULL, `sprayer` TEXT DEFAULT 'unknown', `sprayersteamid` TEXT NOT NULL, PRIMARY KEY(sprayhash)); " ) ;
else
SQL_TQuery ( g_hDatabase , OnSQLSprayBlacklistCreated , " CREATE TABLE IF NOT EXISTS `sprayblacklist` (`sprayhash` VARCHAR(16) NOT NULL, `sprayer` VARCHAR(32) NOT NULL, `sprayersteamid` VARCHAR(32) NOT NULL, PRIMARY KEY(sprayhash)) CHARACTER SET utf8 COLLATE utf8_general_ci; " ) ;
}
return ;
}
g_bGotBlacklist = true ;
if ( g_bGotBans )
{
if ( g_bLoadedLate )
{
2016-05-10 12:57:25 +02:00
if ( CreateTimer ( 2.5 , RetryUpdatingPlayerInfo ) = = null )
2016-05-08 02:46:46 +02:00
{
2016-05-10 12:57:25 +02:00
LogError ( " Failed to create player info updater timer, attempting to update info now. " ) ;
for ( int i = 1 ; i < = MaxClients ; i + + )
{
if ( ! IsValidClient )
continue ;
2016-05-08 02:46:46 +02:00
OnClientPostAdminCheck ( i ) ;
2016-05-10 12:57:25 +02:00
}
2016-05-08 02:46:46 +02:00
}
}
LogMessage ( " Successfully connected to %s database! " , g_bSQLite ? " SQLite " : " mySQL " ) ;
g_bFullyConnected = true ;
}
}
public Action RetryBlacklistTableCreation ( Handle hTimer )
{
if ( g_bSQLite )
SQL_TQuery ( g_hDatabase , OnSQLSprayBlacklistCreated , " CREATE TABLE IF NOT EXISTS `sprayblacklist` (`sprayhash` TEXT NOT NULL, `sprayer` TEXT DEFAULT 'unknown', `sprayersteamid` TEXT NOT NULL, PRIMARY KEY(sprayhash)); " ) ;
else
SQL_TQuery ( g_hDatabase , OnSQLSprayBlacklistCreated , " CREATE TABLE IF NOT EXISTS `sprayblacklist` (`sprayhash` VARCHAR(16) NOT NULL, `sprayer` VARCHAR(32) NOT NULL, `sprayersteamid` VARCHAR(32) NOT NULL, PRIMARY KEY(sprayhash)) CHARACTER SET utf8 COLLATE utf8_general_ci; " ) ;
}
2016-05-10 12:57:25 +02:00
public Action RetryUpdatingPlayerInfo ( Handle hTimer )
{
for ( int i = 1 ; i < = MaxClients ; i + + )
{
if ( ! IsValidClient )
continue ;
OnClientPostAdminCheck ( i ) ;
}
}
2016-12-02 12:55:09 +01:00
public void ConVarChanged_DecalFrequency ( ConVar cvar , const char [ ] sOldValue , const char [ ] sNewValue )
2016-05-08 02:46:46 +02:00
{
if ( cvar = = g_cvarHookedDecalFrequency )
{
if ( StringToInt ( sNewValue ) ! = 0 )
{
LogMessage ( " ConVar \" decalfrequency \" needs to be 0 at all times, please use sm_decalfrequency instead. " ) ;
cvar . IntValue = 0 ;
}
}
}
bool SprayBanClient ( int client , int target , int iBanLength , const char [ ] sReason )
{
if ( ! IsValidClient ( target ) )
{
ReplyToCommand ( client , " [SprayManager] Target is no longer valid. " ) ;
return false ;
}
if ( g_hDatabase = = null | | ! g_bFullyConnected )
{
ReplyToCommand ( client , " [SprayManager] Database is not connected. " ) ;
return false ;
}
if ( g_bSprayBanned [ target ] )
{
ReplyToCommand ( client , " [SprayManager] %N is already spray banned. " , target ) ;
return false ;
}
char sQuery [ 512 ] ;
char sAdminName [ 64 ] ;
char sTargetName [ 64 ] ;
char sTargetSteamID [ 32 ] ;
char sAdminSteamID [ 32 ] ;
Format ( sAdminName , sizeof ( sAdminName ) , " %N " , client ) ;
GetClientName ( target , sTargetName , sizeof ( sTargetName ) ) ;
if ( client )
GetClientAuthId ( client , AuthId_Steam2 , sAdminSteamID , sizeof ( sAdminSteamID ) ) ;
else
strcopy ( sAdminSteamID , sizeof ( sAdminSteamID ) , " STEAM_ID_SERVER " ) ;
GetClientAuthId ( target , AuthId_Steam2 , sTargetSteamID , sizeof ( sTargetSteamID ) ) ;
char [ ] sSafeAdminName = new char [ 2 * strlen ( sAdminName ) + 1 ] ;
char [ ] sSafeTargetName = new char [ 2 * strlen ( sTargetName ) + 1 ] ;
char [ ] sSafeReason = new char [ 2 * strlen ( sReason ) + 1 ] ;
SQL_EscapeString ( g_hDatabase , sAdminName , sSafeAdminName , 2 * strlen ( sAdminName ) + 1 ) ;
SQL_EscapeString ( g_hDatabase , sTargetName , sSafeTargetName , 2 * strlen ( sTargetName ) + 1 ) ;
SQL_EscapeString ( g_hDatabase , sReason , sSafeReason , 2 * strlen ( sReason ) + 1 ) ;
2016-11-19 21:09:30 +01:00
Format ( sQuery , sizeof ( sQuery ) , " INSERT INTO `spraymanager` (`steamid`, `name`, `unbantime`, `issuersteamid`, `issuername`, `issuedtime`, `issuedreason`) VALUES ('%s', '%s', '%d', '%s', '%s', '%d', '%s'); " ,
2016-05-08 21:15:38 +02:00
sTargetSteamID , sSafeTargetName , iBanLength ? ( GetTime ( ) + ( iBanLength * 60 ) ) : 0 , sAdminSteamID , sSafeAdminName , GetTime ( ) , strlen ( sSafeReason ) > 1 ? sSafeReason : " none " ) ;
2016-05-08 02:46:46 +02:00
SQL_TQuery ( g_hDatabase , DummyCallback , sQuery ) ;
strcopy ( g_sBanIssuer [ target ] , sizeof ( g_sBanIssuer [ ] ) , sAdminName ) ;
strcopy ( g_sBanIssuerSID [ target ] , sizeof ( g_sBanIssuerSID [ ] ) , sAdminSteamID ) ;
strcopy ( g_sBanReason [ target ] , sizeof ( g_sBanReason [ ] ) , strlen ( sReason ) ? sReason : " none " ) ;
g_bSprayBanned [ target ] = true ;
g_iSprayBanTimestamp [ target ] = GetTime ( ) ;
g_iSprayUnbanTimestamp [ target ] = iBanLength ? ( GetTime ( ) + ( iBanLength * 60 ) ) : 0 ;
g_fNextSprayTime [ target ] = 0.0 ;
2016-11-30 20:40:59 +01:00
g_iAllowSpray = target ;
2016-12-02 12:55:09 +01:00
SprayClientDecalToAll ( target , 0 , ACTUAL_NULL_VECTOR ) ;
2016-05-08 02:46:46 +02:00
return true ;
}
2016-11-19 21:09:30 +01:00
bool SprayUnbanClient ( int target , int client = - 1 )
2016-05-08 02:46:46 +02:00
{
2016-11-19 21:09:30 +01:00
if ( ! IsValidClient ( target ) )
{
if ( client ! = - 1 )
ReplyToCommand ( client , " [SprayManager] Target is no longer valid. " ) ;
2016-05-08 02:46:46 +02:00
return false ;
2016-11-19 21:09:30 +01:00
}
2016-05-08 02:46:46 +02:00
if ( g_hDatabase = = null | | ! g_bFullyConnected )
2016-11-19 21:09:30 +01:00
{
if ( client ! = - 1 )
ReplyToCommand ( client , " [SprayManager] Database is not connected. " ) ;
2016-05-08 02:46:46 +02:00
return false ;
2016-11-19 21:09:30 +01:00
}
if ( ! g_bSprayBanned [ target ] )
{
if ( client ! = - 1 )
ReplyToCommand ( client , " [SprayManager] %N is not spray banned. " , target ) ;
2016-05-08 02:46:46 +02:00
return false ;
2016-11-19 21:09:30 +01:00
}
2016-05-08 02:46:46 +02:00
char sQuery [ 128 ] ;
char sClientSteamID [ 32 ] ;
2016-11-19 21:09:30 +01:00
GetClientAuthId ( target , AuthId_Steam2 , sClientSteamID , sizeof ( sClientSteamID ) ) ;
2016-05-08 02:46:46 +02:00
Format ( sQuery , sizeof ( sQuery ) , " DELETE FROM `spraymanager` WHERE steamid = '%s'; " , sClientSteamID ) ;
SQL_TQuery ( g_hDatabase , DummyCallback , sQuery ) ;
2016-11-19 21:09:30 +01:00
strcopy ( g_sBanIssuer [ target ] , sizeof ( g_sBanIssuer [ ] ) , " " ) ;
strcopy ( g_sBanIssuerSID [ target ] , sizeof ( g_sBanIssuerSID [ ] ) , " " ) ;
strcopy ( g_sBanReason [ target ] , sizeof ( g_sBanReason [ ] ) , " " ) ;
g_bSprayBanned [ target ] = false ;
g_iSprayLifetime [ target ] = 0 ;
2016-12-02 12:55:09 +01:00
UpdateClientToClientSprayLifeTime ( target , 0 ) ;
2016-11-19 21:09:30 +01:00
g_iSprayBanTimestamp [ target ] = 0 ;
g_iSprayUnbanTimestamp [ target ] = - 1 ;
g_fNextSprayTime [ target ] = 0.0 ;
2016-05-08 02:46:46 +02:00
return true ;
}
2016-11-19 21:09:30 +01:00
bool BanClientSpray ( int client , int target )
2016-05-08 02:46:46 +02:00
{
2016-11-19 21:09:30 +01:00
if ( ! IsValidClient ( target ) )
{
ReplyToCommand ( client , " [SprayManager] Target is no longer valid. " ) ;
2016-05-08 02:46:46 +02:00
return false ;
2016-11-19 21:09:30 +01:00
}
2016-05-08 02:46:46 +02:00
if ( g_hDatabase = = null | | ! g_bFullyConnected )
2016-11-19 21:09:30 +01:00
{
ReplyToCommand ( client , " [SprayManager] Database is not connected. " ) ;
2016-05-08 02:46:46 +02:00
return false ;
2016-11-19 21:09:30 +01:00
}
2016-05-08 02:46:46 +02:00
2016-11-19 21:09:30 +01:00
if ( g_bSprayHashBanned [ target ] )
{
ReplyToCommand ( client , " [SprayManager] %N is already hash banned. " , target ) ;
2016-05-08 02:46:46 +02:00
return false ;
2016-11-19 21:09:30 +01:00
}
2016-05-08 02:46:46 +02:00
char sQuery [ 256 ] ;
char sTargetName [ 64 ] ;
char sTargetSteamID [ 32 ] ;
2016-11-19 21:09:30 +01:00
GetClientName ( target , sTargetName , sizeof ( sTargetName ) ) ;
GetClientAuthId ( target , AuthId_Steam2 , sTargetSteamID , sizeof ( sTargetSteamID ) ) ;
2016-05-08 02:46:46 +02:00
char [ ] sSafeTargetName = new char [ 2 * strlen ( sTargetName ) + 1 ] ;
SQL_EscapeString ( g_hDatabase , sTargetName , sSafeTargetName , 2 * strlen ( sTargetName ) + 1 ) ;
Format ( sQuery , sizeof ( sQuery ) , " INSERT INTO `sprayblacklist` (`sprayhash`, `sprayer`, `sprayersteamid`) VALUES ('%s', '%s', '%s'); " ,
2016-11-19 21:09:30 +01:00
g_sSprayHash [ target ] , sSafeTargetName , sTargetSteamID ) ;
2016-05-08 02:46:46 +02:00
SQL_TQuery ( g_hDatabase , DummyCallback , sQuery ) ;
2016-11-19 21:09:30 +01:00
g_bSprayHashBanned [ target ] = true ;
2016-05-08 02:46:46 +02:00
2016-11-30 20:40:59 +01:00
g_iAllowSpray = target ;
2016-12-02 12:55:09 +01:00
SprayClientDecalToAll ( target , 0 , ACTUAL_NULL_VECTOR ) ;
2016-05-08 02:46:46 +02:00
return true ;
}
2016-11-19 21:09:30 +01:00
bool UnbanClientSpray ( int client , int target )
2016-05-08 02:46:46 +02:00
{
2016-11-19 21:09:30 +01:00
if ( ! IsValidClient ( target ) )
{
ReplyToCommand ( client , " [SprayManager] Target is no longer valid. " ) ;
2016-05-08 02:46:46 +02:00
return false ;
2016-11-19 21:09:30 +01:00
}
2016-05-08 02:46:46 +02:00
if ( g_hDatabase = = null | | ! g_bFullyConnected )
2016-11-19 21:09:30 +01:00
{
ReplyToCommand ( client , " [SprayManager] Database is not connected. " ) ;
2016-05-08 02:46:46 +02:00
return false ;
2016-11-19 21:09:30 +01:00
}
2016-05-08 02:46:46 +02:00
2016-11-19 21:09:30 +01:00
if ( ! g_bSprayHashBanned [ target ] )
{
ReplyToCommand ( client , " [SprayManager] %N is not hash banned. " , target ) ;
2016-05-08 02:46:46 +02:00
return false ;
2016-11-19 21:09:30 +01:00
}
2016-05-08 02:46:46 +02:00
char sQuery [ 128 ] ;
2016-11-19 21:09:30 +01:00
Format ( sQuery , sizeof ( sQuery ) , " DELETE FROM `sprayblacklist` WHERE `sprayhash` = '%s'; " , g_sSprayHash [ target ] ) ;
2016-05-08 02:46:46 +02:00
SQL_TQuery ( g_hDatabase , DummyCallback , sQuery ) ;
2016-11-19 21:09:30 +01:00
g_bSprayHashBanned [ target ] = false ;
2016-05-08 02:46:46 +02:00
return true ;
}
void UpdatePlayerInfo ( int client )
{
if ( ! IsValidClient ( client ) )
return ;
if ( g_hDatabase = = null | | ! g_bFullyConnected )
return ;
char sSteamID [ 32 ] ;
char sQuery [ 128 ] ;
GetClientAuthId ( client , AuthId_Steam2 , sSteamID , sizeof ( sSteamID ) ) ;
Format ( sQuery , sizeof ( sQuery ) , " SELECT * FROM `spraymanager` WHERE `steamid` = '%s'; " , sSteamID ) ;
SQL_TQuery ( g_hDatabase , OnSQLCheckBanQuery , sQuery , client , DBPrio_High ) ;
}
void UpdateSprayHashInfo ( int client )
{
if ( ! IsValidClient ( client ) )
return ;
if ( g_hDatabase = = null | | ! g_bFullyConnected )
return ;
char sSprayQuery [ 128 ] ;
GetPlayerDecalFile ( client , g_sSprayHash [ client ] , sizeof ( g_sSprayHash [ ] ) ) ;
Format ( sSprayQuery , sizeof ( sSprayQuery ) , " SELECT * FROM `sprayblacklist` WHERE `sprayhash` = '%s'; " , g_sSprayHash [ client ] ) ;
SQL_TQuery ( g_hDatabase , OnSQLCheckSprayHashBanQuery , sSprayQuery , client , DBPrio_High ) ;
}
public void DummyCallback ( Handle hOwner , Handle hChild , const char [ ] err , any data )
{
if ( hOwner = = null | | hChild = = null )
LogError ( " Query error. (%s) " , err ) ;
}
public void OnSQLCheckBanQuery ( Handle hParent , Handle hChild , const char [ ] err , any client )
{
if ( ! IsValidClient ( client ) )
return ;
if ( hChild = = null )
{
LogError ( " An error occurred while querying the database for a user ban, retrying in 10 seconds. (%s) " , err ) ;
if ( CreateTimer ( 10.0 , RetryPlayerInfoUpdate , client ) = = null )
{
LogError ( " Failed to create query timer, trying to query now. " ) ;
UpdatePlayerInfo ( client ) ;
}
return ;
}
if ( SQL_FetchRow ( hChild ) )
{
g_bSprayBanned [ client ] = true ;
g_iSprayUnbanTimestamp [ client ] = SQL_FetchInt ( hChild , 2 ) ;
g_iSprayBanTimestamp [ client ] = SQL_FetchInt ( hChild , 5 ) ;
SQL_FetchString ( hChild , 3 , g_sBanIssuerSID [ client ] , sizeof ( g_sBanIssuerSID [ ] ) ) ;
SQL_FetchString ( hChild , 4 , g_sBanIssuer [ client ] , sizeof ( g_sBanIssuer [ ] ) ) ;
SQL_FetchString ( hChild , 6 , g_sBanReason [ client ] , sizeof ( g_sBanReason [ ] ) ) ;
}
}
public void OnSQLCheckSprayHashBanQuery ( Handle hParent , Handle hChild , const char [ ] err , any client )
{
if ( ! IsValidClient ( client ) )
return ;
if ( hChild = = null )
{
LogError ( " An error occurred while querying the database for a spray ban, retrying in 10 seconds. (%s) " , err ) ;
if ( CreateTimer ( 10.0 , RetrySprayHashUpdate , client ) = = null )
{
LogError ( " Failed to create spray query timer, trying to query now. " ) ;
UpdateSprayHashInfo ( client ) ;
}
return ;
}
if ( SQL_FetchRow ( hChild ) )
g_bSprayHashBanned [ client ] = true ;
}
public Action RetryPlayerInfoUpdate ( Handle hTimer , any client )
{
UpdatePlayerInfo ( client ) ;
}
public Action RetrySprayHashUpdate ( Handle hTimer , any client )
{
UpdateSprayHashInfo ( client ) ;
}
bool ForceSpray ( int client , int target , bool bPlaySound = true )
{
if ( ! IsValidClient ( target ) )
return false ;
float vecEndPos [ 3 ] ;
2016-05-10 12:57:25 +02:00
2016-05-08 02:46:46 +02:00
if ( TracePlayerAngles ( client , vecEndPos ) )
{
2016-12-02 12:55:09 +01:00
SprayClientDecalToAll ( target , g_iDecalEntity [ client ] , vecEndPos ) ;
2016-05-08 02:46:46 +02:00
if ( bPlaySound )
EmitSoundToAll ( " player/sprayer.wav " , SOUND_FROM_WORLD , SNDCHAN_AUTO , SNDLEVEL_NORMAL , SND_NOFLAGS , _ , _ , _ , vecEndPos ) ;
return true ;
}
PrintToChat ( client , " \x01 \x04 [SprayManager] \x01 Could not spray here, try somewhere else. " ) ;
return false ;
}
2016-12-02 12:55:09 +01:00
bool SprayClientDecalToAll ( int client , int iEntity , float vecOrigin [ 3 ] )
2016-05-08 02:46:46 +02:00
{
if ( ! IsValidClient ( client ) )
return false ;
TE_Start ( " Player Decal " ) ;
TE_WriteVector ( " m_vecOrigin " , vecOrigin ) ;
TE_WriteNum ( " m_nEntity " , iEntity ) ;
TE_WriteNum ( " m_nPlayer " , client ) ;
TE_SendToAll ( ) ;
return true ;
}
2016-12-02 12:55:09 +01:00
bool SprayClientDecalToOne ( int client , int target , int iEntity , float vecOrigin [ 3 ] )
{
if ( ! IsValidClient ( client ) )
return false ;
TE_Start ( " Player Decal " ) ;
TE_WriteVector ( " m_vecOrigin " , vecOrigin ) ;
TE_WriteNum ( " m_nEntity " , iEntity ) ;
TE_WriteNum ( " m_nPlayer " , client ) ;
TE_SendToClient ( target ) ;
return true ;
}
2016-05-08 02:46:46 +02:00
bool TracePlayerAngles ( int client , float vecResult [ 3 ] )
{
if ( ! IsValidClient ( client ) )
return false ;
float vecEyeAngles [ 3 ] ;
float vecEyeOrigin [ 3 ] ;
GetClientEyeAngles ( client , vecEyeAngles ) ;
GetClientEyePosition ( client , vecEyeOrigin ) ;
2016-11-19 21:09:30 +01:00
g_iDecalEntity [ client ] = 0 ;
Handle hTraceRay = TR_TraceRayFilterEx ( vecEyeOrigin , vecEyeAngles , MASK_SOLID_BRUSHONLY , RayType_Infinite , TraceEntityFilter_FilterPlayers ) ;
2016-05-08 02:46:46 +02:00
if ( TR_DidHit ( hTraceRay ) )
{
TR_GetEndPosition ( vecResult , hTraceRay ) ;
2016-11-19 21:09:30 +01:00
int iEntity ;
if ( ( iEntity = TR_GetEntityIndex ( hTraceRay ) ) > = 0 )
g_iDecalEntity [ client ] = iEntity ;
delete hTraceRay ;
2016-05-08 02:46:46 +02:00
return true ;
}
2016-11-19 21:09:30 +01:00
delete hTraceRay ;
2016-05-08 02:46:46 +02:00
return false ;
}
bool TracePlayerAnglesRanged ( int client , float fMaxDistance )
{
if ( ! IsValidClient ( client ) )
return false ;
float vecEyeAngles [ 3 ] ;
float vecEyeOrigin [ 3 ] ;
float vecDirection [ 3 ] ;
float vecEndPos [ 3 ] ;
GetClientEyeAngles ( client , vecEyeAngles ) ;
GetClientEyePosition ( client , vecEyeOrigin ) ;
GetAngleVectors ( vecEyeAngles , vecDirection , NULL_VECTOR , NULL_VECTOR ) ;
vecEndPos [ 0 ] = vecEyeOrigin [ 0 ] + ( vecDirection [ 0 ] * fMaxDistance ) ;
vecEndPos [ 1 ] = vecEyeOrigin [ 1 ] + ( vecDirection [ 1 ] * fMaxDistance ) ;
vecEndPos [ 2 ] = vecEyeOrigin [ 2 ] + ( vecDirection [ 2 ] * fMaxDistance ) ;
2016-11-19 21:09:30 +01:00
g_iDecalEntity [ client ] = 0 ;
Handle hTraceRay = TR_TraceRayFilterEx ( vecEyeOrigin , vecEndPos , MASK_SOLID_BRUSHONLY , RayType_EndPoint , TraceEntityFilter_FilterPlayers ) ;
2016-05-08 02:46:46 +02:00
if ( TR_DidHit ( hTraceRay ) )
{
2016-11-19 21:09:30 +01:00
delete hTraceRay ;
2016-05-08 02:46:46 +02:00
return true ;
}
2016-11-19 21:09:30 +01:00
delete hTraceRay ;
2016-05-08 02:46:46 +02:00
return false ;
}
void ClearPlayerInfo ( int client )
{
strcopy ( g_sBanIssuer [ client ] , sizeof ( g_sBanIssuer [ ] ) , " " ) ;
strcopy ( g_sBanIssuerSID [ client ] , sizeof ( g_sBanIssuerSID [ ] ) , " " ) ;
strcopy ( g_sBanReason [ client ] , sizeof ( g_sBanReason [ ] ) , " " ) ;
strcopy ( g_sSprayHash [ client ] , sizeof ( g_sSprayHash [ ] ) , " " ) ;
g_bSprayBanned [ client ] = false ;
g_bSprayHashBanned [ client ] = false ;
2016-12-02 12:55:09 +01:00
g_iClientSprayLifetime [ client ] = 2 ;
2016-05-10 12:57:25 +02:00
g_iSprayLifetime [ client ] = 0 ;
2016-12-02 12:55:09 +01:00
ResetClientToClientSprayLifeTime ( client ) ;
2016-05-08 02:46:46 +02:00
g_iSprayBanTimestamp [ client ] = 0 ;
g_iSprayUnbanTimestamp [ client ] = - 1 ;
g_fNextSprayTime [ client ] = 0.0 ;
2016-05-08 21:15:38 +02:00
g_vecSprayOrigin [ client ] = ACTUAL_NULL_VECTOR ;
2017-01-29 08:44:35 +01:00
g_SprayAABB [ client ] = view_as < float > ( { 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 } ) ; //???
2016-05-08 02:46:46 +02:00
}
2016-12-02 12:55:09 +01:00
void UpdateClientToClientSprayLifeTime ( int client , int iLifeTime )
{
for ( int i = 1 ; i < = MaxClients ; i + + )
{
g_iClientToClientSprayLifetime [ i ] [ client ] = iLifeTime ;
}
}
void ResetClientToClientSprayLifeTime ( int client )
{
for ( int i = 1 ; i < = MaxClients ; i + + )
{
g_iClientToClientSprayLifetime [ i ] [ client ] = 0 ;
g_iClientToClientSprayLifetime [ client ] [ i ] = 0 ;
}
}
2016-05-08 02:46:46 +02:00
void FormatRemainingTime ( int iTimestamp , char [ ] sBuffer , int iBuffSize )
{
if ( ! iTimestamp )
{
Format ( sBuffer , iBuffSize , " Permanent " ) ;
return ;
}
int tstamp = ( iTimestamp - GetTime ( ) ) ;
int days = ( tstamp / 86400 ) ;
int hours = ( ( tstamp / 3600 ) % 24 ) ;
int minutes = ( ( tstamp / 60 ) % 60 ) ;
int seconds = ( tstamp % 60 ) ;
if ( tstamp > 86400 )
{
Format ( sBuffer , iBuffSize , " %d %s, %d %s, %d %s, %d %s " , days , SingularOrMultiple ( days ) ? " Days " : " Day " ,
hours , SingularOrMultiple ( hours ) ? " Hours " : " Hour " , minutes , SingularOrMultiple ( minutes ) ? " Minutes " : " Minute " ,
seconds , SingularOrMultiple ( seconds ) ? " Seconds " : " Second " ) ;
}
else if ( tstamp > 3600 )
{
Format ( sBuffer , iBuffSize , " %d %s, %d %s, %d %s " , hours , SingularOrMultiple ( hours ) ? " Hours " : " Hour " ,
minutes , SingularOrMultiple ( minutes ) ? " Minutes " : " Minute " , seconds , SingularOrMultiple ( seconds ) ? " Seconds " : " Second " ) ;
}
else if ( tstamp > 60 )
{
Format ( sBuffer , iBuffSize , " %d %s, %d %s " , minutes , SingularOrMultiple ( minutes ) ? " Minutes " : " Minute " ,
seconds , SingularOrMultiple ( seconds ) ? " Seconds " : " Second " ) ;
}
else
2016-05-10 12:57:25 +02:00
Format ( sBuffer , iBuffSize , " %d %s " , seconds , SingularOrMultiple ( seconds ) ? " Seconds " : " Second " ) ;
2016-05-08 02:46:46 +02:00
}
bool IsPointInsideAABB ( float vecPoint [ 3 ] , float AABB [ 6 ] )
{
if ( vecPoint [ 0 ] > = AABB [ AABBMinX ] & & vecPoint [ 0 ] < = AABB [ AABBMaxX ] & &
vecPoint [ 1 ] > = AABB [ AABBMinY ] & & vecPoint [ 1 ] < = AABB [ AABBMaxY ] & &
vecPoint [ 2 ] > = AABB [ AABBMinZ ] & & vecPoint [ 2 ] < = AABB [ AABBMaxZ ] )
{
return true ;
}
return false ;
}
bool CheckForAABBCollision ( float AABB1 [ 6 ] , float AABB2 [ 6 ] )
{
if ( AABB1 [ AABBMinX ] > AABB2 [ AABBMaxX ] ) return false ;
if ( AABB1 [ AABBMinY ] > AABB2 [ AABBMaxY ] ) return false ;
if ( AABB1 [ AABBMinZ ] > AABB2 [ AABBMaxZ ] ) return false ;
if ( AABB1 [ AABBMaxX ] < AABB2 [ AABBMinX ] ) return false ;
if ( AABB1 [ AABBMaxY ] < AABB2 [ AABBMinY ] ) return false ;
if ( AABB1 [ AABBMaxZ ] < AABB2 [ AABBMinZ ] ) return false ;
return true ;
}
2016-12-02 12:55:09 +01:00
bool IsVectorZero ( float vecPos [ 3 ] )
2016-05-08 02:46:46 +02:00
{
return ( ( vecPos [ 0 ] = = 0.0 ) & & ( vecPos [ 1 ] = = 0.0 ) & & ( vecPos [ 2 ] = = 0.0 ) ) ;
}
2016-12-02 12:55:09 +01:00
bool SingularOrMultiple ( int num )
2016-05-08 02:46:46 +02:00
{
if ( ! num | | num > 1 )
return true ;
return false ;
}
2016-12-02 12:55:09 +01:00
bool TraceEntityFilter_FilterPlayers ( int entity , int contentsMask )
2016-05-08 02:46:46 +02:00
{
2016-11-19 21:09:30 +01:00
return entity > MaxClients ;
2016-05-08 02:46:46 +02:00
}
2016-12-02 12:55:09 +01:00
bool IsValidClient ( int client )
2016-05-08 02:46:46 +02:00
{
if ( client < = 0 | | client > MaxClients | | ! IsClientInGame ( client ) )
return false ;
return IsClientAuthorized ( client ) ;
}