Author Topic: GUI: Health&Armour Bar!  (Read 2882 times)

Atheros

  • Newbie
  • *
  • Posts: 24
  • Karma: +4/-5
    • View Profile
GUI: Health&Armour Bar!
« on: March 30, 2016, 09:04:51 am »
Code: [Select]
RED <- Colour( 250, 20, 20 );
BLACK <- Colour( 100, 100, 100 );
GREEN <- Colour( 0, 255, 0 );


function onClientSpawn(id)
{
local pos2 = VectorScreen(ScreenWidth/2-545,ScreenHeight/2-850);
local size2 = ScreenSize(450,30);
local pos3 = VectorScreen(ScreenWidth/2-545,ScreenHeight/2-880);
local size3 = ScreenSize(450,30);
local pos = VectorScreen(ScreenWidth/2-245,ScreenHeight/2-50);
local size = ScreenSize(450,30);
Bars <- GUIProgressBar(pos2,size2);
BarsA <- GUIProgressBar(pos3,size3);
Windows <- GUIWindow(pos,size,"Example Window");
AddGUILayer( Windows );
Windows.AddChild( Bars );
Windows.AddChild( BarsA );
Windows.Alpha = 0;
Bars.MaxValue = 100;
BarsA.MaxValue = 100;
Bars.EndColour = GREEN;
Bars.StartColour = RED;
BarsA.EndColour = BLACK;
BarsA.StartColour = RED;
Bars.Alpha = 255;
BarsA.Alpha = 255;
Bars.Value = 0;
BarsA.Value = 0;
Bars.Visible = true;
BarsA.Visible = true;
SetHUDItemEnabled( HUD_HEALTH, false );
SetHUDItemEnabled( HUD_WANTED, false );
SetHUDItemEnabled( HUD_ARMOUR, false );
return 0;
}
function onClientRender() {
if ( Bars ) Bars.Value = FindLocalPlayer().Health.tostring();
if ( BarsA ) BarsA.Value = FindLocalPlayer().Armour.tostring();
if (Bars)
{
Bars.Value = FindLocalPlayer().Health;
}
if (BarsA)
{
BarsA.Value = FindLocalPlayer().Armour;
}

}

Save it to health.nut, and add to script.xml
|
v

<script file="health.nut" client="1" />

This will add a progress bar of health, armour when player spawns ;D

Motley

  • Full Member
  • ***
  • Posts: 253
  • Karma: +32/-34
    • View Profile
Re: GUI: Health&Armour Bar!
« Reply #1 on: March 30, 2016, 03:55:21 pm »
Nice Work  :P

You're work creates many great examples THANK YOU
« Last Edit: April 04, 2016, 05:56:27 am by Motley »

 

© Liberty Unleashed Team.