From a57acce7468d2a98499802367823de70fe31070b Mon Sep 17 00:00:00 2001 From: David Anderson Date: Mon, 23 Jul 2007 21:01:58 +0000 Subject: [PATCH] added amb444 - ForcePlayerSuicide() --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401157 --- extensions/sdktools/vnatives.cpp | 21 ++++++++++++++++++ gamedata/sdktools.games.txt | 30 ++++++++++++++++++++++++++ plugins/include/sdktools_functions.inc | 9 ++++++++ 3 files changed, 60 insertions(+) diff --git a/extensions/sdktools/vnatives.cpp b/extensions/sdktools/vnatives.cpp index 622b506d..90f4b5cb 100644 --- a/extensions/sdktools/vnatives.cpp +++ b/extensions/sdktools/vnatives.cpp @@ -274,6 +274,26 @@ static cell_t TeleportPlayer(IPluginContext *pContext, const cell_t *params) return 1; } +static cell_t ForcePlayerSuicide(IPluginContext *pContext, const cell_t *params) +{ + static ValveCall *pCall = NULL; + if (!pCall) + { + if (!CreateBaseCall("CommitSuicide", ValveCall_Player, NULL, NULL, 0, &pCall)) + { + return pContext->ThrowNativeError("\"CommitSuicide\" not supported by this mod"); + } else if (!pCall) { + return pContext->ThrowNativeError("\"CommitSuicide\" wrapper failed to initialized"); + } + } + + START_CALL(); + DECODE_VALVE_PARAM(1, thisinfo, 0); + FINISH_CALL_SIMPLE(NULL); + + return 1; +} + static cell_t SetClientViewEntity(IPluginContext *pContext, const cell_t *params) { IGamePlayer *player = playerhelpers->GetGamePlayer(params[1]); @@ -301,6 +321,7 @@ sp_nativeinfo_t g_Natives[] = { {"ExtinguishPlayer", ExtinguishPlayer}, {"ExtinguishEntity", ExtinguishPlayer}, + {"ForcePlayerSuicide", ForcePlayerSuicide}, {"GivePlayerItem", GiveNamedItem}, {"GetPlayerWeaponSlot", GetPlayerWeaponSlot}, {"IgnitePlayer", IgnitePlayer}, diff --git a/gamedata/sdktools.games.txt b/gamedata/sdktools.games.txt index 74ecc1bb..7cc51a04 100644 --- a/gamedata/sdktools.games.txt +++ b/gamedata/sdktools.games.txt @@ -134,6 +134,11 @@ "windows" "98" "linux" "99" } + "CommitSuicide" + { + "windows" "357" + "linux" "358" + } } } @@ -172,6 +177,11 @@ "windows" "98" "linux" "99" } + "CommitSuicide" + { + "windows" "356" + "linux" "357" + } } } @@ -210,6 +220,11 @@ "windows" "97" "linux" "98" } + "CommitSuicide" + { + "windows" "356" + "linux" "357" + } } } @@ -249,6 +264,11 @@ "windows" "100" "linux" "101" } + "CommitSuicide" + { + "windows" "343" + "linux" "344" + } /* Temp Entities */ "TE_GetServerClass" @@ -296,6 +316,11 @@ "windows" "100" "linux" "101" } + "CommitSuicide" + { + "windows" "360" + "linux" "361" + } /* Offset into CBaseTempEntity constructor. * On Windows Dsytopia is heavily inlined; we use the function @@ -399,6 +424,11 @@ "windows" "98" "linux" "99" } + "CommitSuicide" + { + "windows" "356" + "linux" "357" + } /* Temp Entities */ "s_pTempEntities" diff --git a/plugins/include/sdktools_functions.inc b/plugins/include/sdktools_functions.inc index 1dae0672..1f61c262 100644 --- a/plugins/include/sdktools_functions.inc +++ b/plugins/include/sdktools_functions.inc @@ -84,6 +84,15 @@ native ExtinguishEntity(client); */ native TeleportEntity(entity, const Float:origin[3], const Float:angles[3], const Float:velocity[3]); +/** + * Forces a player to commit suicide. + * + * @param client Client index. + * @noreturn + * @error Invalid entity or client not in game, or lack of mod support. + */ +native ForcePlayerSuicide(client); + /** * @deprecated */