Raised This Month: $ Target: $400
 0% 

health


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Oneshox
BANNED
Join Date: May 2010
Location: Germany
Old 06-04-2010 , 08:45   health
Reply With Quote #1

how i can show the full health from all CT's on hud?

ex.
1 CT 70hp
2 CT 80hp

it shows:

CT's health: 150

if he lost health the hud update the hp..
Oneshox is offline
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 06-04-2010 , 09:19   Re: health
Reply With Quote #2

Simple, but not efficient method:
PHP Code:
#include <amxmodx>
#include <cstrike>

new g_max_players
public plugin_init(){
    
set_task(1.0"show_health"325236__"b")
    
g_max_players get_maxplayers()
}

public 
show_health(){
    new 
total_health
    
for(new i=1i<=g_max_playersi++){
        if(
is_user_alive(i) && cs_get_user_team(i)==CS_TEAM_CT)
            
total_health += get_user_health(i)
    }
    
set_hudmessage(00255, -1.00.106.01.00.10.1, -1)
    
show_hudmessage(0"CT Total Health: %d"total_health)

To make it more efficient you should cache alive cts, health and update it when player is damaged.
__________________
Impossible is Nothing
Sylwester is offline
Oneshox
BANNED
Join Date: May 2010
Location: Germany
Old 06-04-2010 , 09:31   Re: health
Reply With Quote #3

Thank you
Oneshox is offline
Old 06-04-2010, 10:28
hleV
This message has been deleted by hleV. Reason: Nevermind.
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 06-04-2010 , 11:12   Re: health
Reply With Quote #5

Better to use get_players.

PHP Code:
#include <amxmodx>

public plugin_init()
{
    
set_task(1.0"show_health", .flags="b")
}

public 
show_health()
{
    new 
iPlayers[32], iNumiHealth
    get_players
(iPlayersiNum"ae""CT")
    for(new 
ii<iNumi++)
    {
        
iHealth += get_user_health(iPlayers[i])
    }

    
set_hudmessage(00255, -1.00.100.0000011.00.5010.501, -1)
    
show_hudmessage(0"CT Total Health: %d"iHealth)

__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Oneshox
BANNED
Join Date: May 2010
Location: Germany
Old 06-04-2010 , 12:12   Re: health
Reply With Quote #6

how to make that it shows only in first round and remove on round end?
Oneshox 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 05:16.


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