Raised This Month: $138 Target: $400
 34% 

Getting Client's Max Health


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Riotline
AlliedModders Donor
Join Date: Oct 2015
Location: Half Life 3
Old 05-16-2017 , 05:10   Getting Client's Max Health
Reply With Quote #1

Is it possible to detect a client's maximum health, not their current health so I can compare if the client was hurt by something or not.

Edit:

Could I get it to work using m_iMaxHealth and GetEntProp?
__________________

Last edited by Riotline; 05-16-2017 at 05:21.
Riotline is offline
Pruppet
Junior Member
Join Date: Dec 2016
Old 05-16-2017 , 09:48   Re: Getting Client's Max Health
Reply With Quote #2

Code:
bool g_bIsPlayerDamaged[MAXPLAYERS + 1];

if (GetClientHealth(client) < GetEntProp(client, Prop_Data, "m_iMaxHealth"))
{
	g_bIsPlayerDamaged[client] = true;
	
	// Do code.
}

if (g_bIsPlayerDamaged[client])
{
	// Do code.
}
Untested, but should work
__________________
Contact me on Steam for private plugins.
Pruppet is offline
cravenge
Veteran Member
Join Date: Nov 2015
Location: Black Hole
Old 05-16-2017 , 21:57   Re: Getting Client's Max Health
Reply With Quote #3

Quote:
Originally Posted by Pruppet View Post
[...]
+1, but change it to Prop_Send if it spams errors with Prop_Data.
cravenge is offline
nosoop
Veteran Member
Join Date: Aug 2014
Old 05-17-2017 , 00:05   Re: Getting Client's Max Health
Reply With Quote #4

From experience, TF2 handles maximum health differently and you might not get the values you expect from the client's m_iMaxHealth property. The player resource entity should have the correct value:

Code:
stock int TF2_GetPlayerMaxHealth(int client) {
	return GetEntProp(GetPlayerResourceEntity(), Prop_Send, "m_iMaxHealth", _, client);
}
__________________
I do TF2, TF2 servers, and TF2 plugins.
I don't do DMs over Discord -- PM me on the forums regarding inquiries.
AlliedModders Releases / Github / TF2 Server / Donate (BTC / BCH)
nosoop is offline
xSquared
Junior Member
Join Date: Jan 2019
Old 09-10-2019 , 05:04   Re: Getting Client's Max Health
Reply With Quote #5

This is very helpful.
thanks you
__________________
xSquared/Silver's Custom Attributes:https://forums.alliedmods.net/showth...02#post2663402
xSquared is offline
Reply


Thread Tools
Display Modes

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 02:54.


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