Raised This Month: $29 Target: $400

Getting Client's Max Health

Post New Thread Reply   
Thread Tools Display Modes
Author Message
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.


Could I get it to work using m_iMaxHealth and GetEntProp?

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

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
Veteran Member
Join Date: Nov 2015
Location: Middle of Nowhere
Old 05-16-2017 , 21:57   Re: Getting Client's Max Health
Reply With Quote #3

Originally Posted by Pruppet View Post
+1, but change it to Prop_Send if it spams errors with Prop_Data.
cravenge is offline
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:

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 / coffee)
nosoop is online now
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

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 06:48.

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