--- /dev/null
+#include <sourcemod>\r
+#include "version.inc"\r
+\r
+/* Array to track players who are dead. */\r
+new dead[MAXPLAYERS];\r
+\r
+public Plugin:myinfo = {\r
+ name = "Death exploit",\r
+ author = "furrycat",\r
+ description = "Stops people suiciding for a health boost.",\r
+ version = Version,\r
+};\r
+\r
+public OnPluginStart() {\r
+ decl String:ModName[50];\r
+ GetGameFolderName(ModName, sizeof(ModName));\r
+\r
+ if (!StrEqual(ModName, "left4dead", false)) {\r
+ SetFailState("This mod is for Left 4 Dead only.");\r
+ }\r
+\r
+ /* Hooks. */\r
+ HookEvent("player_first_spawn", player_first_spawn_callback);\r
+ HookEvent("player_transitioned", player_transitioned_callback);\r
+ HookEvent("round_freeze_end", round_freeze_end_callback);\r
+}\r
+\r
+public player_first_spawn_callback(Handle:event, const String:name[], bool:dontBroadcast) {\r
+ new userid = GetEventInt(event, "userid");\r
+ new client = GetClientOfUserId(userid);\r
+\r
+ /* Set the client alive at the start of the game. */\r
+ if (client < 1 || client > MaxClients) return;\r
+ dead[client] = 0;\r
+}\r
+\r
+public player_transitioned_callback(Handle:event, const String:name[], bool:dontBroadcast) {\r
+ new userid = GetEventInt(event, "userid");\r
+ new client = GetClientOfUserId(userid);\r
+\r
+ /* Remember if the client was dead. */\r
+ if (client < 1 || client > MaxClients) return;\r
+ if (IsPlayerAlive(client)) dead[client] = 0;\r
+ else dead[client] = 1;\r
+}\r
+\r
+public round_freeze_end_callback(Handle:event, const String:name[], bool:dontBroadcast) {\r
+ for (new i = 1; i <= MaxClients; i++) {\r
+ if (! dead[i]) continue;\r
+ SetEntityHealth(i, 1);\r
+ LogMessage("Set %L health to 1. Player was dead before transition.", i);\r
+ }\r
+}\r
+\r
+public OnMapStart() {\r
+}\r
+\r
+public OnMapEnd() {\r
+}\r
+\r