AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   health (https://forums.alliedmods.net/showthread.php?t=128697)

Oneshox 06-04-2010 08:45

health
 
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..

Sylwester 06-04-2010 09:19

Re: health
 
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.

Oneshox 06-04-2010 09:31

Re: health
 
Thank you

ConnorMcLeod 06-04-2010 11:12

Re: health
 
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)



Oneshox 06-04-2010 12:12

Re: health
 
how to make that it shows only in first round and remove on round end?


All times are GMT -4. The time now is 05:16.

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