diff --git a/UNLOZE_KnifeMadness/scripting/UNLOZE_KnifeMadness.sp b/UNLOZE_KnifeMadness/scripting/UNLOZE_KnifeMadness.sp index bc6d8815..e35cedd8 100644 --- a/UNLOZE_KnifeMadness/scripting/UNLOZE_KnifeMadness.sp +++ b/UNLOZE_KnifeMadness/scripting/UNLOZE_KnifeMadness.sp @@ -10,7 +10,9 @@ ConVar g_hCVar_Delay; /* BOOLS */ -bool g_bZMwasKnifed[MAXPLAYERS+1]; +bool g_bClientKnifed[MAXPLAYERS+1]; +bool g_bSupressDeath[MAXPLAYERS+1]; + //---------------------------------------------------------------------------------------------------- // Purpose: //---------------------------------------------------------------------------------------------------- @@ -30,8 +32,9 @@ public void OnPluginStart() { g_hCVar_Delay = CreateConVar("sm_knife_madness_kill_delay", "3", "Delay before ZMs die after being knifed by a human.", 0, true, 0.0); - HookEvent("player_spawn", OnClientSpawn); - HookEvent("player_hurt", OnClientHurt); + HookEvent("player_spawn", OnClientSpawn, EventHookMode_Post); + HookEvent("player_death", OnClientDeath, EventHookMode_Pre); + HookEvent("player_hurt", OnClientHurt, EventHookMode_Post); } //---------------------------------------------------------------------------------------------------- @@ -40,7 +43,25 @@ public void OnPluginStart() public void OnClientSpawn(Event hEvent, const char[] sEvent, bool bDontBroadcast) { int client = GetClientOfUserId(hEvent.GetInt("userid")); - g_bZMwasKnifed[client] = false; + + g_bClientKnifed[client] = false; + g_bSupressDeath[client] = false; +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public Action OnClientDeath(Event hEvent, const char[] sEvent, bool bDontBroadcast) +{ + int client = GetClientOfUserId(hEvent.GetInt("userid")); + + if (g_bSupressDeath[client]) + { + g_bSupressDeath[client] = false; + return Plugin_Handled; + } + + return Plugin_Continue; } //---------------------------------------------------------------------------------------------------- @@ -63,7 +84,7 @@ public void OnClientHurt(Event hEvent, const char[] sEvent, bool bDontBroadcast) if(!StrEqual(sWeapon, "knife", false)) return; - g_bZMwasKnifed[victim] = true; + g_bClientKnifed[victim] = true; CPrintToChat(attacker, "{unique}[Knife Madness] {white}You have knifed {lime}%N{white}. He will die in %ds if he doesnt infect a human.", victim, g_hCVar_Delay.IntValue); CPrintToChat(victim, "{unique}[Knife Madness] {white}You have been knifed by {lime}%N{white}. You will die in %ds if you do not infect a human.", attacker, g_hCVar_Delay.IntValue); @@ -76,7 +97,6 @@ public void OnClientHurt(Event hEvent, const char[] sEvent, bool bDontBroadcast) pack.WriteCell(GetClientUserId(victim)); } - //---------------------------------------------------------------------------------------------------- // Purpose: //---------------------------------------------------------------------------------------------------- @@ -85,9 +105,9 @@ public void ZR_OnClientInfected(int client, int attacker, bool motherInfect, boo if (!IsValidClient(attacker)) return; - if(g_bZMwasKnifed[attacker]) + if(g_bClientKnifed[attacker]) { - g_bZMwasKnifed[attacker] = false; + g_bClientKnifed[attacker] = false; SetEntProp(attacker, Prop_Send, "m_iProgressBarDuration", 0); CPrintToChat(attacker, "{unique}[Knife Madness] {white}You have successfully infected a human and prevented your death."); } @@ -108,9 +128,10 @@ public Action KillZM(Handle timer, DataPack pack) if (client == 0) return; - if (!(IsValidClient(client, false) && IsPlayerAlive(client) && ZR_IsClientZombie(client) && g_bZMwasKnifed[client])) + if (!(IsValidClient(client, false) && IsPlayerAlive(client) && ZR_IsClientZombie(client) && g_bClientKnifed[client])) return; + g_bSupressDeath[client] = true; ForcePlayerSuicide(client); if (!(IsValidClient(attacker, false)))