View Single Post
TheDanner
Junior Member
Join Date: Mar 2009
Old 12-14-2009 , 23:46   Re: [L4D2] Black and White on Defib
Reply With Quote #9

A while back I wrote a small plugin to tell me everyone's HP. This post had the formula; changing it around a bit comes up with:

(I noticed that a lot of this was unnecessary, particularly because I completely missed that I was doing hp + (time / decay) - (time / decay). Time and decay aren't needed when setting that value.)

PHP Code:
SetTempHealth(clienthp)
{
    
SetEntPropFloat(clientProp_Send"m_healthBufferTime"GetGameTime());
    
    
/*
    new Float:decay = GetConVarFloat(FindConVar("pain_pills_decay_rate"));
    new Float:time =
            (GetEntPropFloat(client, Prop_Send, "m_healthBufferTime") -
            GetGameTime()) * -1;
    
    new Float:newBuf = hp + (time / decay);
    
    new Float:newOverheal = newBuf - (time / decay);
    */
    
new Float:newOverheal hp 1.0;
    
SetEntPropFloat(clientProp_Send"m_healthBuffer"newOverheal);

To test:
PHP Code:
RegConsoleCmd("sm_tmp"Command_SetTemp"sm_tmp [new hp] - Sets your temp health.  Get rid of me before trying this in a real game");
//...
public Action:Command_SetTemp(clientargs)
{
    
decl String:arg[8];
    
GetCmdArg(1argsizeof(arg));
    
    new 
hp StringToInt(arg);
    
SetTempHealth(clienthp);
    
    return 
Plugin_Handled;


Last edited by TheDanner; 12-20-2009 at 01:35.
TheDanner is offline