diff --git a/cstrike/cfg/sourcemod/zombiereloaded/zombiereloaded.cfg b/cstrike/cfg/sourcemod/zombiereloaded/zombiereloaded.cfg index 7a4c178..191108c 100644 --- a/cstrike/cfg/sourcemod/zombiereloaded/zombiereloaded.cfg +++ b/cstrike/cfg/sourcemod/zombiereloaded/zombiereloaded.cfg @@ -382,6 +382,10 @@ zr_damage_suicide_human "0" // Default: "kill, spectate, jointeam, joinclass" zr_damage_suicide_cmds "kill, spectate, jointeam, joinclass" +// Intercept suicide commands only after the first zombie has spawned. +// Default: "1" +zr_damage_suicide_after_infect "1" + // ---------------------------------------------------------------------------- // Overlays (core) diff --git a/src/zr/cvars.inc b/src/zr/cvars.inc index c5ec5b7..0c29bf3 100644 --- a/src/zr/cvars.inc +++ b/src/zr/cvars.inc @@ -85,6 +85,7 @@ enum CvarsList Handle:CVAR_DAMAGE_SUICIDE_MZOMBIE, Handle:CVAR_DAMAGE_SUICIDE_HUMAN, Handle:CVAR_DAMAGE_SUICIDE_CMDS, + Handle:CVAR_SUICIDE_AFTER_INFECT, Handle:CVAR_SAYHOOKS_QUIET, Handle:CVAR_SAYHOOKS_QUIET_FILTER, Handle:CVAR_SAYHOOKS_QUIET_FLAGS, @@ -347,6 +348,7 @@ CvarsCreate() g_hCvarsList[CVAR_DAMAGE_SUICIDE_MZOMBIE] = CreateConVar("zr_damage_suicide_mzombie", "1", "Intercept suicide commands attempted by mother zombies."); g_hCvarsList[CVAR_DAMAGE_SUICIDE_HUMAN] = CreateConVar("zr_damage_suicide_human", "0", "Intercept suicide commands attempted by humans."); g_hCvarsList[CVAR_DAMAGE_SUICIDE_CMDS] = CreateConVar("zr_damage_suicide_cmds", "kill, spectate, jointeam, joinclass", "List of client commands to intercept as suicide attempts. [Delimiter: \", \"]"); + g_hCvarsList[CVAR_SUICIDE_AFTER_INFECT] = CreateConVar("zr_damage_suicide_after_infect", "1", "Intercept suicide commands only after the first zombie has spawned."); // =========================== diff --git a/src/zr/damage.inc b/src/zr/damage.inc index 2f8d601..2123a32 100644 --- a/src/zr/damage.inc +++ b/src/zr/damage.inc @@ -382,63 +382,47 @@ public ZRTools_Action:DamageOnTakeDamage(client, inflictor, attacker, Float:dama */ public Action:DamageSuicideIntercept(client, argc) { - // If zombie hasn't spawned, then stop. - if (!g_bZombieSpawned) + // Get suicide interception settings. + new bool:suicideAfterInfect = GetConVarBool(g_hCvarsList[CVAR_SUICIDE_AFTER_INFECT]); + new bool:suicideZombie = GetConVarBool(g_hCvarsList[CVAR_DAMAGE_SUICIDE_ZOMBIE]); + new bool:suicideZombieMother = GetConVarBool(g_hCvarsList[CVAR_DAMAGE_SUICIDE_MZOMBIE]); + new bool:suicideHuman = GetConVarBool(g_hCvarsList[CVAR_DAMAGE_SUICIDE_HUMAN]); + + // Check various criterias that will _allow_ the command. If no criterias + // match, block it. + + // Check general criterias. + if ((suicideAfterInfect && !g_bZombieSpawned) || // Check if it should block suicides before mother zombie. + !ZRIsClientValid(client) || // Validate client (to stop console). + !IsPlayerAlive(client)) // Check if dead. { + // Allow command. return Plugin_Continue; } - // If client is invalid, then stop. (Stop console.) - if (!ZRIsClientValid(client)) - { - return Plugin_Continue; - } - - // If client is dead, then stop. - if (!IsPlayerAlive(client)) - { - return Plugin_Continue; - } - - // Get cvar values for suicide interception. - new bool:suicidezombie = GetConVarBool(g_hCvarsList[CVAR_DAMAGE_SUICIDE_ZOMBIE]); - new bool:suicidezombiemother = GetConVarBool(g_hCvarsList[CVAR_DAMAGE_SUICIDE_MZOMBIE]); - new bool:suicidehuman = GetConVarBool(g_hCvarsList[CVAR_DAMAGE_SUICIDE_HUMAN]); - - // Check if client is a zombie. + // Check zombie criterias. if (InfectIsClientInfected(client)) { - // If client is a mother zombie, and suicide intercept is enabled for mother zombies zombies, then block command. - if (g_bDamageMotherZombie[client] && suicidezombiemother) + if (g_bDamageMotherZombie[client] && !suicideZombieMother || // Check if suicide is allowed for mother zombies. + (!g_bDamageMotherZombie[client] && !suicideZombie)) // Check if suicide is allowed for regular zombies. { - // Tell client their command has been intercepted, and log. - TranslationPrintToChat(client, "Damage suicide intercept"); - LogEvent(false, LogType_Normal, LOG_GAME_EVENTS, LogModule_Damage, "Suicide Intercept", "Player \"%L\" attempted suicide.", client); - - return Plugin_Handled; - } - - // If client is a zombie, and suicide intercept is enabled for zombies, then block command. - if (!g_bDamageMotherZombie[client] && suicidezombie) - { - // Tell client their command has been intercepted, and log. - TranslationPrintToChat(client, "Damage suicide intercept"); - LogEvent(false, LogType_Normal, LOG_GAME_EVENTS, LogModule_Damage, "Suicide Intercept", "Player \"%L\" attempted suicide.", client); - - return Plugin_Handled; + // Allow command. + return Plugin_Continue; } } - // If client is a human, and suicide intercept is enabled for humans, then block command. - if (InfectIsClientHuman(client) && suicidehuman) + // Check human criterias. + // Allow suicide if player is a human and humans can suicide. + if (InfectIsClientHuman(client) && !suicideHuman) { - // Tell client their command has been intercepted, and log. - TranslationPrintToChat(client, "Damage suicide intercept"); - LogEvent(false, LogType_Normal, LOG_GAME_EVENTS, LogModule_Damage, "Suicide Intercept", "Player \"%L\" attempted suicide.", client); - - return Plugin_Handled; + // Allow command. + return Plugin_Continue; } - // Allow command. - return Plugin_Continue; + // Tell client their command has been intercepted, and log. + TranslationPrintToChat(client, "Damage suicide intercept"); + LogEvent(false, LogType_Normal, LOG_GAME_EVENTS, LogModule_Damage, "Suicide Intercept", "\"%L\" attempted suicide.", client); + + // Block command. + return Plugin_Handled; }