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

[L4D2] Defibrillate via Menu


Post New Thread Reply   
 
Thread Tools Display Modes
Author
Shadowysn
Senior Member
Join Date: Sep 2015
Location: Location:
Plugin ID:
7028
Plugin Version:
1.1.8b
Plugin Category:
Admin Commands
Plugin Game:
Left 4 Dead
Plugin Dependencies:
    Servers with this Plugin:
    4 
    Plugin Description:
    Use sm_defib or sm_vdefib to defib via menu.
    Old 04-06-2020 , 10:18   [L4D2] Defibrillate via Menu
    Reply With Quote #1

    -= Description =-


    This plugin allows admins with the SLAY flag to defibrillate dead bodies with a menu and bring survivors back to life.
    Combine with an external no-dead-body-use respawn plugin so you can bring people back with the in-game accessible method or externally.


    -= How to Use =-

    sm_defib will open 2 menus in total.
    The first one will ask for you to choose a dead body located in the map. The second will then ask for you to choose a dead person. If done correctly, the client will then be instantly defibbed in the location where the body used to be.
    It does not matter whether the body and client are different characters - a Nick client can be defibbed in the spot of a Coach body!

    sm_vdefib will only open 1 menu, asking for you to choose a dead body located in the map.
    Unlike sm_defib, this method can fail in situations where duplicates of survivors roam around.

    sm_autodefib will automatically choose the nearest indexed client and body to defib. By default, this will account for the client and body's character in-code (and not model).

    sm_telebody will teleport all bodies to your location.

    The autotimer defibs will start for every survivor that dies and count down by themselves.
    However, once a timer starts, it can not be stopped, and once a survivor dies before the autotimers are enabled, they have to be manually defibbed.
    The autotimer can also be configured to:
    - Keep count of how many times a victim keeps dying due to a map death zone, then stop auto-defibbing them if they reach the max amount of early deaths.
    - Adjust the 'check for safety' timer responsible for checking whether the auto-defibbed victim had a too-early death or not.
    - Teleport them to:
    [Mode 1] The nearest living survivor that is on ground.
    [Mode 2] A periodically-saved location on static, non-changeable geometry.

    The temporary godmode given to autodefibbed survivors has a cvar to control how long it lasts.
    Code:
    Tip:
    The starting weapon of the survivor after coming back is decided by the survivor itself, not the body. 
    Thus, defibbing Zoey, who had a frying pan, via Bill's body, whom died with a Pistol, 
    will still keep Zoey's frying pan as her secondary.

    The plugin will autogenerate a l4d2_defibmodel_cvars.cfg file in your cfg/sourcemod folder.


    -= Commands =-

    sm_defib = Open a menu with a list of death models to defibrillate. Defibs via Signature.
    sm_vdefib = Open a menu with a list of death models to defibrillate. Defibs via VScript.
    sm_autodefib = Choose the nearest indexed dead person and body to defib. Defibs via Signature. (Client-less)
    sm_telebody = Teleport all dead bodies to your position.


    -= CVARS =-

    sm_defib_death_model_blackandwhite 0.0 (1|2) {bitflag cvar} = Whether to make players defibbed by this plugin black-and-white. 0 = Disable. 1 | BaW on AutoDefib + 2 | BaW on Manual Defib

    sm_defib_death_model_autotimer 0.0 (0.0/INF) = 0.0 = Off. | Automatic timer for defibbing each player that died within the defined time limit.
    sm_defib_death_model_autotimer_mode 1 (0.0/1.0) = 0 = VScript. 1 = Signature. | Choose an automatic timer mode.

    sm_defib_death_model_autodefib_god 5.0 (0.0/inf) = 0.0 = Off. | How long the temporary godmode lasts from autodefib, in seconds.
    sm_defib_death_model_autodefib_teleport 0 (0.0/2.0) = 0 = Off. 1 = Teleport autodefibbed survivors to closest survivor on ground. 2 = Periodically save location on ground.
    sm_defib_death_model_autodefib_spawnkill 2 (0.0/inf) = 0 = Off. | How much spawnkill deaths are allowed until auto-defib stops defibbing a victim dying after defib/godmode ends?
    sm_defib_death_model_autodefib_safetytimer 1.5 (0.5/inf) = How long the 'check for safety' timer lasts.


    -= Releases =-

    Code:
    Version 1.1.8
    - Fixed ConVar descriptions getting cut off due to stupid oversights.
    Version 1.1.7
    - Now compiles with SM 1.11, albeit with non-fatal warnings.
    - Optimized ConVar-grabbing code with Silvers' AddChangeHooks method.
    - Optimized chars with static to prevent null string bottlenecks.
    Version 1.1.6
    - sm_defib_death_model_autodefib_teleport 2 now uses a traceline from the middle of the survivor that only detects static, safe ground.
    Version 1.1.5
    - Added mode 2 to sm_defib_death_model_autodefib_teleport.
     * Periodically saves locations of the client where the client is non-incapped, alive, and on the ground.
     * Will teleport them to those periodically-saved locations.
     * Recommended to use mode 2 if map has killzones, which are ignored by the godmode timer.
    - Prevented godmoded survivors from being counted when checking for teleports.
    Version 1.1.3
    - Fixed potential cases of VScript defibbing not working at times.
    - Fixed black and white cvar not applying to autodefibbing when there is no temporary godmode.
    Version 1.1.2
    - Added:
     * sm_defib_death_model_blackandwhite
    Version 1.1.0
    - Added:
     * sm_defib_death_model_autodefib_teleport
     * sm_defib_death_model_autodefib_spawnkill
     * sm_defib_death_model_autodefib_safetytimer
    - Handle timers have been replaced with a hook onto PostThink. No more timer errors!
    Version 1.0.8
    - Fixed autodefib timer attempting to give players temp god even if their bodies were invalid and they weren't defibbed.
    Version 1.0.75
    - Fixed a few minor screw-ups.
    Version 1.0.7
    - Used delete for removing/nulling timer handles instead of CloseHandle.
     * Added sm_defib_death_model_autodefib_god.
    Version 1.0.6
    - Fixed some bugs with autotimer handles being invalid.
    - Added temporary godmode for automatic defibbing.
    Version 1.0.5
    - Added autotimed defib after death, thanks to Silvers for the suggestion. By default, it is turned off.
     * Added sm_defib_death_model_autotimer and sm_defib_death_model_autotimer_mode.
    - Added <mode> parameter to sm_autodefib.
    - Fixed a few bugs.
    Version 1.0.0
    - Initial release.

    -= BUGS =-

    None that can be described, yet.


    -= Credits =-

    Silvers - For suggesting and providing base code for autotimed defibs.


    -= How to Install =-

    - (OPTIONAL) Move the .cfg file to your sourcemod folder inside the left4dead2/cfg directory. The plugin, by itself, will auto-generate the config file needed if it doesn't find one, hence this being optional.
    - (OPTIONAL) Move the .txt file to your gamedata folder inside the Sourcemod directory. The plugin, by itself, will auto-generate the gamedata needed if it doesn't find one, hence this being optional.
    - Click on Get Plugin and move the compiled .smx file to your plugins folder inside the Sourcemod directory.
    IF YOU HAVE AN OLDER GAMEDATA .txt FILE AND/OR A CONFIG .cfg FILE, YOU MUST EITHER DELETE THEM AND LET THE NEW PLUGIN AUTO-GENERATE OR REPLACE THEM WITH A NEW ONE!
    Attached Files
    File Type: sp Get Plugin or Get Source (DefibModel.sp - 154 views - 43.7 KB)
    File Type: txt l4d2_defibmodel.txt (381 Bytes, 558 views)
    File Type: cfg l4d2_defibmodel_cvars.cfg (1.4 KB, 312 views)
    __________________
    ragdoll spam, that is all

    Steam profile, where I game, obviously.
    Youtube channel, where I do Stick Death Maze animations and some other stuff.
    no plugin requests, sorry


    My Plugins:
    -search list-
    Modified Plugins:
    1 | 2 | 3 | 4

    Last edited by Shadowysn; 09-08-2023 at 21:04. Reason: Updated to Version 1.1.8b to fix SM 1.11 compile warnings
    Shadowysn is offline
    Silvers
    SourceMod Plugin Approver
    Join Date: Aug 2010
    Location: SpaceX
    Old 04-06-2020 , 22:31   Re: [L4D2] Defibrillate via Menu
    Reply With Quote #2

    Very nice! Great idea that's much better than respawning players out of thin air.

    Where did you get the code from to generate the gamedata file? This looks almost exactly like from one of my plugins just without methodmaps, except those plugins were private.
    __________________
    Silvers is offline
    Shadowysn
    Senior Member
    Join Date: Sep 2015
    Location: Location:
    Old 04-06-2020 , 22:52   Re: [L4D2] Defibrillate via Menu
    Reply With Quote #3

    Quote:
    Originally Posted by Silvers View Post
    Very nice! Great idea that's much better than respawning players out of thin air.

    Where did you get the code from to generate the gamedata file? This looks almost exactly like from one of my plugins just without methodmaps, except those plugins were private.
    A plus side to teleporting all dead bodies and defibbing them is that dead people get to keep their previous secondaries instead of losing them.

    I didn't actually think auto-generating a gamedata file was possible until I saw this forum post:
    https://forums.alliedmods.net/showthread.php?t=305063

    Obviously it needed a tweak, but it works. (thanks btw)

    Last edited by Shadowysn; 08-30-2020 at 04:26.
    Shadowysn is offline
    Silvers
    SourceMod Plugin Approver
    Join Date: Aug 2010
    Location: SpaceX
    Old 04-06-2020 , 23:03   Re: [L4D2] Defibrillate via Menu
    Reply With Quote #4

    Quote:
    Originally Posted by Shadowysn View Post
    A plus side to teleporting all dead bodies and defibbing them is that dead people get to keep their previous secondaries instead of losing them.
    Oh excellent! Also the whole coming back to life thing instead of just appearing, much better for immersion.

    Maybe you could add an optional cvar to control a timer and if enabled will automatically defib players after X seconds from when they died. Like 0.0=Off, any other value is time since death to defib.
    __________________
    Silvers is offline
    Shadowysn
    Senior Member
    Join Date: Sep 2015
    Location: Location:
    Old 04-07-2020 , 00:14   Re: [L4D2] Defibrillate via Menu
    Reply With Quote #5

    Quote:
    Originally Posted by Silvers View Post
    Oh excellent! Also the whole coming back to life thing instead of just appearing, much better for immersion.

    Maybe you could add an optional cvar to control a timer and if enabled will automatically defib players after X seconds from when they died. Like 0.0=Off, any other value is time since death to defib.
    That's a neat suggestion for alternative gameplay, dunno if I've time to do it though.

    Last edited by Shadowysn; 08-30-2020 at 04:25.
    Shadowysn is offline
    Silvers
    SourceMod Plugin Approver
    Join Date: Aug 2010
    Location: SpaceX
    Old 04-07-2020 , 00:56   Re: [L4D2] Defibrillate via Menu
    Reply With Quote #6

    Global:
    PHP Code:
    ConVar g_hCvarRespawn;
    Handle g_hTimerRespawn[MAXPLAYERS+1]; 
    OnPluginStart:
    PHP Code:
        g_hCvarRespawn CreateConVar("sm_defib_death_model_respawn""60.0""0.0=Off. How many seconds to wait after player death until automatic respawn."FCVAR_NOTIFY);
        
    HookEvent("round_end"Event_RoundEnd);
        
    HookEvent("player_death"Event_PlayerDeath); 
    Code
    PHP Code:
    public void OnMapEnd()
    {
        for( 
    int i 1<= MaxClientsi++ )
        {
            
    delete g_hTimerRespawn[i];
        }
    }

    public 
    void Event_RoundEnd(Event event, const char[] namebool dontBroadcast)
    {
        for( 
    int i 1<= MaxClientsi++ )
        {
            
    delete g_hTimerRespawn[i];
        }
    }

    public 
    void Event_PlayerDeath(Event event, const char[] namebool dontBroadcast)
    {
        if( 
    g_hCvarRespawn.FloatValue )
        {
            
    int client GetClientOfUserId(event.GetInt("userid"));
            if( 
    client && GetClientTeam(client) == )
            {
                
    delete g_hTimerRespawn[client];
                
    g_hTimerRespawn[client] = CreateTimer(g_hCvarRespawn.FloatValueTimerRespawnGetClientUserId(client));
            }
        }
    }

    public 
    Action TimerRespawn(Handle timerany userid)
    {
        
    int client GetClientOfUserId(userid);
        if( 
    client )
        {
            
    g_hTimerRespawn[client] = null;
            if( 
    IsPlayerAlive(client) == false )
            {
                
    Logic_RunScript("GetPlayerFromUserID(%d).ReviveByDefib()"userid);
            }
        }


    Something like that. This uses the VScript method, I don't know the difference between SDKCall and VScript methods. Should be a good starting place for you anyway if you have time.

    Thanks.
    __________________
    Silvers is offline
    Shadowysn
    Senior Member
    Join Date: Sep 2015
    Location: Location:
    Old 04-07-2020 , 03:40   Re: [L4D2] Defibrillate via Menu
    Reply With Quote #7

    Quote:
    Originally Posted by Silvers View Post
    <insert code here>
    Something like that. This uses the VScript method, I don't know the difference between SDKCall and VScript methods. Should be a good starting place for you anyway if you have time.

    Thanks.
    Wow, that's a lot of base code. Thanks a lot!

    The difference between the Signature (SDKCall) and VScript methods is that using SDKCall offers more control, is guaranteed to defib players and can defib a person with a body of a different character; only downside is that it requires a body entity alongside a client.

    VScript won't be able to work well if there are duplicate survivors; sometimes it does nothing when attempting to defib a corpse of a duplicate.

    Last edited by Shadowysn; 08-30-2020 at 04:25.
    Shadowysn is offline
    Silvers
    SourceMod Plugin Approver
    Join Date: Aug 2010
    Location: SpaceX
    Old 04-07-2020 , 03:46   Re: [L4D2] Defibrillate via Menu
    Reply With Quote #8

    Quote:
    Originally Posted by Shadowysn View Post
    Wow, that's a lot of base code. Thanks a lot!

    The difference between the Signature (SDKCall) and VScript methods is that using SDKCall offers more control, is guaranteed to defib players and can defib a person with a body of a different character; only downside is that it requires a body entity alongside a client.

    VScript won't be able to work well if there are duplicate survivors; sometimes it does nothing when attempting to defib a corpse of a duplicate.
    Ahh ok, I didn't want to bother adding the SDK method because it looked like more work to copy paste the verification checks instead of the single line VScript. SDKCall would be better then. You understand it better than I do (I'm too lazy/busy to look closely and learn how it works) so I'll leave it up to you!
    __________________
    Silvers is offline
    Shadowysn
    Senior Member
    Join Date: Sep 2015
    Location: Location:
    Old 04-07-2020 , 10:42   Re: [L4D2] Defibrillate via Menu
    Reply With Quote #9

    Quote:
    Originally Posted by Silvers View Post
    Ahh ok, I didn't want to bother adding the SDK method because it looked like more work to copy paste the verification checks instead of the single line VScript. SDKCall would be better then. You understand it better than I do (I'm too lazy/busy to look closely and learn how it works) so I'll leave it up to you!
    It's alright, I don't think I'd understand your code better too

    Last edited by Shadowysn; 08-30-2020 at 04:25.
    Shadowysn is offline
    Shadowysn
    Senior Member
    Join Date: Sep 2015
    Location: Location:
    Old 08-30-2020 , 04:25   Re: [L4D2] Defibrillate via Menu
    Reply With Quote #10

    Plugin updated to Version 1.1.0.

    Code:
    Version 1.1.0
    - Added:
     * sm_defib_death_model_autodefib_teleport
     * sm_defib_death_model_autodefib_spawnkill
     * sm_defib_death_model_autodefib_safetytimer
    - Handle timers have been replaced with a hook onto PostThink. No more timer errors!

    Last edited by Shadowysn; 08-30-2020 at 04:25.
    Shadowysn 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 16:59.


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