View Single Post
  #9  
Old 08-11-2011, 02:00 PM
Adddeeee Adddeeee is offline
Registered User
Join Date: Aug 2011
Posts: 30
Adddeeee is on a distinguished road
Thank you for your replies earlier

I managed to get my own images shown instead of the default hearts. Although, we've decided to use a health bar instead of just images.

But I'm not really a fan of the onTimeout function used. Feels like it could be done without a timer running constantly?

Isn't there any event that handels onPlayerHurt or do I need to write such an event by myself?

Here's the code we use:

PHP Code:
//#CLIENTSIDE
function onCreated()
{
  new 
GuiControlProfile("TextProfile"
  {
    
fontcolor "0 0 0";
    
fonttype "Arial";
    
fontsize 25;
    
fontstyle "b";
  }
    
  new 
GuiProgressCtrl("HealthControl_Bar"
  {
    
profile GuiBlueProgressProfile;
    
width 360;
    
height 40;
    
screenwidth width 20;
    
10;
    
progress player.hearts/player.fullhearts;
    
    new 
GuiTextCtrl("HealthConrol_Text"
    {
      
profile TextProfile;
      
HealthControl_Bar.width this.width 2;
      
10;
      
height 20;
      
width 80;
      
text player.hearts SPC "/" SPC player.fullhearts;
    } 
  }
  
  
onTimeout();
}

function 
onTimeout()
{
  
HealthControl_Bar player.hearts/player.fullhearts;
  
HealthControl_Text.text player.hearts SPC "/" SPC player.fullhearts;
  
setTimer(0.5);

Reply With Quote