View Single Post
Author Message
Shadowysn
Senior Member
Join Date: Sep 2015
Location: Location:
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 - 189 views - 43.7 KB)
File Type: txt l4d2_defibmodel.txt (381 Bytes, 588 views)
File Type: cfg l4d2_defibmodel_cvars.cfg (1.4 KB, 331 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