Raised This Month: $32 Target: $400
 8% 

TOG Bot Damage Immunity


Post New Thread Reply   
 
Thread Tools Display Modes
Author
ThatOneGuy
Veteran Member
Join Date: Jul 2012
Location: Oregon, USA
Plugin ID:
6503
Plugin Version:
1.1.0
Plugin Category:
General Purpose
Plugin Game:
Any
Plugin Dependencies:
    Servers with this Plugin:
    1 
    Plugin Description:
    Makes bot/replay clients immune to damage.
    Old 04-07-2019 , 17:03   TOG Bot Damage Immunity
    Reply With Quote #1

    I'm slowly releasing (which takes a good bit of time) a bunch of my older/smaller plugins that have just been sitting around and others might want them. By now, some of these may have similar plugins released by others - I don't intend on checking them all. This one was made upon request (on here? I cant find where...) and I didn't see a similar plugin in the first page or two of a search.

    TOG Bot Damage Immunity

    Makes bot/replay clients immune to damage.

    Installation:
    * Put togbotdmgimmunity.smx in the following folder: /addons/sourcemod/plugins/
    Attached Files
    File Type: smx togbotdmgimmunity.smx (4.0 KB, 140 views)
    File Type: sp Get Plugin or Get Source (togbotdmgimmunity.sp - 389 views - 1.5 KB)
    __________________

    Last edited by ThatOneGuy; 04-09-2019 at 20:33. Reason: Updated to 1.1.0.
    ThatOneGuy is offline
    B3none
    AlliedModders Donor
    Join Date: Oct 2016
    Location: United Kingdom
    Old 04-08-2019 , 12:01   Re: TOG Bot Damage Immunity
    Reply With Quote #2

    Perhaps:

    PHP Code:
    #include <sourcemod>
    #include <sdkhooks>

    #pragma semicolon 1
    #pragma newdecls required

    #define PLUGIN_VERSION "1.0.1"

    public Plugin myinfo =
    {
        
    name "TOG Bot Damage Immunity",
        
    author "That One Guy",
        
    description "Makes bot/replay clients immune to damage",
        
    version PLUGIN_VERSION,
        
    url "https://www.togcoding.com/togcoding/"
    }

    public 
    void OnPluginStart()
    {
        
    CreateConVar("tbdi_version"PLUGIN_VERSION"TOG Bot Damage Immunity - version number."FCVAR_NOTIFY|FCVAR_DONTRECORD);
    }

    public 
    void OnClientPutInServer(int client)
    {
        
    SDKHook(clientSDKHook_OnTakeDamageEvent_OnTakeDamage);
    }

    public 
    void OnClientDisconnect(int client)
    {
        
    SDKUnhook(clientSDKHook_OnTakeDamageEvent_OnTakeDamage);
    }

    public 
    Action Event_OnTakeDamage(int victimint &attackerint &inflictorfloat &fDamageint &damagetypeint &weaponfloat a_fDmgForce[3], float a_fDmgPosition[3])
    {
        if (
    IsValidClient(victim) && IsFakeClient(victim) || IsClientReplay(victim))
        {
            
    fDamage 0.0;
            return 
    Plugin_Changed;
        }
        
        return 
    Plugin_Continue;
    }

    bool IsValidClient(int client)
    {
        if(!(
    <= client <= MaxClients) || !IsClientInGame(client))
        {
            return 
    false;
        }
        
        return 
    true;
    }

    stock void Log(char[] sPath, const char[] sMsgany ...) //TOG logging function - path is relative to logs folder.
    {
        
    char sLogFilePath[PLATFORM_MAX_PATH], sFormattedMsg[1500];
        
        
    BuildPath(Path_SMsLogFilePathsizeof(sLogFilePath), "logs/%s"sPath);
        
    VFormat(sFormattedMsgsizeof(sFormattedMsg), sMsg3);
        
    LogToFileEx(sLogFilePath"%s"sFormattedMsg);
    }

    /////////////////////////////////////////////////////////////////////////////////////////
    /////////////////////////////////////// CHANGE LOG //////////////////////////////////////
    /////////////////////////////////////////////////////////////////////////////////////////
    /*
        1.0.1
            * Tiny re-factor courtesy of B3none.
        
        1.0.0
            * Initial creation.
            
    */ 
    __________________
    B3none is offline
    ttasdasda
    Member
    Join Date: Apr 2014
    Old 04-08-2019 , 12:10   Re: TOG Bot Damage Immunity
    Reply With Quote #3

    m_takedamage 0
    ttasdasda is offline
    Mitchell
    ~lick~
    Join Date: Mar 2010
    Old 04-08-2019 , 13:17   Re: TOG Bot Damage Immunity
    Reply With Quote #4

    remove all those checks but mainly IsValidClient lol how insane is that function within a sdkhooks callback. A callback that wouldn't fire for some one not actually hooked... And guess what, you're hooking the client when they are put in the server... Something like this should work, and be immune.

    PHP Code:
    #pragma semicolon 1
    #define PLUGIN_VERSION "1.1.0"
    #include <sdkhooks>

    #pragma newdecls required

    public Plugin myinfo =
    {
        
    name "TOG Bot Damage Immunity",
        
    author "That One Guy",
        
    description "Makes bot/replay clients immune to damage",
        
    version PLUGIN_VERSION,
        
    url "https://www.togcoding.com/togcoding/"
    }

    public 
    void OnPluginStart()
    {
        
    CreateConVar("tbdi_version"PLUGIN_VERSION"TOG Bot Damage Immunity - version number."FCVAR_NOTIFY|FCVAR_DONTRECORD);
    }

    public 
    void OnClientPutInServer(int client)
    {
        if (
    IsFakeClient(client) || IsClientReplay(client))
        {
            
    SDKHook(clientSDKHook_OnTakeDamageEvent_OnTakeDamage);
        }
    }

    public 
    void OnClientDisconnect(int client)
    {
        
    SDKUnhook(clientSDKHook_OnTakeDamageEvent_OnTakeDamage);
    }

    public 
    Action Event_OnTakeDamage(int victimint &attackerint &inflictorfloat &fDamageint &damagetypeint &weaponfloat a_fDmgForce[3], float a_fDmgPosition[3]/*, int damagecustom*/)
    {
        return 
    Plugin_Stop;

    m_takedamage 0 is a terrible solution since there are several plugins that modify that property.

    Last edited by Mitchell; 04-08-2019 at 13:17.
    Mitchell is offline
    ThatOneGuy
    Veteran Member
    Join Date: Jul 2012
    Location: Oregon, USA
    Old 04-09-2019 , 20:26   Re: TOG Bot Damage Immunity
    Reply With Quote #5

    Quote:
    Originally Posted by b3none View Post
    Perhaps:
    PHP Code:
    if (IsValidClient(victim) && IsFakeClient(victim) || IsClientReplay(victim)) 
    IsFakeClient and IsClientReplay were nested under IsValidClient because I couldnt remember if it causes an error if those functions are passed an invalid client index.

    Quote:
    Originally Posted by ttasdasda View Post
    m_takedamage 0
    That would indeed be a better solution provided it isnt later modified by another plugin, e.g., a super admin plugin with God Mode commands. If the server operator is sure no other plugins modify that property, that could work well.

    Quote:
    Originally Posted by Mitchell View Post
    ...you're hooking the client when they are put in the server
    Good point. That would indeed be a better solution as no checks are necessary after the initial check. Even though this was intended to just be an old plugin dump, I'll make that edit real quick and update the OP. Just a note though, returning Plugin_Stop could prevent other plugins that may need to hook that event (e.g. stats plugins counting the damage).

    OP version updated to 1.1.0.
    __________________
    ThatOneGuy is offline
    Reply


    Thread Tools
    Display Modes

    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 10:49.


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