diff --git a/ZombieManager/scripting/ZombieManager.sp b/ZombieManager/scripting/ZombieManager.sp index 63ffee11..e5819234 100644 --- a/ZombieManager/scripting/ZombieManager.sp +++ b/ZombieManager/scripting/ZombieManager.sp @@ -9,12 +9,14 @@ bool g_bTestRound; bool g_bAdminTestRound; bool g_bMotherZM[MAXPLAYERS + 1] = { false, ...}; +int g_iAFKTime; + public Plugin myinfo = { name = "Zombie Manager", author = "Dogan", description = "Tools to manage testround and zombies", - version = "1.1.0", + version = "1.2.0", url = "" }; @@ -22,7 +24,7 @@ public void OnPluginStart() { g_bTestRound = false; g_bAdminTestRound = false; - + RegAdminCmd("sm_testround", Command_Testround, ADMFLAG_GENERIC, "Toggle to enable/disable a test round."); CreateTimer(20.0, Timer_MessageTestRound, _, TIMER_REPEAT); @@ -30,7 +32,12 @@ public void OnPluginStart() HookEvent("round_start", OnRoundStart); HookEvent("player_spawn", OnClientSpawn); HookEvent("player_team", OnPlayerTeam); - + + ConVar cvar; + HookConVarChange((cvar = CreateConVar("sm_player_afk_time", "180", "AFK Time in seconds after which a player won't turn into a motherzombie")), Cvar_AFKTime); + g_iAFKTime = cvar.IntValue; + delete cvar; + AddMultiTargetFilter("@mzombie", Filter_Motherzombies, "Mother Zombies", false); RegConsoleCmd("sm_mzombie", Command_DisplayMotherzombies, "Current Mother Zombies"); } @@ -40,6 +47,11 @@ public void OnPluginEnd() RemoveMultiTargetFilter("@mzombie", Filter_Motherzombies); } +public void Cvar_AFKTime(ConVar convar, const char[] oldValue, const char[] newValue) +{ + g_iAFKTime = convar.IntValue; +} + public void OnRoundStart(Event hEvent, const char[] sName, bool bDontBroadcast) { g_bTestRound = false; @@ -58,7 +70,7 @@ public void ZR_OnClientHumanPost(int client, bool respawn, bool protect) public Action ZR_OnClientInfect(int &client, int &attacker, bool &motherInfect, bool &respawnOverride, bool &respawn) { - if(g_bTestRound) + if(g_bTestRound || (GetClientIdleTime(client) > g_iAFKTime && motherInfect)) return Plugin_Handled; return Plugin_Continue;