PHP Code:
/**
* Returns player temporarily health.
*
* Note: This will not work with mutations or campaigns that alters the decay
* rate through vscript'ing. If you want to be sure that it works no matter
* the mutation, you will have to detour the OnGetScriptValueFloat function.
* Doing so you are able to capture the altered decay rate and calulate the
* temp health the same way as this function does.
*
* @param client Client index.
* @return Player's temporarily health, -1 if unable to get.
* @error Invalid client index or unable to find
* pain_pills_decay_rate cvar.
*/
stock L4D_GetPlayerTempHealth(client)
{
static Handle:painPillsDecayCvar = INVALID_HANDLE;
if (painPillsDecayCvar == INVALID_HANDLE)
{
painPillsDecayCvar = FindConVar("pain_pills_decay_rate");
if (painPillsDecayCvar == INVALID_HANDLE)
{
return -1;
}
}
new tempHealth = RoundToCeil(GetEntPropFloat(client, Prop_Send, "m_healthBuffer") - ((GetGameTime() - GetEntPropFloat(client, Prop_Send, "m_healthBufferTime")) * GetConVarFloat(painPillsDecayCvar))) - 1;
return tempHealth < 0 ? 0 : tempHealth;
}
PHP Code:
/**
* Returns whether player is incapacitated.
*
* Note: A tank player will return true when in dying animation.
*
* @param client Player index.
* @return True if incapacitated, false otherwise.
* @error Invalid client index.
*/
stock bool:L4D_IsPlayerIncapacitated(client)
{
return bool:GetEntProp(client, Prop_Send, "m_isIncapacitated", 1);
}
More various L4D stock functions can be found
here.