View Single Post
nergal
Veteran Member
Join Date: Apr 2012
Old 07-15-2014 , 12:27   Re: Versus Saxton Hale 1.43 - Now with collaboration! (Last updated 7/15/2014)
Reply With Quote #15

Here's a quick update for my healthbar thingy from Powerlord :>

How to add FF2-style Monoculus Healthbar (props to Powerlord since this is ripped from his plugin)

In the function OnMapStart() add this piece of code anywhere inside the function

PHP Code:
    FindHealthBar(); 
after that, add this global variable+function anywhere in the plugin as long as it doesn't interfere with other functions

PHP Code:
new g_healthBar = -1;
FindHealthBar()
{
    
g_healthBar FindEntityByClassname2(-1"monster_resource");
    if (
g_healthBar == -1)
    {
        
g_healthBar CreateEntityByName("monster_resource");
        if (
g_healthBar != -1DispatchSpawn(g_healthBar);
    }

the code above simply adds the healthbar, now we gotta make it work.

add this function anywhere in the plugin, as long as it doesn't interfere with other functions

PHP Code:
public UpdateBossHealth(client)
{
    new 
halebar;
    if (
IsValidClient(client)) halebar = (HaleHealthMax <= 0) ? RoundToCeil(float(HaleHealth) / HaleHealthMax 255);
    else 
halebar 0;
    
SetEntProp(g_healthBarProp_Send"m_iBossHealthPercentageByte"halebar);

That should get the healthbar to work Now there's two choices to make. Do you want the health bar to dynamically update by itself? OR Have the health bar update only when checking Hale/Boss health?

IF you want the health bar to update itself. Simply put this code inside the function
PHP Code:
public  Action:HaleTimer(Handle:hTimer
When you've located that function, put this code in it. Remember to put it somewhere that doesn't interfere with the rest of the code.
PHP Code:
    UpdateBossHealth(Hale); 
OR

If you want the health bar to update only from Health Checking, then find the following function
PHP Code:
public Action:Command_GetHP(client
After you've located it, put the UpdateBossHealth(Hale); code twice inside the function. For best results, place it the 1st one under client == Hale and switch Special
like this
OLD
PHP Code:
    if (client == Hale)
    {
        switch (
Special)
        { 
NEW
PHP Code:
if (client == Hale)
    {
        
UpdateBossHealth(Hale);
        switch (
Special)
        { 
After you've done that, place the second function check under
PHP Code:
    if (GetGameTime() >= HPTime
for example, like this!
PHP Code:
    if (GetGameTime() >= HPTime)
    {
        
UpdateBossHealth(Hale);
        
healthcheckused++;
        switch (
Special)
        { 
end tutorial!
__________________
nergal is offline