2019-07-25 00:28:59 +02:00
# pragma semicolon 1
# include <sourcemod>
# include <sdktools>
# include <zombiereloaded>
# include <cstrike>
2019-08-09 22:01:47 +02:00
# include <multicolors>
2019-07-25 00:28:59 +02:00
int g_iHighRatio ;
int g_iMediumRatio ;
int g_iLowRatio ;
int g_iHighStreak ;
int g_iMediumStreak ;
int g_iLowStreak ;
int g_iHumanScore ;
int g_iZombieScore ;
int g_iOldZombieScore ;
2019-08-09 22:01:47 +02:00
float g_fKnockbackLowBoost ;
float g_fKnockbackMediumBoost ;
float g_fKnockbackHighBoost ;
float g_fNapalmLowReduction ;
float g_fNapalmMediumReduction ;
float g_fNapalmHighReduction ;
2019-07-25 00:28:59 +02:00
int g_iZombieStreak ;
bool g_bLowPopulation ;
int g_iMaxPopulation ;
2019-08-09 22:01:47 +02:00
float g_fKnockbackPopulationBoost ;
float g_fNapalmPopulationReduction ;
2019-07-25 00:28:59 +02:00
2019-08-09 22:01:47 +02:00
int g_iAntiNoob ;
char g_cAntiNoobHelp [ 64 ] ;
char g_cAntiNoobPopulation [ 32 ] ;
2019-07-25 00:28:59 +02:00
public Plugin myinfo =
{
name = " AntiNoob " ,
author = " Dogan " ,
description = " Provide help when the server is doing bad on a map " ,
2019-08-09 22:01:47 +02:00
version = " 3.0.0 " ,
2019-07-25 00:28:59 +02:00
url = " "
}
public void OnPluginStart ( )
{
HookEvent ( " round_start " , OnRoundStart ) ;
ConVar cvar ;
2019-08-09 22:01:47 +02:00
HookConVarChange ( ( cvar = CreateConVar ( " sm_an_help " , " 1 " , " 1 = AntiNoob performs help, 0 = AntiNoob is disabled " , FCVAR_NONE , true , 0.0 , true , 1.0 ) ) , g_cvAntiNoob ) ;
g_iAntiNoob = cvar . IntValue ;
2019-07-25 00:28:59 +02:00
HookConVarChange ( ( cvar = CreateConVar ( " sm_an_maxplayers " , " 40 " , " max active players until the kb should be increased " ) ) , g_cvMaxPopulation ) ;
g_iMaxPopulation = cvar . IntValue ;
2019-08-09 22:01:47 +02:00
HookConVarChange ( ( cvar = CreateConVar ( " sm_an_kb_population " , " 5.0 " , " knockback boost during low population in procent (stacks with the helps) " ) ) , g_cvKnockbackPopulationBoost ) ;
g_fKnockbackPopulationBoost = cvar . FloatValue / 100.0 ;
HookConVarChange ( ( cvar = CreateConVar ( " sm_an_napalm_population " , " 2.0 " , " napalm damage reduction needed during low population for full burn from nades (stacks with the helps) " ) ) , g_cvNapalmPopulationReduction ) ;
g_fNapalmPopulationReduction = cvar . FloatValue ;
HookConVarChange ( ( cvar = CreateConVar ( " sm_an_lowratio " , " 3 " , " human:zombie ratio to perform low help " ) ) , g_cvLowRatio ) ;
g_iLowRatio = cvar . IntValue ;
HookConVarChange ( ( cvar = CreateConVar ( " sm_an_mediumratio " , " 5 " , " human:zombie ratio to perform medium help " ) ) , g_cvMediumRatio ) ;
g_iMediumRatio = cvar . IntValue ;
HookConVarChange ( ( cvar = CreateConVar ( " sm_an_highratio " , " 7 " , " human:zombie ratio to perform high help " ) ) , g_cvHighRatio ) ;
g_iHighRatio = cvar . IntValue ;
HookConVarChange ( ( cvar = CreateConVar ( " sm_an_lowstreak " , " 2 " , " zombie win streaks to perfom low help " ) ) , g_cvLowStreak ) ;
g_iLowStreak = cvar . IntValue ;
HookConVarChange ( ( cvar = CreateConVar ( " sm_an_mediumstreak " , " 4 " , " zombie win streaks to perfom medium help " ) ) , g_cvMediumStreak ) ;
g_iMediumStreak = cvar . IntValue ;
HookConVarChange ( ( cvar = CreateConVar ( " sm_an_highstreak " , " 6 " , " zombie win streaks to perfom high help " ) ) , g_cvHighStreak ) ;
g_iHighStreak = cvar . IntValue ;
HookConVarChange ( ( cvar = CreateConVar ( " sm_an_kb_lowhelp " , " 5.0 " , " knockback boost in procent when low help is performed (stacks with low population boost) " ) ) , g_cvKnockbackLowBoost ) ;
g_fKnockbackLowBoost = cvar . FloatValue / 100.0 ;
HookConVarChange ( ( cvar = CreateConVar ( " sm_an_kb_mediumhelp " , " 10.0 " , " knockback boost in procent when medium help is performed (stacks with low population boost) " ) ) , g_cvKnockbackMediumBoost ) ;
g_fKnockbackMediumBoost = cvar . FloatValue / 100.0 ;
HookConVarChange ( ( cvar = CreateConVar ( " sm_an_kb_highhelp " , " 15.0 " , " knockback boost in procent when high help is performed (stacks with low population boost) " ) ) , g_cvKnockbackHighBoost ) ;
g_fKnockbackHighBoost = cvar . FloatValue / 100.0 ;
HookConVarChange ( ( cvar = CreateConVar ( " sm_an_napalm_lowhelp " , " 2.0 " , " napalm damage reduction needed when low help is perfomed for full burn from nades (stacks with low population reduction) " ) ) , g_cvNapalmLowReduction ) ;
g_fNapalmLowReduction = cvar . FloatValue ;
HookConVarChange ( ( cvar = CreateConVar ( " sm_an_napalm_mediumhelp " , " 4.0 " , " napalm damage reduction needed when medium help is performed for full burn from nades (stacks with low population reduction) " ) ) , g_cvNapalmMediumReduction ) ;
g_fNapalmMediumReduction = cvar . FloatValue ;
HookConVarChange ( ( cvar = CreateConVar ( " sm_an_napalm_highhelp " , " 6.0 " , " napalm damage reduction needed when high help is perfomed for full burn from nades (stacks with low population reduction) " ) ) , g_cvNapalmHighReduction ) ;
g_fNapalmHighReduction = cvar . FloatValue ;
CloseHandle ( cvar ) ;
g_cAntiNoobHelp = " {cyan}[AntiNoob]{white} Plugin still loading " ;
g_cAntiNoobPopulation = " {white}. " ;
RegAdminCmd ( " sm_antinoob " , Command_AntiNoob , ADMFLAG_RCON , " returns the current helps or boosts for this round " ) ;
2019-07-25 00:28:59 +02:00
AutoExecConfig ( true , " plugin.AntiNoob " ) ;
}
2019-08-09 22:01:47 +02:00
public void g_cvAntiNoob ( ConVar convar , const char [ ] oldValue , const char [ ] newValue )
{
g_iAntiNoob = convar . IntValue ;
}
2019-07-25 00:28:59 +02:00
public void g_cvMaxPopulation ( ConVar convar , const char [ ] oldValue , const char [ ] newValue )
{
g_iMaxPopulation = convar . IntValue ;
}
2019-08-09 22:01:47 +02:00
public void g_cvKnockbackPopulationBoost ( ConVar convar , const char [ ] oldValue , const char [ ] newValue )
{
g_fKnockbackPopulationBoost = convar . FloatValue / 100.0 ;
}
public void g_cvNapalmPopulationReduction ( ConVar convar , const char [ ] oldValue , const char [ ] newValue )
{
g_fNapalmPopulationReduction = convar . FloatValue ;
}
public void g_cvLowRatio ( ConVar convar , const char [ ] oldValue , const char [ ] newValue )
{
g_iLowRatio = convar . IntValue ;
}
public void g_cvMediumRatio ( ConVar convar , const char [ ] oldValue , const char [ ] newValue )
{
g_iMediumRatio = convar . IntValue ;
}
public void g_cvHighRatio ( ConVar convar , const char [ ] oldValue , const char [ ] newValue )
{
g_iHighRatio = convar . IntValue ;
}
public void g_cvLowStreak ( ConVar convar , const char [ ] oldValue , const char [ ] newValue )
{
g_iLowStreak = convar . IntValue ;
}
public void g_cvMediumStreak ( ConVar convar , const char [ ] oldValue , const char [ ] newValue )
{
g_iMediumStreak = convar . IntValue ;
}
public void g_cvHighStreak ( ConVar convar , const char [ ] oldValue , const char [ ] newValue )
{
g_iHighStreak = convar . IntValue ;
}
public void g_cvKnockbackLowBoost ( ConVar convar , const char [ ] oldValue , const char [ ] newValue )
{
g_fKnockbackLowBoost = convar . FloatValue / 100.0 ;
}
public void g_cvKnockbackMediumBoost ( ConVar convar , const char [ ] oldValue , const char [ ] newValue )
{
g_fKnockbackMediumBoost = convar . FloatValue / 100.0 ;
}
public void g_cvKnockbackHighBoost ( ConVar convar , const char [ ] oldValue , const char [ ] newValue )
2019-07-25 00:28:59 +02:00
{
2019-08-09 22:01:47 +02:00
g_fKnockbackHighBoost = convar . FloatValue / 100.0 ;
2019-07-25 00:28:59 +02:00
}
2019-08-09 22:01:47 +02:00
public void g_cvNapalmLowReduction ( ConVar convar , const char [ ] oldValue , const char [ ] newValue )
2019-07-25 00:28:59 +02:00
{
2019-08-09 22:01:47 +02:00
g_fNapalmLowReduction = convar . FloatValue ;
}
public void g_cvNapalmMediumReduction ( ConVar convar , const char [ ] oldValue , const char [ ] newValue )
{
g_fNapalmMediumReduction = convar . FloatValue ;
}
public void g_cvNapalmHighReduction ( ConVar convar , const char [ ] oldValue , const char [ ] newValue )
{
g_fNapalmHighReduction = convar . FloatValue ;
2019-07-25 00:28:59 +02:00
}
public void OnMapStart ( )
{
g_iHumanScore = 1 ;
g_iZombieScore = 0 ;
g_iOldZombieScore = 0 ;
g_iZombieStreak = 0 ;
}
2019-08-09 22:01:47 +02:00
public Action Command_AntiNoob ( int client , int args )
2019-07-25 00:28:59 +02:00
{
2019-08-09 22:01:47 +02:00
CPrintToChat ( client , " %s%s " , g_cAntiNoobHelp , g_cAntiNoobPopulation ) ;
return Plugin_Handled ;
2019-07-25 00:28:59 +02:00
}
public void OnRoundStart ( Event hEvent , const char [ ] sEvent , bool bDontBroadcast )
{
g_iHumanScore = GetTeamScore ( CS_TEAM_CT ) ;
g_iZombieScore = GetTeamScore ( CS_TEAM_T ) ;
if ( g_iHumanScore = = 0 )
{
g_iHumanScore = 1 ;
}
if ( g_iZombieScore ! = g_iOldZombieScore )
{
g_iZombieStreak + + ;
g_iOldZombieScore + + ;
}
else
{
g_iZombieStreak = 0 ;
}
int ActivePlayers ;
for ( int i = 1 ; i < = MaxClients ; i + + )
{
2019-09-30 14:17:23 +02:00
if ( IsClientInGame ( i ) & & ! IsFakeClient ( i ) & & GetClientTeam ( i ) > 0 )
2019-07-25 00:28:59 +02:00
{
ActivePlayers + + ;
}
}
2019-08-09 22:01:47 +02:00
if ( g_iAntiNoob = = 0 )
{
g_cAntiNoobHelp = " {cyan}[AntiNoob]{white} Currently disabled " ;
g_cAntiNoobPopulation = " {white}. " ;
PerformReset ( ) ;
for ( int i = 1 ; i < = MaxClients ; i + + )
{
if ( IsRootAdmin ( i ) )
CPrintToChat ( i , " %s%s " , g_cAntiNoobHelp , g_cAntiNoobPopulation ) ;
}
return ;
}
2019-07-25 00:28:59 +02:00
if ( ActivePlayers < = g_iMaxPopulation )
{
g_bLowPopulation = true ;
2019-08-09 22:01:47 +02:00
g_cAntiNoobPopulation = " {white} + Low Population Boost. " ;
2019-07-25 00:28:59 +02:00
}
else
{
g_bLowPopulation = false ;
2019-08-09 22:01:47 +02:00
g_cAntiNoobPopulation = " {white}. " ;
2019-07-25 00:28:59 +02:00
}
if ( g_iZombieScore / g_iHumanScore > = g_iHighRatio | | g_iZombieStreak > = g_iHighStreak )
{
2019-08-09 22:01:47 +02:00
g_cAntiNoobHelp = " {cyan}[AntiNoob]{white} Currently perfoming High Help " ;
2019-07-25 00:28:59 +02:00
PerformHighHelp ( ) ;
}
else if ( g_iZombieScore / g_iHumanScore > = g_iMediumRatio | | g_iZombieStreak > = g_iMediumStreak )
{
2019-08-09 22:01:47 +02:00
g_cAntiNoobHelp = " {cyan}[AntiNoob]{white} Currently perfoming Medium Help " ;
2019-07-25 00:28:59 +02:00
PerformMediumHelp ( ) ;
}
else if ( g_iZombieScore / g_iHumanScore > = g_iLowRatio | | g_iZombieStreak > = g_iLowStreak )
{
2019-08-09 22:01:47 +02:00
g_cAntiNoobHelp = " {cyan}[AntiNoob]{white} Currently perfoming Low Help " ;
2019-07-25 00:28:59 +02:00
PerformLowHelp ( ) ;
}
else
{
2019-08-09 22:01:47 +02:00
g_cAntiNoobHelp = " {cyan}[AntiNoob]{white} Currently perfoming No Help " ;
2019-07-25 00:28:59 +02:00
PerformReset ( ) ;
}
2019-08-09 22:01:47 +02:00
for ( int i = 1 ; i < = MaxClients ; i + + )
{
if ( IsRootAdmin ( i ) )
CPrintToChat ( i , " %s%s " , g_cAntiNoobHelp , g_cAntiNoobPopulation ) ;
}
2019-07-25 00:28:59 +02:00
}
public void PerformHighHelp ( )
{
if ( g_bLowPopulation )
{
2019-08-09 22:01:47 +02:00
ServerCommand ( " zr_class_set_multiplier zombies knockback %f " , 1.0 + g_fKnockbackHighBoost + g_fKnockbackPopulationBoost ) ;
ServerCommand ( " zr_napalm_time_scale %f " , 50.0 - g_fNapalmHighReduction - g_fNapalmPopulationReduction ) ;
2019-07-25 00:28:59 +02:00
}
else
{
2019-08-09 22:01:47 +02:00
ServerCommand ( " zr_class_set_multiplier zombies knockback %f " , 1.0 + g_fKnockbackHighBoost ) ;
ServerCommand ( " zr_napalm_time_scale %f " , 50.0 - g_fNapalmHighReduction ) ;
2019-07-25 00:28:59 +02:00
}
}
public void PerformMediumHelp ( )
{
if ( g_bLowPopulation )
{
2019-08-09 22:01:47 +02:00
ServerCommand ( " zr_class_set_multiplier zombies knockback %f " , 1.0 + g_fKnockbackMediumBoost + g_fKnockbackPopulationBoost ) ;
ServerCommand ( " zr_napalm_time_scale %f " , 50.0 - g_fNapalmMediumReduction - g_fNapalmPopulationReduction ) ;
2019-07-25 00:28:59 +02:00
}
else
{
2019-08-09 22:01:47 +02:00
ServerCommand ( " zr_class_set_multiplier zombies knockback %f " , 1.0 + g_fKnockbackMediumBoost ) ;
ServerCommand ( " zr_napalm_time_scale %f " , 50.0 - g_fNapalmMediumReduction ) ;
2019-07-25 00:28:59 +02:00
}
}
public void PerformLowHelp ( )
{
if ( g_bLowPopulation )
{
2019-08-09 22:01:47 +02:00
ServerCommand ( " zr_class_set_multiplier zombies knockback %f " , 1.0 + g_fKnockbackLowBoost + g_fKnockbackPopulationBoost ) ;
ServerCommand ( " zr_napalm_time_scale %f " , 50.0 - g_fNapalmLowReduction - g_fNapalmPopulationReduction ) ;
2019-07-25 00:28:59 +02:00
}
else
{
2019-08-09 22:01:47 +02:00
ServerCommand ( " zr_class_set_multiplier zombies knockback %f " , 1.0 + g_fKnockbackLowBoost ) ;
ServerCommand ( " zr_napalm_time_scale %f " , 50.0 - g_fNapalmLowReduction ) ;
2019-07-25 00:28:59 +02:00
}
}
public void PerformReset ( )
{
2019-08-09 22:01:47 +02:00
if ( g_bLowPopulation & & g_iAntiNoob ! = 0 )
2019-07-25 00:28:59 +02:00
{
2019-08-09 22:01:47 +02:00
ServerCommand ( " zr_class_set_multiplier zombies knockback %f " , 1.0 + g_fKnockbackPopulationBoost ) ;
ServerCommand ( " zr_napalm_time_scale %f " , 50.0 - g_fNapalmPopulationReduction ) ;
2019-07-25 00:28:59 +02:00
}
else
{
ServerCommand ( " zr_class_set_multiplier zombies knockback 1.0 " ) ;
2019-08-09 22:01:47 +02:00
ServerCommand ( " zr_napalm_time_scale 50.0 " ) ;
2019-07-25 00:28:59 +02:00
}
2019-08-09 22:01:47 +02:00
}
static stock bool IsRootAdmin ( int client )
{
if ( client > 0 & & client < = MaxClients & & IsClientInGame ( client ) & & CheckCommandAccess ( client , " " , ADMFLAG_RCON ) )
return true ;
else
return false ;
2019-07-25 00:28:59 +02:00
}