From 1a5b3eccb9ea01f95152451667c7fd0207a6a69d Mon Sep 17 00:00:00 2001 From: "[furrycat]" Date: Wed, 20 May 2009 22:33:40 +0100 Subject: [PATCH] Stop suicide exploit. Set player health to 0 after loading if he was dead before the map changed. --- death_exploit.sp | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100755 death_exploit.sp diff --git a/death_exploit.sp b/death_exploit.sp new file mode 100755 index 0000000..8d3f870 --- /dev/null +++ b/death_exploit.sp @@ -0,0 +1,60 @@ +#include +#include "version.inc" + +/* Array to track players who are dead. */ +new dead[MAXPLAYERS]; + +public Plugin:myinfo = { + name = "Death exploit", + author = "furrycat", + description = "Stops people suiciding for a health boost.", + version = Version, +}; + +public OnPluginStart() { + decl String:ModName[50]; + GetGameFolderName(ModName, sizeof(ModName)); + + if (!StrEqual(ModName, "left4dead", false)) { + SetFailState("This mod is for Left 4 Dead only."); + } + + /* Hooks. */ + HookEvent("player_first_spawn", player_first_spawn_callback); + HookEvent("player_transitioned", player_transitioned_callback); + HookEvent("round_freeze_end", round_freeze_end_callback); +} + +public player_first_spawn_callback(Handle:event, const String:name[], bool:dontBroadcast) { + new userid = GetEventInt(event, "userid"); + new client = GetClientOfUserId(userid); + + /* Set the client alive at the start of the game. */ + if (client < 1 || client > MaxClients) return; + dead[client] = 0; +} + +public player_transitioned_callback(Handle:event, const String:name[], bool:dontBroadcast) { + new userid = GetEventInt(event, "userid"); + new client = GetClientOfUserId(userid); + + /* Remember if the client was dead. */ + if (client < 1 || client > MaxClients) return; + if (IsPlayerAlive(client)) dead[client] = 0; + else dead[client] = 1; +} + +public round_freeze_end_callback(Handle:event, const String:name[], bool:dontBroadcast) { + for (new i = 1; i <= MaxClients; i++) { + if (! dead[i]) continue; + SetEntityHealth(i, 1); + LogMessage("Set %L health to 1. Player was dead before transition.", i); + } +} + +public OnMapStart() { +} + +public OnMapEnd() { +} + -- 2.7.4