#pragma semicolon 1 #include #include #include #include #include #include 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; float g_fKnockbackLowBoost; float g_fKnockbackMediumBoost; float g_fKnockbackHighBoost; float g_fNapalmLowReduction; float g_fNapalmMediumReduction; float g_fNapalmHighReduction; bool g_bLowPopulation; int g_iMaxPopulation; float g_fKnockbackPopulationBoost; float g_fNapalmPopulationReduction; bool g_bMidRound; float g_fKnockbackMidRoundBoost; float g_fNapalmMidRoundReduction; float g_fMidRoundRatio; bool g_bNoSteam; float g_fKnockbackNoSteamBoost; float g_fNapalmNoSteamReduction; float g_fNoSteamRatio; bool g_bAntiNoob; float g_fCurrentKnockbackBoost; float g_fCurrentNapalmDamage; public Plugin myinfo = { name = "AntiNoob", author = "Dogan", description = "Provide help when the server is doing bad on a map", version = "5.0.0", url = "" } public void OnPluginStart() { HookEvent("round_start", OnRoundStart); HookEvent("player_team", OnPlayerTeam); g_fCurrentKnockbackBoost = 1.0; g_fCurrentNapalmDamage = 50.0; ConVar cvar; 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_bAntiNoob = cvar.BoolValue; 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_population", "5.0", "knockback boost during low population in procent (stacking)")), 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 (stacking)")), g_cvNapalmPopulationReduction); g_fNapalmPopulationReduction = cvar.FloatValue; HookConVarChange((cvar = CreateConVar("sm_an_lowratio", "3", "human:zombie score ratio to perform low help, x = zombie")), g_cvLowRatio); g_iLowRatio = cvar.IntValue; HookConVarChange((cvar = CreateConVar("sm_an_mediumratio", "5", "human:zombie score ratio to perform medium help, x = zombie")), g_cvMediumRatio); g_iMediumRatio = cvar.IntValue; HookConVarChange((cvar = CreateConVar("sm_an_highratio", "7", "human:zombie score ratio to perform high help, x = zombie")), 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 (stacking)")), 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 (stacking)")), 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 (stacking)")), 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 (stacking)")), 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 (stacking)")), 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 (stacking)")), g_cvNapalmHighReduction); g_fNapalmHighReduction = cvar.FloatValue; HookConVarChange((cvar = CreateConVar("sm_an_napalm_midround", "1.0", "napalm damage reduction needed when mid round help is performed for full burn from nades (stacking)")), g_cvNapalmMidRoundReduction); g_fNapalmMidRoundReduction = cvar.FloatValue; HookConVarChange((cvar = CreateConVar("sm_an_kb_midround", "2.5", "knockback boost in procent when mid round help is performed (stacking)")), g_cvKnockbackMidRoundBoost); g_fKnockbackMidRoundBoost = cvar.FloatValue / 100.0; HookConVarChange((cvar = CreateConVar("sm_an_midroundratio", "1.20", "zombie ratio in relation to humans to perform mid round help")), g_cvMidRoundRatio); g_fMidRoundRatio = cvar.FloatValue; HookConVarChange((cvar = CreateConVar("sm_an_napalm_nosteam", "1.0", "napalm damage reduction needed when nosteam help is performed for full burn from nades (stacking)")), g_cvNapalmNoSteamReduction); g_fNapalmNoSteamReduction = cvar.FloatValue; HookConVarChange((cvar = CreateConVar("sm_an_kb_nosteam", "2.5", "knockback boost in procent when nosteam help is performed (stacking)")), g_cvKnockbackNoSteamBoost); g_fKnockbackNoSteamBoost = cvar.FloatValue / 100.0; HookConVarChange((cvar = CreateConVar("sm_an_nosteamratio", "0.25", "nosteam ratio in relation to server population to perform nosteam help")), g_cvNoSteamRatio); g_fNoSteamRatio = cvar.FloatValue; delete cvar; RegAdminCmd("sm_antinoob", Command_AntiNoob, ADMFLAG_GENERIC, "returns the current helps or boosts for this round"); AutoExecConfig(true, "plugin.AntiNoob"); } public void OnPluginEnd() { ServerCommand("zr_class_set_multiplier zombies knockback 1.0"); ServerCommand("zr_napalm_time_scale 50.0"); } public void g_cvAntiNoob(ConVar convar, const char[] oldValue, const char[] newValue) { g_bAntiNoob = convar.BoolValue; } public void g_cvMaxPopulation(ConVar convar, const char[] oldValue, const char[] newValue) { g_iMaxPopulation = convar.IntValue; } 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) { g_fKnockbackHighBoost = convar.FloatValue / 100.0; } public void g_cvNapalmLowReduction(ConVar convar, const char[] oldValue, const char[] newValue) { 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; } public void g_cvNapalmMidRoundReduction(ConVar convar, const char[] oldValue, const char[] newValue) { g_fNapalmMidRoundReduction = convar.FloatValue; } public void g_cvKnockbackMidRoundBoost(ConVar convar, const char[] oldValue, const char[] newValue) { g_fKnockbackMidRoundBoost = convar.FloatValue / 100.0; } public void g_cvMidRoundRatio(ConVar convar, const char[] oldValue, const char[] newValue) { g_fMidRoundRatio = convar.FloatValue; } public void g_cvNapalmNoSteamReduction(ConVar convar, const char[] oldValue, const char[] newValue) { g_fNapalmNoSteamReduction = convar.FloatValue; } public void g_cvKnockbackNoSteamBoost(ConVar convar, const char[] oldValue, const char[] newValue) { g_fKnockbackNoSteamBoost = convar.FloatValue / 100.0; } public void g_cvNoSteamRatio(ConVar convar, const char[] oldValue, const char[] newValue) { g_fNoSteamRatio = convar.FloatValue; } public void OnMapStart() { g_iHumanScore = 1; g_iZombieScore = 0; g_iOldZombieScore = 0; g_iZombieStreak = 0; } public Action Command_AntiNoob(int client, int args) { char cAdminNotification[128] = "{cyan}[AntiNoob]{white} Currently disabled."; if(!g_bAntiNoob) { CPrintToChat(client, "%s", cAdminNotification); return Plugin_Handled; } Format(cAdminNotification, sizeof(cAdminNotification), "{cyan}[AntiNoob]{white} Currently boosting knockback by {red}%.2f%%{white}.", ((g_fCurrentKnockbackBoost - 1.0) * 100.0)); if(g_bLowPopulation) CPrintToChat(client, "{cyan}[AntiNoob]{white} Low Population detected."); if(g_bNoSteam) CPrintToChat(client, "{cyan}[AntiNoob]{white} Large Amount of No-Steam Players detected."); CPrintToChat(client, "%s", cAdminNotification); return Plugin_Handled; } public void OnPlayerTeam(Event event, const char[] name, bool dontBroadcast) { RequestFrame(RequestFrame_Callback); } public void OnClientDisconnect(int client) { RequestFrame(RequestFrame_Callback); } public void RequestFrame_Callback(int iPacked) { CheckHumanZombieCount(); } public void CheckHumanZombieCount() { if(g_bMidRound || !g_bAntiNoob) return; int iHumanCount; int iZombieCount; for(int i = 1; i <= MaxClients; i++) { if(!IsClientInGame(i) || !IsPlayerAlive(i)) continue; if(GetClientTeam(i) == CS_TEAM_CT) iHumanCount++; if(GetClientTeam(i) == CS_TEAM_T) iZombieCount++; } if(iHumanCount == 0 || iZombieCount == 0) return; if(float(iZombieCount) / float(iHumanCount) >= g_fMidRoundRatio) { g_bMidRound = true; g_fCurrentKnockbackBoost = g_fCurrentKnockbackBoost + g_fKnockbackMidRoundBoost; g_fCurrentNapalmDamage = g_fCurrentNapalmDamage - g_fNapalmMidRoundReduction; ServerCommand("zr_class_set_multiplier zombies knockback %f", g_fCurrentKnockbackBoost); ServerCommand("zr_napalm_time_scale %f", g_fCurrentNapalmDamage); for(int i = 1; i <= MaxClients; i++) { if(IsAdmin(i)) CPrintToChat(i, "{cyan}[AntiNoob]{white} Large Amount of Zombies detected."); } } } public void OnRoundStart(Event hEvent, const char[] sEvent, bool bDontBroadcast) { g_iHumanScore = GetTeamScore(CS_TEAM_CT); g_iZombieScore = GetTeamScore(CS_TEAM_T); g_bMidRound = false; if(g_iHumanScore == 0) g_iHumanScore = 1; if(g_iZombieScore != g_iOldZombieScore) { g_iZombieStreak++; g_iOldZombieScore++; } else { g_iZombieStreak = 0; } int iActivePlayers; int iActiveSteamPlayers; int iActiveNoSteamPlayers; for(int i = 1; i <= MaxClients; i++) { if(!IsClientInGame(i) || IsFakeClient(i) || GetClientTeam(i) <= CS_TEAM_T) continue; iActivePlayers++; if(PM_IsPlayerSteam(i)) iActiveSteamPlayers++; else iActiveNoSteamPlayers++; } if(iActiveSteamPlayers == 0) iActiveSteamPlayers = 1; char cAdminNotification[128] = "{cyan}[AntiNoob]{white} Currently disabled."; if(!g_bAntiNoob) { PerformReset(); for(int i = 1; i <= MaxClients; i++) { if(IsAdmin(i)) CPrintToChat(i,"%s", cAdminNotification); } return; } if(iActivePlayers <= g_iMaxPopulation) g_bLowPopulation = true; else g_bLowPopulation = false; if((float(iActiveNoSteamPlayers) / float(iActiveSteamPlayers)) >= g_fNoSteamRatio) g_bNoSteam = true; else g_bNoSteam = 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(); Format(cAdminNotification, sizeof(cAdminNotification), "{cyan}[AntiNoob]{white} Starting to boost this round by {red}%.2f%%{white} knockback increase.", ((g_fCurrentKnockbackBoost - 1.0) * 100.0)); for(int i = 1; i <= MaxClients; i++) { if(!IsAdmin(i)) continue; if(g_bLowPopulation) CPrintToChat(i, "{cyan}[AntiNoob]{white} Low Population detected."); if(g_bNoSteam) CPrintToChat(i, "{cyan}[AntiNoob]{white} Large Amount of No-Steam Players detected."); if(g_bMidRound) CPrintToChat(i, "{cyan}[AntiNoob]{white} Large Amount of Zombies detected."); CPrintToChat(i,"%s", cAdminNotification); } } public void PerformHighHelp() { if(g_bNoSteam && g_bLowPopulation) { ServerCommand("zr_class_set_multiplier zombies knockback %f", 1.0 + g_fKnockbackHighBoost + g_fKnockbackPopulationBoost + g_fKnockbackNoSteamBoost); ServerCommand("zr_napalm_time_scale %f", 50.0 - g_fNapalmHighReduction - g_fNapalmPopulationReduction - g_fNapalmNoSteamReduction); g_fCurrentKnockbackBoost = 1.0 + g_fKnockbackHighBoost + g_fKnockbackPopulationBoost + g_fKnockbackNoSteamBoost; g_fCurrentNapalmDamage = 50.0 - g_fNapalmHighReduction - g_fNapalmPopulationReduction - g_fNapalmNoSteamReduction; } else if(g_bLowPopulation) { 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); g_fCurrentKnockbackBoost = 1.0 + g_fKnockbackHighBoost + g_fKnockbackPopulationBoost; g_fCurrentNapalmDamage = 50.0 - g_fNapalmHighReduction - g_fNapalmPopulationReduction; } else if(g_bNoSteam) { ServerCommand("zr_class_set_multiplier zombies knockback %f", 1.0 + g_fKnockbackHighBoost + g_fKnockbackNoSteamBoost); ServerCommand("zr_napalm_time_scale %f", 50.0 - g_fNapalmHighReduction - g_fNapalmNoSteamReduction); g_fCurrentKnockbackBoost = 1.0 + g_fKnockbackHighBoost + g_fKnockbackNoSteamBoost; g_fCurrentNapalmDamage = 50.0 - g_fNapalmHighReduction - g_fNapalmNoSteamReduction; } else { ServerCommand("zr_class_set_multiplier zombies knockback %f", 1.0 + g_fKnockbackHighBoost); ServerCommand("zr_napalm_time_scale %f", 50.0 - g_fNapalmHighReduction); g_fCurrentKnockbackBoost = 1.0 + g_fKnockbackHighBoost; g_fCurrentNapalmDamage = 50.0 - g_fNapalmHighReduction; } } public void PerformMediumHelp() { if(g_bNoSteam && g_bLowPopulation) { ServerCommand("zr_class_set_multiplier zombies knockback %f", 1.0 + g_fKnockbackMediumBoost + g_fKnockbackPopulationBoost + g_fKnockbackNoSteamBoost); ServerCommand("zr_napalm_time_scale %f", 50.0 - g_fNapalmMediumReduction - g_fNapalmPopulationReduction - g_fNapalmNoSteamReduction); g_fCurrentKnockbackBoost = 1.0 + g_fKnockbackMediumBoost + g_fKnockbackPopulationBoost + g_fKnockbackNoSteamBoost; g_fCurrentNapalmDamage = 50.0 - g_fNapalmMediumReduction - g_fNapalmPopulationReduction - g_fNapalmNoSteamReduction; } else if(g_bLowPopulation) { 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); g_fCurrentKnockbackBoost = 1.0 + g_fKnockbackMediumBoost + g_fKnockbackPopulationBoost; g_fCurrentNapalmDamage = 50.0 - g_fNapalmMediumReduction - g_fNapalmPopulationReduction; } else if(g_bNoSteam) { ServerCommand("zr_class_set_multiplier zombies knockback %f", 1.0 + g_fKnockbackMediumBoost + g_fKnockbackNoSteamBoost); ServerCommand("zr_napalm_time_scale %f", 50.0 - g_fNapalmMediumReduction - g_fNapalmNoSteamReduction); g_fCurrentKnockbackBoost = 1.0 + g_fKnockbackMediumBoost + g_fKnockbackNoSteamBoost; g_fCurrentNapalmDamage = 50.0 - g_fNapalmMediumReduction - g_fNapalmNoSteamReduction; } else { ServerCommand("zr_class_set_multiplier zombies knockback %f", 1.0 + g_fKnockbackMediumBoost); ServerCommand("zr_napalm_time_scale %f", 50.0 - g_fNapalmMediumReduction); g_fCurrentKnockbackBoost = 1.0 + g_fKnockbackMediumBoost; g_fCurrentNapalmDamage = 50.0 - g_fNapalmMediumReduction; } } public void PerformLowHelp() { if(g_bNoSteam && g_bLowPopulation) { ServerCommand("zr_class_set_multiplier zombies knockback %f", 1.0 + g_fKnockbackLowBoost + g_fKnockbackPopulationBoost + g_fKnockbackNoSteamBoost); ServerCommand("zr_napalm_time_scale %f", 50.0 - g_fNapalmLowReduction - g_fNapalmPopulationReduction - g_fNapalmNoSteamReduction); g_fCurrentKnockbackBoost = 1.0 + g_fKnockbackLowBoost + g_fKnockbackPopulationBoost + g_fKnockbackNoSteamBoost; g_fCurrentNapalmDamage = 50.0 - g_fNapalmLowReduction - g_fNapalmPopulationReduction - g_fNapalmNoSteamReduction; } else if(g_bLowPopulation) { 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); g_fCurrentKnockbackBoost = 1.0 + g_fKnockbackLowBoost + g_fKnockbackPopulationBoost; g_fCurrentNapalmDamage = 50.0 - g_fNapalmLowReduction - g_fNapalmPopulationReduction; } else if(g_bNoSteam) { ServerCommand("zr_class_set_multiplier zombies knockback %f", 1.0 + g_fKnockbackLowBoost + g_fKnockbackNoSteamBoost); ServerCommand("zr_napalm_time_scale %f", 50.0 - g_fNapalmLowReduction - g_fNapalmNoSteamReduction); g_fCurrentKnockbackBoost = 1.0 + g_fKnockbackLowBoost + g_fKnockbackNoSteamBoost; g_fCurrentNapalmDamage = 50.0 - g_fNapalmLowReduction - g_fNapalmNoSteamReduction; } else { ServerCommand("zr_class_set_multiplier zombies knockback %f", 1.0 + g_fKnockbackLowBoost); ServerCommand("zr_napalm_time_scale %f", 50.0 - g_fNapalmLowReduction); g_fCurrentKnockbackBoost = 1.0 + g_fKnockbackLowBoost; g_fCurrentNapalmDamage = 50.0 - g_fNapalmLowReduction; } } public void PerformReset() { if(g_bLowPopulation && g_bNoSteam && g_bAntiNoob) { ServerCommand("zr_class_set_multiplier zombies knockback %f", 1.0 + g_fKnockbackPopulationBoost + g_fKnockbackNoSteamBoost); ServerCommand("zr_napalm_time_scale %f", 50.0 - g_fNapalmPopulationReduction - g_fNapalmNoSteamReduction); g_fCurrentKnockbackBoost = 1.0 + g_fKnockbackPopulationBoost + g_fKnockbackNoSteamBoost; g_fCurrentNapalmDamage = 50.0 - g_fNapalmPopulationReduction - g_fNapalmNoSteamReduction; } else if(g_bLowPopulation && g_bAntiNoob) { ServerCommand("zr_class_set_multiplier zombies knockback %f", 1.0 + g_fKnockbackPopulationBoost); ServerCommand("zr_napalm_time_scale %f", 50.0 - g_fNapalmPopulationReduction); g_fCurrentKnockbackBoost = 1.0 + g_fKnockbackPopulationBoost; g_fCurrentNapalmDamage = 50.0 - g_fNapalmPopulationReduction; } else if(g_bNoSteam && g_bAntiNoob) { ServerCommand("zr_class_set_multiplier zombies knockback %f", 1.0 + g_fKnockbackNoSteamBoost); ServerCommand("zr_napalm_time_scale %f", 50.0 - g_fNapalmNoSteamReduction); g_fCurrentKnockbackBoost = 1.0 + g_fKnockbackNoSteamBoost; g_fCurrentNapalmDamage = 50.0 - g_fNapalmNoSteamReduction; } else { ServerCommand("zr_class_set_multiplier zombies knockback 1.0"); ServerCommand("zr_napalm_time_scale 50.0"); g_fCurrentKnockbackBoost = 1.0; g_fCurrentNapalmDamage = 50.0; } } static stock bool IsAdmin(int client) { if (client > 0 && client <= MaxClients && IsClientInGame(client) && CheckCommandAccess(client, "", ADMFLAG_GENERIC)) return true; else return false; }