AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How to get a entity(NPC) health? (https://forums.alliedmods.net/showthread.php?t=164089)

4554 08-07-2011 07:35

How to get a entity(NPC) health?
 
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?

hornet 08-10-2011 05:55

Re: How to get a entity(NPC) health?
 
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 ) ) ); 


Doc-Holiday 08-10-2011 06:31

Re: How to get a entity(NPC) health?
 
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 ) ) ); 


4554 08-10-2011 07:04

Re: How to get a entity(NPC) health?
 
Quote:

Originally Posted by hornet (Post 1529443)
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

hleV 08-10-2011 09:26

Re: How to get a entity(NPC) health?
 
You could use pev(ent, pev_health) since it returns an integer value, so you avoid using floatround() native.

Doc-Holiday 08-10-2011 09:39

Re: How to get a entity(NPC) health?
 
Quote:

Originally Posted by hleV (Post 1529546)
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

hleV 08-10-2011 09:47

Re: How to get a entity(NPC) health?
 
Quote:

Originally Posted by Doc-Holiday (Post 1529556)
pev health is a float also.. its get/set_user_health int value

Code:
pev(ent, pev_health)
will return an integer value.

Doc-Holiday 08-10-2011 09:50

Re: How to get a entity(NPC) health?
 
Quote:

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

will return an integer value.

it takes a float but returns an int?? interesting.

hornet 08-10-2011 09:56

Re: How to get a entity(NPC) health?
 
Yes that's true but for whatever reason he might only require Engine for the rest of his plugin ... saves using another module.

Doc-Holiday 08-10-2011 09:58

Re: How to get a entity(NPC) health?
 
Quote:

Originally Posted by hornet (Post 1529572)
Yes that's true but for whatever reason he might only require Engine for the rest of his plugin ... saves using another module.

90% of the the time all the modules are running... other plugins use them.


All times are GMT -4. The time now is 03:28.

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