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

[L4D2]Get/set player health?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
gilmon
Senior Member
Join Date: Feb 2011
Location: China
Old 08-20-2014 , 09:31   [L4D2]Get/set player health?
Reply With Quote #1

I know there's a simple way like this but sometime dont't work.

PHP Code:
public AutoFixHealth()
{
    
CreateTimer(60.0Fixhealth_TIMER_REPEAT);
}

public 
Action:Fixhealth(Handle:timer)
{
      for (new 
1<= MaxClientsi++)
      {
         if (
IsClientInGame(i) && (GetClientTeam(i) == 2) && !IsFakeClient(i))
         {
                      if(
GetEntProp(targetProp_Data"m_iHealth") > 100)
                  {
                          
SetEntProp(targetProp_Send"m_iHealth"100);
                      }
             }
      }

And this will not work right when player incapacitated,will also set to 100.any help about it? if always check player is stand/incapacitated there will a lot of code.
gilmon is offline
Send a message via MSN to gilmon
xerox8521
Senior Member
Join Date: Sep 2011
Old 08-20-2014 , 18:53   Re: [L4D2]Get/set player health?
Reply With Quote #2

PHP Code:
GetEntProp(iProp_Send"m_isIncapacitated"1) == 1// player is incapped 

Last edited by xerox8521; 08-20-2014 at 18:53.
xerox8521 is offline
gilmon
Senior Member
Join Date: Feb 2011
Location: China
Old 08-21-2014 , 06:34   Re: [L4D2]Get/set player health?
Reply With Quote #3

Thanks,that's very good way to deal it.
gilmon is offline
Send a message via MSN to gilmon
gilmon
Senior Member
Join Date: Feb 2011
Location: China
Old 08-21-2014 , 06:54   Re: [L4D2]Get/set player health?
Reply With Quote #4

Still need another help,anyone know the painpills health type? that one is not m_iHealth. "m_healthBuffer"?

Last edited by gilmon; 08-21-2014 at 06:55.
gilmon is offline
Send a message via MSN to gilmon
Mr. Zero
Veteran Member
Join Date: Jun 2009
Location: Denmark
Old 08-21-2014 , 10:54   Re: [L4D2]Get/set player health?
Reply With Quote #5

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(clientProp_Send"m_healthBuffer") - ((GetGameTime() - GetEntPropFloat(clientProp_Send"m_healthBufferTime")) * GetConVarFloat(painPillsDecayCvar))) - 1;
    return 
tempHealth 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(clientProp_Send"m_isIncapacitated"1);

More various L4D stock functions can be found here.
Mr. Zero is offline
gilmon
Senior Member
Join Date: Feb 2011
Location: China
Old 08-22-2014 , 04:17   Re: [L4D2]Get/set player health?
Reply With Quote #6

Thanks for the help,will check more about it.
gilmon is offline
Send a message via MSN to gilmon
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 16:55.


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