Raised This Month: $ Target: $400
 0% 

[L4D2] Show Tank's HP


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
DieTeetasse
Senior Member
Join Date: Jul 2009
Old 02-03-2010 , 04:42   Re: [L4D2] Show Tank's HP
Reply With Quote #7

Not tested, just wrote it down in the university:
PHP Code:
#include <sourcemod>
#pragma semicolon 1

#define HUD_INTERVAL 1.0

new bool:TankAlive false;
new 
TankClient = -1;

public 
OnPluginStart()
{
    
HookEvent("tank_spawn"Tank_Spawn_Event);
    
HookEvent("player_death"Player_Death_Event);
}

public 
Action:Tank_Spawn_Event(Handle:event, const String:name[], bool:dontBroadcast)
{
    
TankClient GetClientOfUserId(GetEventInt(event"userid"));
    
TankAlive true;

    
CreateTimer(HUD_INTERVALHUD_TimerINVALID_HANDLETIMER_REPEAT);
}

public 
Action:Player_Death_Event(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    if (
client == TankClient)
    {
        
TankClient = -1;
        
TankAlive false;
    }
}

public 
Action:HUD_Timer(Handle:timer)
{    
    
ShowHUD();

    if(!
TankAlive) return Plugin_Stop;
    return 
Plugin_Continue;
}

ShowHUD()
{
    if (!
IsClientInGame(TankClient)) return;
    if (!
IsPlayerAlive(TankClient)) return;

    new 
String:text[128];
    new 
Handle:HUD CreatePanel();

    
DrawPanelText(HUD"Tank Info:");
    
DrawPanelText(HUD"##################");

    if (
IsFakeClient(TankClient)) text "Player: AI";
    else 
Format(textsizeof(text), "Player: %N"TankClient);

    
DrawPanelText(HUDtext);

    new 
health GetEntProp(TankClientProp_Send"m_iHealth");
    
Format(textsizeof(text), "Health: %d"health);

    
DrawPanelText(HUDtext);

    for(new 
client 1client MaxClients+1client++)
    {
        if (!
IsClientInGame(client)) continue;
        if (
IsFakeClient(client)) continue;
        if (
client == TankClient) continue;

        
SendPanelToClient(HUDclientHUDHandler3);
    }
}  


public 
HUDHandler(Handle:menuMenuAction:actionparam1param2)
{

__________________
DieTeetasse is offline
 



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 09:36.


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