Stop suicide exploit.
author[furrycat] <furrycat@furryclan.net>
Wed, 20 May 2009 21:33:40 +0000 (22:33 +0100)
committer[furrycat] <furrycat@furryclan.net>
Mon, 1 Jun 2009 22:01:22 +0000 (18:01 -0400)
Set player health to 0 after loading if he was dead before the map changed.

death_exploit.sp [new file with mode: 0755]

diff --git a/death_exploit.sp b/death_exploit.sp
new file mode 100755 (executable)
index 0000000..8d3f870
--- /dev/null
@@ -0,0 +1,60 @@
+#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