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

Player controlled heal and revive times


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Sunyata
Senior Member
Join Date: Nov 2017
Location: Wherever I am
Old 04-03-2018 , 14:49   Player controlled heal and revive times
Reply With Quote #1

Hello all,

I'm looking for a simple plugin for l4d1 & 2 that can control the heal and revive times of players on a combined "normal" and "hardcore" server. Of course I can tweak the heal and revive times for myself in the console - but only coz I'm the admin/owner of the server. However the other members/players can't do this for themselves when I'm not playing on the server.

The problem is that my server difficulty can go from a "normal" mode to "insane" mode, so the default heal and revive times are ok when played in "normal" mode, but those default heal/revive times become just too slow for the teams when playing the server on "insane" mode - so the teams almost invariable end up being either incapped or dead most of the time due to the insane influx of Special Infected. >

I would like for the players to be able to adjust the timers on heal and revive for themselves, using an "!command" such as "!healtime1" or "!revivetime3" etc - or even have the !commands locked together as "!heal_revive2" etc, done in increments of 1 - from 1 up to 5 max. The Cvars I use for the entry-level times on my "normal" server are written to my sourcemod.cfg file as this:

"sm_cvar first_aid_kit_use_duration 3"
"sm_cvar survivor_revive_duration 3"

But the timer setting in the sourcemod.cfg file becomes no good for the 'insane' mode, and has to be overridden by me when I'm playing ingame. The fastest duration I use then become these values:

"sm_cvar first_aid_kit_use_duration 1"
"sm_cvar survivor_revive_duration 1"

Any help in any way from some creative coder here would be greatly appreciated by me.

Can any of you guys help?


edit: updated paragraph 1 to include l4d 2 server

Last edited by Sunyata; 06-16-2018 at 04:39. Reason: l4d version added
Sunyata is offline
Sunyata
Senior Member
Join Date: Nov 2017
Location: Wherever I am
Old 05-23-2018 , 07:51   Re: Player controlled heal and revive times
Reply With Quote #2

I managed to code (more like hack) my own plugin for the above. I've done this out of desperation really, as no-one here at the forums has helped to date.

I have to give some credit to Silvers/Silvershot for PMing me a plugin that had some useful code in it that helped me figure out how to go about doing this. So that snippet of code alone is appreciated.

I'm not a coder, more of a hacker, but if any other coder wishes to improve/clean this up for me, then be my guest. At least it works for me. And because it works for me, I'm gonna share the code here for anyone else that wishes to use this plugin.

It works for both l4d1 & 2.

The chat command to open the menu is "!hrd" - select menu item 1 to 5 to set speed from 1 to 5 seconds. Also the default values can be overridden in a config file.

Code here:

PHP Code:

#include <sourcemod>
#define CVAR_FLAGS            FCVAR_NOTIFY
#define PLUGIN_VERSION         "1.0"

new Handle:g_hSpeedHandle:g_hSpeed2bool:g_iSpeedg_iSpeed2;

public 
Plugin:myinfo =
{
    
name "Heal & Revive Duration",
    
author "Sunyata",
    
description "Change heal and revive speed",
    
version PLUGIN_VERSION,
    
url "https://steamcommunity.com/groups/hardcore4"
}

public 
OnPluginStart()
{
    
// Cvars
    
RegConsoleCmd("sm_hrd"HealReviveMenu"heal & revive command for menu");
    
g_hSpeed CreateConVar("heal_duration_speed""5""Healing duration, sets 'first_aid_kit_use_duration' cvar"CVAR_FLAGS);
    
g_hSpeed2 CreateConVar("revive_duration_speed""5""Revive duration, sets 'survivor_revive_duration' cvar"CVAR_FLAGS);
    
CreateConVar("heal_duration_version"PLUGIN_VERSION"l4d_heal_duration plugin version"CVAR_FLAGS|FCVAR_REPLICATED|FCVAR_DONTRECORD);
    
AutoExecConfig(true"heal_and_revive_speed"); //Cvar values can also be set to override default values from the config file
    
GetCvars();
}

public 
ConVarChanged_Cvar(Handle:convar, const String:oldValue[], const String:newValue[])
{
    
GetCvars();
}

GetCvars()
{
    
g_iSpeed GetConVarInt(g_hSpeed);
    
g_iSpeed2 GetConVarInt(g_hSpeed2);
    
SetConVarInt(FindConVar("first_aid_kit_use_duration"), g_iSpeed);
    
SetConVarInt(FindConVar("survivor_revive_duration"), g_iSpeed2);
}

public 
Action HealReviveMenu(int clientint args)
{
    
Menu menu = new Menu(MenuHandler);
    
menu.SetTitle("HEAL & REVIVE DURATION");
    
menu.AddItem("1""  1 second");
    
menu.AddItem("2""  2 seconds");
    
menu.AddItem("3""  3 seconds");
    
menu.AddItem("4""  4 seconds"); 
    
menu.AddItem("5""  5 seconds"); 
    
// note - only integer values 1 to 5 should be used else animations will play incorrectly
    
PrintToChat(client"Select 1 to 5 to set heal and revive speed");
    
menu.ExitButton false;
    
menu.Display(client10);
    return 
Plugin_Handled;
}

public 
int MenuHandler(Menu menuMenuAction actionint param1int param2)
{
    if (
action == MenuAction_Select)
    {
        
char info[40];
        
bool found menu.GetItem(param2infosizeof(info));
        
PrintToConsole(param1"You selected item: %d (found? %d info: %s)"param2foundinfo);
        
ServerCommand("sm_cvar first_aid_kit_use_duration %s"info);
        
ServerCommand("sm_cvar survivor_revive_duration %s"info);
        
PrintHintTextToAll("Heal and revive duration has been changed to %s second/s"info);
    }
    else if (
action == MenuAction_Cancel)
    {
        
PrintToServer("Client %d's menu was cancelled.  Reason: %d"param1param2);
    }
    else if (
action == MenuAction_End)
    {
        
delete menu;
    }

Edit: Also attached plugin file
Attached Files
File Type: smx Heal-Revive-Speed.smx (5.4 KB, 172 views)

Last edited by Sunyata; 06-16-2018 at 04:44.
Sunyata is offline
GerPunisher_
Junior Member
Join Date: Mar 2022
Old 02-27-2023 , 23:44   Re: Player controlled heal and revive times
Reply With Quote #3

good i like it and im using it ♥
GerPunisher_ 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 10:57.


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