AlliedModders Donor
Join Date: Oct 2010
Location: Undisclosed...
|
07-25-2011
, 22:41
Re: [CS:S] Kill Delay
|
#8
|
eh, I hope you don't mind, but here is a revised version of your plugin - I incorporated the ideas from what I was going to do into what you did. The version I have uses different messages and junk... I just tailored my changes into your already existing code and cvars and junk.
PHP Code:
/* 1.0 -- July_23_2011 Official release * 1.1 -- July_23_2011 Touched up code * */
// chat green = /x04 // lightgreen = /x03 // white = /x01
#pragma semicolon 1 // TnT addition #include <sourcemod> #include <sdktools> #define PLUGIN_VERSION "1.1"
// cvars new Handle:g_pluginEnabled= INVALID_HANDLE; new Handle:g_killdelay_time= INVALID_HANDLE; new Handle:g_SuicideTimer[MAXPLAYERS+1]; // TnT addition
public Plugin:myinfo = { name = "Kill Delay", author = "Jon - Ehh", description = "When a player types kill in console it will delay x then suicide them", version = PLUGIN_VERSION, url = "http://wazzgame.com/" }
public OnPluginStart() { // RegConsoleCmd("kill", command_kill); // TnT edit
CreateConVar("sm_killdelay_version", PLUGIN_VERSION, "Kill Delay Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY); CreateConVar("sm_killdelay_enabled", "1", "Is Kill Delay Enabled? 1/0"); // TnT addition CreateConVar("sm_killdelay_time", "5", "How many seconds to wait before forcing the suicide on the player who tried to suicide.", _, true, 1.0, true, 10.0); // TnT addition
AddCommandListener(command_kill, "kill"); // TnT addition AddCommandListener(command_kill, "spectate"); // TnT addition AddCommandListener(command_kill, "jointeam"); // TnT addition AddCommandListener(command_kill, "joinclass"); // TnT addition AddCommandListener(command_kill, "explode"); // TnT addition
//g_pluginEnabled= CreateConVar("sm_killdelay_enabled", "1", "Is Kill Delay Enabled? 1/0"); //g_killdelay_time= CreateConVar("sm_killdelay_time", "5", "How many seconds to wait before suicide the client");
g_pluginEnabled = FindConVar("sm_killdelay_enabled"); // TnT addition g_killdelay_time = FindConVar("sm_killdelay_time"); // TnT addition
HookEvent("player_death", OnPlayerDeath); // TnT addition // Execute the config file // TnT addition AutoExecConfig(true, "killdelay.plugin"); // TnT addition }
public Action:command_kill(client, const String:command[], args) // TnT added const String:command[] although it may not be needed { if(client == 0) // TnT addition { return Plugin_Handled; // TnT addition }
if (GetConVarBool(g_pluginEnabled) && IsPlayerAlive(client) && IsClientInGame(client) && !IsFakeClient(client)) // TnT added && !IsFakeClient(client) { //CreateTimer(GetConVarFloat(g_killdelay_time), Suicide_Player, client) // TnT edit g_SuicideTimer[client] = CreateTimer(GetConVarFloat(g_killdelay_time), Force_Suicide, client); // TnT addition return Plugin_Handled; // TnT addition } return Plugin_Continue; // TnT edit } public Action:Force_Suicide(Handle:timer, any:client) { if(g_SuicideTimer[client] != INVALID_HANDLE) // TnT addition { if(IsClientInGame(client) && IsPlayerAlive(client)) // TnT addition { PrintToConsole(client, "You have suicided!"); PrintCenterText(client,"You have suicided!"); PrintToChat(client, "\x04[Kill Delay] : \x03You have suicided!"); ForcePlayerSuicide(client); } g_SuicideTimer[client] = INVALID_HANDLE; // TnT addition } }
// TnT added below public OnPlayerDeath(Handle:event, const String:name[], bool:dontBroadcast) { new client = GetClientOfUserId(GetEventInt(event,"userid")); if(g_SuicideTimer[client] != INVALID_HANDLE) { KillTimer(g_SuicideTimer[client]); g_SuicideTimer[client] = INVALID_HANDLE; } }
I was going to post my version, but the two resemble each other too closely - so... here's just the code of the one I'm using:
PHP Code:
/* This plugin will intercept player suicide attempts by capturing the following commands * kill * jointeam * joinclass * spectate * explode Plugin can be en/disabled via cvar sm_suicideintercept_enabled 1/0 Configurable number of delay seconds to carry out players requested suicide */
#pragma semicolon 1
#include <sourcemod> #include <sdktools> #define PLUGIN_VERSION "1.0"
new Handle:g_pluginEnabled = INVALID_HANDLE; new Handle:g_delay_death_time = INVALID_HANDLE; new Handle:g_SuicideTimer[MAXPLAYERS+1];
public Plugin:myinfo = { name = "Suicide Intercept", author = "TnTSCS aKa ClarKKent", description = "Intercepts suicide commands and delays it by X seconds", version = PLUGIN_VERSION, url = "http://forums.alliedmods.net" }
public OnPluginStart() { // Create my ConVars CreateConVar("sm_suicideintercept_version", PLUGIN_VERSION, "Suicide Intercept version.", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY); CreateConVar("sm_suicideintercept_enabled", "1", "Is Kill Delay Enabled? 1/0"); CreateConVar("sm_suicideintercept_delaydeathtime", "5", "How many seconds to wait before forcing the suicide on the player who tried to suicide.", _, true, 1.0, true, 10.0);
// Add command listeners AddCommandListener(Command_InterceptSuicide, "kill"); AddCommandListener(Command_InterceptSuicide, "spectate"); AddCommandListener(Command_InterceptSuicide, "jointeam"); AddCommandListener(Command_InterceptSuicide, "joinclass"); AddCommandListener(Command_InterceptSuicide, "explode");
// Set the variables g_pluginEnabled = FindConVar("sm_suicideintercept_enabled"); g_delay_death_time = FindConVar("sm_suicideintercept_delaydeathtime"); HookEvent("player_death", OnPlayerDeath); // Execute the config file AutoExecConfig(true, "SuicideIntercept.plugin"); } public Action:Command_InterceptSuicide(client, const String:command[], args) { if(client == 0) { return Plugin_Handled; } // Known player suicide commands - "kill" "spectate" "jointeam" "joinclass" "explode"
// If plugin is enabled, player is alive, and client is in game (one may be redundant) if (GetConVarBool(g_pluginEnabled) && IsPlayerAlive(client) && IsClientInGame(client) && !IsFakeClient(client)) { // Notify player their suicide attempt was intercepted and will be delayed PrintCenterText(client, "Suicide Intercepted, delaying %i seconds", GetConVarInt(g_delay_death_time)); PrintToChat(client, "\x04[\x03Suicide Intercept\x04]\x01 Your suicide request will be granted in %i seconds", GetConVarInt(g_delay_death_time)); // Create a timer to carry out the players suicide request (needs float and not int due to 0.0 format for timer) g_SuicideTimer[client] = CreateTimer(GetConVarFloat(g_delay_death_time), Force_Suicide, client); return Plugin_Handled; } return Plugin_Continue; } public Action:Force_Suicide(Handle:timer, any:client) { if(g_SuicideTimer[client] != INVALID_HANDLE) { // Make sure client is still in game and didn't rage quit if(IsClientInGame(client) && IsPlayerAlive(client)) { // Notify player their suicide request has been carried out PrintToConsole(client, "Your request for suicide was granted."); PrintCenterText(client,"Suicide granted"); PrintToChat(client, "\x04[\x03Suicide Intercept\x04]\x01 Your suicide request was carried out"); // Kill player via suicide ForcePlayerSuicide(client); } g_SuicideTimer[client] = INVALID_HANDLE; } }
public OnPlayerDeath(Handle:event, const String:name[], bool:dontBroadcast) { new client = GetClientOfUserId(GetEventInt(event,"userid")); if(g_SuicideTimer[client] != INVALID_HANDLE) { KillTimer(g_SuicideTimer[client]); g_SuicideTimer[client] = INVALID_HANDLE; } }
Last edited by TnTSCS; 07-25-2011 at 22:47.
|
|