Raised This Month: $51 Target: $400
 12% 

[CS:S] Kill Delay


Post New Thread Reply   
 
Thread Tools Display Modes
Author
wazzgod
Member
Join Date: Oct 2005
Location: Home
Plugin ID:
2453
Plugin Version:
Plugin Category:
General Purpose
Plugin Game:
Any
Plugin Dependencies:
    Servers with this Plugin:
     
    Plugin Description:
    Unapprover:
    Reason for Unapproving:
    Duplicate of http://forums.alliedmods.net/showthread.php?t=163257
    Old 07-24-2011 , 03:00   [CS:S] Kill Delay
    Reply With Quote #1

    Kill Delay
    Version 1.0

    Description:
    This plugin will delay the suicide of a player.
    Example : when a player types kill in console it will wait the 'sm_killdelay_time' variable
    So instead of the player suicideing right before you can kill him/her, you have the time of the variable to kill the user.

    Variables:
    sm_killdelay_enabled 1/0 (default: 1)
    sm_killdelay_time 5 (default: 5)

    Install Instructions:

    Place kill_delay.smx in your /addons/sourcemod/plugins folder and change the map

    Notes :
    This is my first public plugin.
    Enjoy!


    Changelog

    07.23.2011 - v1.0 - Initial Release
    07.23.2011 - v1.1 - Touched up code

    Attached Files
    File Type: sp Get Plugin or Get Source (kill_delay.sp - 923 views - 1.5 KB)
    __________________
    People Who Think They Know Everything
    Are Very Irritating To Those Of Us Who Do.

    Last edited by wazzgod; 07-24-2011 at 03:23.
    wazzgod is offline
    RedSword
    SourceMod Plugin Approver
    Join Date: Mar 2006
    Location: Quebec, Canada
    Old 07-24-2011 , 03:10   Re: [CS:S] Kill Delay
    Reply With Quote #2

    Since you're delaying a function call you should make checks concerning the client. You've to check with IsClientInGame() and maybe IsPlayerAlive() before killing him. If you don't and the players is killed before force-"suiciding" console shall print errors. Also making the timer destroy themselves on map change would be good (simple flag).

    I suggest you also clean up your code... "OnPluginEnd()" is empty and there is a comment for a test line (at least for the release version).

    Code:
    #define MAX_PLAYERS 256
    I also suggest that you actually use what you define... MAX_PLAYERS isn't used anywhere, and anyway Valve HL2 games can't get up to 256 players (but maybe 128 with bots and it's 64 with players only).

    You should also check the syntax of your CVar descriptions; there are some spelling mistakes.

    I do believe you should set a minimum delay before killing the players; since someone could put negative values, and who knows what would happen (most experienced coders I guess ><).

    Red

    EDIT : I do believe using "CommandListener()" rather than RegConsoleCmd would be better (optimization I believe).
    __________________
    My plugins :
    Red Maze
    Afk Bomb
    RAWR (per player/rounds Awp Restrict.)
    Kill Assist
    Be Medic

    You can also Donate if you appreciate my work

    Last edited by RedSword; 07-24-2011 at 03:14.
    RedSword is offline
    wazzgod
    Member
    Join Date: Oct 2005
    Location: Home
    Old 07-24-2011 , 03:14   Re: [CS:S] Kill Delay
    Reply With Quote #3

    Thank you for your suggestions
    I always forget to make my code noob proof.
    But then again i normally think im the only one who is going to use this.
    __________________
    People Who Think They Know Everything
    Are Very Irritating To Those Of Us Who Do.
    wazzgod is offline
    wazzgod
    Member
    Join Date: Oct 2005
    Location: Home
    Old 07-24-2011 , 03:23   Re: [CS:S] Kill Delay
    Reply With Quote #4

    thank you > touched up code.
    Removed ver 1.0 from original post and uploaded ver 1.1

    Any other suggestions / ideas?
    __________________
    People Who Think They Know Everything
    Are Very Irritating To Those Of Us Who Do.
    wazzgod is offline
    RedSword
    SourceMod Plugin Approver
    Join Date: Mar 2006
    Location: Quebec, Canada
    Old 07-24-2011 , 13:33   Re: [CS:S] Kill Delay
    Reply With Quote #5

    Quote:
    Originally Posted by wazzgod View Post
    Any other suggestions / ideas?
    More like already said ones.

    Quote:
    Originally Posted by RedSword View Post
    Since you're delaying a function call you should make checks concerning the client. You've to check with IsClientInGame() and maybe IsPlayerAlive() before killing him. If you don't and the players is killed before force-"suiciding" console shall print errors. Also making the timer destroy themselves on map change would be good (simple flag).
    Not done. Player can be out of the game.

    Quote:
    Originally Posted by RedSword View Post
    I do believe you should set a minimum delay before killing the players; since someone could put negative values, and who knows what would happen (most experienced coders I guess ><).
    Not done.

    Quote:
    Originally Posted by RedSword View Post
    I do believe using "CommandListener()" rather than RegConsoleCmd would be better (optimization I believe).
    Still not done.

    Red
    __________________
    My plugins :
    Red Maze
    Afk Bomb
    RAWR (per player/rounds Awp Restrict.)
    Kill Assist
    Be Medic

    You can also Donate if you appreciate my work
    RedSword is offline
    wazzgod
    Member
    Join Date: Oct 2005
    Location: Home
    Old 07-25-2011 , 01:50   Re: [CS:S] Kill Delay
    Reply With Quote #6

    RegConsoleCmd works fine, and people been using it for years...

    Give POWER to the USER, if they want a NEGATIVE value, let them be noob.
    If a user is smart enough to change the var to a negative value, he/she is smart enough to change it back.

    Check code again. Ver 1.1 is
    Code:
    if (GetConVarBool(g_pluginEnabled) && IsPlayerAlive(client) && IsClientInGame(client))
    And you dont have to have a kill timer.
    The plugin works fine without one.


    Why us smart people love linux > power to do what you want.
    pfft eye candy noob proof windowz - makes me angry...
    __________________
    People Who Think They Know Everything
    Are Very Irritating To Those Of Us Who Do.
    wazzgod is offline
    TnTSCS
    AlliedModders Donor
    Join Date: Oct 2010
    Location: Undisclosed...
    Old 07-25-2011 , 02:10   Re: [CS:S] Kill Delay
    Reply With Quote #7

    Quote:
    Originally Posted by wazzgod View Post
    Thank you for your suggestions
    I always forget to make my code noob proof.
    But then again i normally think im the only one who is going to use this.
    nevermind.. you were the requestor... i am still going to try my hand at this as well... i will post the code here for you to compare

    Last edited by TnTSCS; 07-25-2011 at 02:14.
    TnTSCS is offline
    TnTSCS
    AlliedModders Donor
    Join Date: Oct 2010
    Location: Undisclosed...
    Old 07-25-2011 , 22:41   Re: [CS:S] Kill Delay
    Reply With Quote #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_pluginEnabledINVALID_HANDLE;
    new 
    Handle:g_killdelay_timeINVALID_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."_true1.0true10.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_Suicideclient); // TnT addition
            
    return Plugin_Handled// TnT addition
        
    }
        return 
    Plugin_Continue// TnT edit
    }
     
    public 
    Action:Force_Suicide(Handle:timerany: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."_true1.0true10.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_Suicideclient);
            
            return 
    Plugin_Handled;
        }
        return 
    Plugin_Continue;
    }
     
    public 
    Action:Force_Suicide(Handle:timerany: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.
    TnTSCS is offline
    wazzgod
    Member
    Join Date: Oct 2005
    Location: Home
    Old 07-28-2011 , 03:12   Re: [CS:S] Kill Delay
    Reply With Quote #9

    Thx tnTSCS

    go a head and post the plugin for approval (be cool if i got credit for the idea)
    I just sparked a idea and needed a simple plugin for my servers.

    please post your version.
    __________________
    People Who Think They Know Everything
    Are Very Irritating To Those Of Us Who Do.
    wazzgod is offline
    TnTSCS
    AlliedModders Donor
    Join Date: Oct 2010
    Location: Undisclosed...
    Old 07-28-2011 , 09:52   Re: [CS:S] Kill Delay
    Reply With Quote #10

    done - here
    TnTSCS is offline
    Reply



    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off

    Forum Jump


    All times are GMT -4. The time now is 22:29.


    Powered by vBulletin®
    Copyright ©2000 - 2024, vBulletin Solutions, Inc.
    Theme made by Freecode