199 lines
4.2 KiB
SourcePawn
199 lines
4.2 KiB
SourcePawn
|
#pragma semicolon 1
|
||
|
|
||
|
#include <sourcemod>
|
||
|
#include <sdktools>
|
||
|
#include <zombiereloaded>
|
||
|
#include <cstrike>
|
||
|
|
||
|
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;
|
||
|
|
||
|
int g_iZombieStreak;
|
||
|
|
||
|
bool g_bLowPopulation;
|
||
|
int g_iMaxPopulation;
|
||
|
float g_fKnockbackBoost;
|
||
|
|
||
|
ConVar g_cvNapalmScale;
|
||
|
float g_fNapalmScale;
|
||
|
|
||
|
public Plugin myinfo =
|
||
|
{
|
||
|
name = "AntiNoob",
|
||
|
author = "Dogan",
|
||
|
description = "Provide help when the server is doing bad on a map",
|
||
|
version = "2.0.0",
|
||
|
url = ""
|
||
|
}
|
||
|
|
||
|
public void OnPluginStart()
|
||
|
{
|
||
|
g_iHighRatio = 7;
|
||
|
g_iMediumRatio = 5;
|
||
|
g_iLowRatio = 3;
|
||
|
|
||
|
g_iHighStreak = 6;
|
||
|
g_iMediumStreak = 4;
|
||
|
g_iLowStreak = 2;
|
||
|
|
||
|
HookEvent("round_start", OnRoundStart);
|
||
|
|
||
|
ConVar cvar;
|
||
|
HookConVarChange((cvar = CreateConVar("sm_an_maxplayers", "40", "max active players until the kb should be increased")), g_cvMaxPopulation);
|
||
|
g_iMaxPopulation = cvar.IntValue;
|
||
|
HookConVarChange((cvar = CreateConVar("sm_an_kb", "5.0", "knockback boost during low population in procent")), g_cvKnockbackBoost);
|
||
|
g_fKnockbackBoost = cvar.FloatValue / 100.0;
|
||
|
delete cvar;
|
||
|
|
||
|
AutoExecConfig(true, "plugin.AntiNoob");
|
||
|
}
|
||
|
|
||
|
public void g_cvMaxPopulation(ConVar convar, const char[] oldValue, const char[] newValue)
|
||
|
{
|
||
|
g_iMaxPopulation = convar.IntValue;
|
||
|
}
|
||
|
|
||
|
public void g_cvKnockbackBoost(ConVar convar, const char[] oldValue, const char[] newValue)
|
||
|
{
|
||
|
g_fKnockbackBoost = convar.FloatValue / 100.0;
|
||
|
}
|
||
|
|
||
|
public void OnAllPluginsLoaded()
|
||
|
{
|
||
|
g_cvNapalmScale = FindConVar("zr_napalm_time_scale");
|
||
|
}
|
||
|
|
||
|
public void OnMapStart()
|
||
|
{
|
||
|
g_iHumanScore = 1;
|
||
|
g_iZombieScore = 0;
|
||
|
g_iOldZombieScore = 0;
|
||
|
g_iZombieStreak = 0;
|
||
|
}
|
||
|
|
||
|
public void OnConfigsExecuted()
|
||
|
{
|
||
|
g_fNapalmScale = g_cvNapalmScale.FloatValue;
|
||
|
}
|
||
|
|
||
|
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++)
|
||
|
{
|
||
|
if(IsClientInGame(i) && !IsFakeClient(i) && GetClientTeam(i) != CS_TEAM_SPECTATOR)
|
||
|
{
|
||
|
ActivePlayers++;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if(ActivePlayers <= g_iMaxPopulation)
|
||
|
{
|
||
|
g_bLowPopulation = true;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
g_bLowPopulation = false;
|
||
|
}
|
||
|
|
||
|
if(g_iZombieScore / g_iHumanScore >= g_iHighRatio || g_iZombieStreak >= g_iHighStreak)
|
||
|
{
|
||
|
PerformHighHelp();
|
||
|
}
|
||
|
else if(g_iZombieScore / g_iHumanScore >= g_iMediumRatio || g_iZombieStreak >= g_iMediumStreak)
|
||
|
{
|
||
|
PerformMediumHelp();
|
||
|
}
|
||
|
else if(g_iZombieScore / g_iHumanScore >= g_iLowRatio || g_iZombieStreak >= g_iLowStreak)
|
||
|
{
|
||
|
PerformLowHelp();
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
PerformReset();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public void PerformHighHelp()
|
||
|
{
|
||
|
if(g_bLowPopulation)
|
||
|
{
|
||
|
ServerCommand("zr_class_set_multiplier zombies knockback %f", 1.15 + g_fKnockbackBoost);
|
||
|
ServerCommand("zr_napalm_time_scale %f", g_fNapalmScale - 8.0);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
ServerCommand("zr_class_set_multiplier zombies knockback 1.15");
|
||
|
ServerCommand("zr_napalm_time_scale %f", g_fNapalmScale - 6.0);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public void PerformMediumHelp()
|
||
|
{
|
||
|
if(g_bLowPopulation)
|
||
|
{
|
||
|
ServerCommand("zr_class_set_multiplier zombies knockback %f", 1.1 + g_fKnockbackBoost);
|
||
|
ServerCommand("zr_napalm_time_scale %f", g_fNapalmScale - 6.0);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
ServerCommand("zr_class_set_multiplier zombies knockback 1.1");
|
||
|
ServerCommand("zr_napalm_time_scale %f", g_fNapalmScale - 4.0);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public void PerformLowHelp()
|
||
|
{
|
||
|
if(g_bLowPopulation)
|
||
|
{
|
||
|
ServerCommand("zr_class_set_multiplier zombies knockback %f", 1.05 + g_fKnockbackBoost);
|
||
|
ServerCommand("zr_napalm_time_scale %f", g_fNapalmScale - 4.0);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
ServerCommand("zr_class_set_multiplier zombies knockback 1.05");
|
||
|
ServerCommand("zr_napalm_time_scale %f", g_fNapalmScale - 2.0);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public void PerformReset()
|
||
|
{
|
||
|
if(g_bLowPopulation)
|
||
|
{
|
||
|
ServerCommand("zr_class_set_multiplier zombies knockback %f", 1.0 + g_fKnockbackBoost);
|
||
|
ServerCommand("zr_napalm_time_scale %f", g_fNapalmScale - 2.0);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
ServerCommand("zr_class_set_multiplier zombies knockback 1.0");
|
||
|
ServerCommand("zr_napalm_time_scale %f", g_fNapalmScale);
|
||
|
}
|
||
|
}
|