Raised This Month: $ Target: $400
 0% 

How to get a entity(NPC) health?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
4554
Senior Member
Join Date: Aug 2009
Old 08-07-2011 , 07:35   How to get a entity(NPC) health?
Reply With Quote #1

i had a code which is:

Code:
#define HEALTH_OFFSET	100000.0

entity_set_float(ent, EV_FL_health, 10000.0+HEALTH_OFFSET);
Now i want to show everyone the health, does anyone know how to do?
4554 is offline
Old 08-10-2011, 05:44
4554
This message has been deleted by Exolent[jNr]. Reason: Don't bump until 2 weeks have passed since last post.
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 08-10-2011 , 05:55   Re: How to get a entity(NPC) health?
Reply With Quote #3

Your not supposed to bump your thread unless its been longer than 2 weeks.

Hud Message:
PHP Code:
set_hudmessage255255255);
show_hudmessage0"Entity health is %i"floatroundentity_get_floatentEV_FL_health ) ) ); 
If you want to change the position and effects then use the rest of the parametres.

Chat Message:
PHP Code:
client_print0print_chat"Entity health is %i"floatroundentity_get_floatentEV_FL_health ) ) ); 
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.

Last edited by hornet; 08-10-2011 at 06:51. Reason: Left out a parameter
hornet is offline
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 08-10-2011 , 06:31   Re: How to get a entity(NPC) health?
Reply With Quote #4

Change
[php]
Chat Message:
PHP Code:
client_print0"Entity health is %i"floatroundentity_get_floatentEV_FL_health ) ) ); 
To

[php]
Chat Message:
PHP Code:
client_print0print_chat"Entity health is %i"floatroundentity_get_floatentEV_FL_health ) ) ); 
Doc-Holiday is offline
4554
Senior Member
Join Date: Aug 2009
Old 08-10-2011 , 07:04   Re: How to get a entity(NPC) health?
Reply With Quote #5

Quote:
Originally Posted by hornet View Post
Your not supposed to bump your thread unless its been longer than 2 weeks.

Hud Message:
PHP Code:
set_hudmessage255255255);
show_hudmessage0"Entity health is %i"floatroundentity_get_floatentEV_FL_health ) ) ); 
If you want to change the position and effects then use the rest of the parametres.

Chat Message:
PHP Code:
client_print0print_chat"Entity health is %i"floatroundentity_get_floatentEV_FL_health ) ) ); 
sorry i forgot the rule
btw, thanks all
4554 is offline
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 08-10-2011 , 09:26   Re: How to get a entity(NPC) health?
Reply With Quote #6

You could use pev(ent, pev_health) since it returns an integer value, so you avoid using floatround() native.
__________________
hleV is offline
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 08-10-2011 , 09:39   Re: How to get a entity(NPC) health?
Reply With Quote #7

Quote:
Originally Posted by hleV View Post
You could use pev(ent, pev_health) since it returns an integer value, so you avoid using floatround() native.
pev health is a float also.. its get/set_user_health int value
Doc-Holiday is offline
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 08-10-2011 , 09:47   Re: How to get a entity(NPC) health?
Reply With Quote #8

Quote:
Originally Posted by Doc-Holiday View Post
pev health is a float also.. its get/set_user_health int value
Code:
pev(ent, pev_health)
will return an integer value.
__________________
hleV is offline
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 08-10-2011 , 09:50   Re: How to get a entity(NPC) health?
Reply With Quote #9

Quote:
Originally Posted by hleV View Post
Code:
pev(ent, pev_health)

will return an integer value.
it takes a float but returns an int?? interesting.
Doc-Holiday is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 08-10-2011 , 10:03   Re: How to get a entity(NPC) health?
Reply With Quote #10

Quote:
Originally Posted by Doc-Holiday View Post
it takes a float but returns an int?? interesting.
pev() returns integer values.
To get the float value, you have to pass another parameter to get the float value by-ref.
When you leave out that extra parameter and try to access a float pev value, then it is returned as an integer.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
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 03:28.


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