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_hSpeed, Handle:g_hSpeed2, bool:g_iSpeed, g_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 client, int 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(client, 10);
return Plugin_Handled;
}
public int MenuHandler(Menu menu, MenuAction action, int param1, int param2)
{
if (action == MenuAction_Select)
{
char info[40];
bool found = menu.GetItem(param2, info, sizeof(info));
PrintToConsole(param1, "You selected item: %d (found? %d info: %s)", param2, found, info);
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", param1, param2);
}
else if (action == MenuAction_End)
{
delete menu;
}
}
Edit: Also attached plugin file