[Release] GUI Health & Armour Bar

Started by Anik, Mar 29, 2017, 10:35 AM

Previous topic - Next topic

Anik

Credits :-

GUI Health & Armour Bar
This snippet replaces the native Health and armour. And adds new GUI Health And armour bar

Codes Here :-

Client side :-

function Script::ScriptLoad()
{
CreateNameTag();
}

function Script::ScriptProcess( )
{
if( NameTag.Spawned )
{
local plr = World.FindLocalPlayer();
if ( plr.Health.tointeger() != NameTag.HP )
{
NameTag.HPprogressBar.Value = plr.Health;
NameTag.HP = plr.Health;
NameTag.HPLabel.Text = plr.Health.tointeger()+"%";
}
if( plr.Armour > 2 && (!(NameTag.ArmourprogressBar.Flags & GUI_FLAG_VISIBLE))) NameTag.ArmourprogressBar.AddFlags( GUI_FLAG_VISIBLE );
if (NameTag.ArmourprogressBar.Flags & GUI_FLAG_VISIBLE)
{
if ( plr.Armour.tointeger() != NameTag.Armour )
{
NameTag.ArmourLabel.Text = plr.Armour.tointeger()+"%";
NameTag.ArmourprogressBar.Value = plr.Armour;
NameTag.Armour = plr.Armour;
if( plr.Armour < 3 ) NameTag.ArmourprogressBar.RemoveFlags( GUI_FLAG_VISIBLE );
}
}
else NameTag.ArmourprogressBar.RemoveFlags( GUI_FLAG_VISIBLE );
}
}

NameTag <-
{
HPprogressBar = null
ArmourprogressBar = null
HPLabel = null
Spawned = false
HP = 100
Armour = 0
ArmourLabel = null
}

function DelNameTag( )
{
NameTag.HPprogressBar = null;
NameTag.ArmourprogressBar = null;
NameTag.HPLabel = null;
NameTag.ArmourLabel = null;
NameTag.Spawned = false;
NameTag.HP = 100;
NameTag.Armour = 0;
}

function CreateNameTag( )
{
local plr = World.FindLocalPlayer(), scr = GUI.GetScreenSize();

NameTag.HPprogressBar = GUIProgressBar();
NameTag.HPprogressBar.Pos = VectorScreen( scr.X * 0.763, scr.Y * 0.148 );
NameTag.HPprogressBar.Size = VectorScreen( scr.X * 0.07, scr.Y * 0.05 );
NameTag.HPprogressBar.StartColour = Colour( 40, 255, 40 );
NameTag.HPprogressBar.EndColour = Colour( 180, 110, 110 );
NameTag.HPprogressBar.MaxValue = 100;
NameTag.HPprogressBar.BackgroundShade = 0.3;
NameTag.HPprogressBar.Thickness = 2;

NameTag.ArmourprogressBar = GUIProgressBar();
NameTag.ArmourprogressBar.Pos = VectorScreen( scr.X * 0.65, scr.Y * 0.148 );
NameTag.ArmourprogressBar.Size = VectorScreen( scr.X * 0.07, scr.Y * 0.05 );
NameTag.ArmourprogressBar.StartColour = Colour( 40, 40, 180 );
NameTag.ArmourprogressBar.EndColour = Colour( 40, 40, 0 );
NameTag.ArmourprogressBar.MaxValue = 100;
NameTag.ArmourprogressBar.BackgroundShade = 0.3;
NameTag.ArmourprogressBar.Thickness = 2;

NameTag.HPLabel = GUILabel( );
NameTag.HPLabel.Text = "100%";
NameTag.HPLabel.Pos = VectorScreen( scr.X * 0.007, scr.X * 0.005 );
NameTag.HPLabel.FontSize = scr.Y * 0.022;
NameTag.HPLabel.TextColour = Colour( 255, 255, 255 );

NameTag.ArmourLabel = GUILabel( );
NameTag.ArmourLabel.Text = "100%";
NameTag.ArmourLabel.Pos = VectorScreen( scr.X * 0.007, scr.X * 0.005 );
NameTag.ArmourLabel.FontSize = scr.Y * 0.022;
NameTag.ArmourLabel.TextColour = Colour( 255, 255, 255 );

NameTag.HPprogressBar.AddChild( NameTag.HPLabel );
NameTag.ArmourprogressBar.AddChild( NameTag.ArmourLabel );

if( plr.Armour < 3 ) NameTag.ArmourprogressBar.RemoveFlags( GUI_FLAG_VISIBLE );
NameTag.Spawned = true;
}

function GUI::GameResize(width, height)
{
local scr = GUI.GetScreenSize();
NameTag.HPprogressBar.Pos = VectorScreen( scr.X * 0.763, scr.Y * 0.148 );
NameTag.HPprogressBar.Size = VectorScreen( scr.X * 0.07, scr.Y * 0.05 );
NameTag.ArmourprogressBar.Pos = VectorScreen( scr.X * 0.65, scr.Y * 0.148 );
NameTag.ArmourprogressBar.Size = VectorScreen( scr.X * 0.07, scr.Y * 0.05 );
NameTag.HPLabel.FontSize = scr.Y * 0.022;
NameTag.ArmourLabel.FontSize = scr.Y * 0.022;
NameTag.HPLabel.Pos = VectorScreen( scr.X * 0.007, scr.X * 0.005 );
NameTag.ArmourLabel.Pos = VectorScreen( scr.X * 0.007, scr.X * 0.005 );
}

Video :-

https://www.youtube.com/watch?v=0VWNElddL5g#

Zone_Killer

Bohemia Is God Of Punjabi Rap
Yo Yo Honey Singh tou chutiya hai

vito

Awesome, I hope devs will made in next update option to hide native GUI.

Anik

Quote from: vito on Mar 29, 2017, 10:57 AMAwesome, I hope devs will made in next update option to hide native GUI.
Hope so. :)

Luis_Labarca

Quote from: vito on Mar 29, 2017, 10:57 AMAwesome, I hope devs will made in next update option to hide native GUI.

If you hope and add this option we all want this option

@Anik  good job ;)
My server RP
IP: 51.222.28.159:8194

Anik

Quote from: h4fmaster on May 24, 2017, 04:52 PMHow can I do that helpme ?

Just Create a new file called main.nut at /store/script/ and copy-paste this code in the file

Mohamed Boubekri

Niice, one question:-
Thi its Work For Rel003 ?
| What now ? | Not yet ! |
Morrocan:- [ 🇲🇦 ].

!


Discord: zeus#5155