Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- You need to have the two images in your 'sprites' folder inside the store folder. You can also use your own image but you'll have to amend the code in order to make bar inside the image and other changes. The link for the files is here: http://www.mediafire.com/folder/xbvptwd35o5m3/sprites
- last updated: 3/31/2021
- - Changed timer to Script::ScriptProcess function.
- -Shy
- */
- // Remove the health and armour bar from the hud
- Hud.RemoveFlags(HUD_FLAG_HEALTH);
- // official function, scriptload
- function Script::ScriptLoad()
- {
- //Show the armor and UI health to the client
- ShowHealth();
- }
- function Script::ScriptProcess()
- {
- updateHealthVal(); //better than a timer, remember to not use the function two times in your scripts or different files even!
- }
- function updateHealthVal()
- {
- local plr = World.FindLocalPlayer();
- local H = plr.Health, A = plr.Armour;
- UI.ProgressBar("HPBAR").Value = H; //updatethe value again
- UI.Label("Bar").Text = H; //update the player's health label again
- UI.ProgressBar("ARMBAR").Value = A; //update armour value
- UI.Label("ABar").Text = A; //update text
- }
- // the main function which'll show Armour & health bar
- function ShowHealth()
- {
- local plr = World.FindLocalPlayer(); // find player (client side)
- local H = plr.Health; // player's Hp
- local A = plr.Armour; // PLAYER'S Armour
- //Health main canvas
- UI.Canvas({
- id = "canvy"
- align = "bottom_left"
- children = [
- UI.Sprite({
- id = "heal"
- file = "HPBar.png" /* loading sprite downloaded from sprites folder in the above provided link, if you haven't added any sprite, the system will throw error */
- align = "hud_top"
- move = { down = 92, left = 320}
- Size = VectorScreen( 270, 60 )
- })
- //ProgressBar which'll show health
- UI.ProgressBar({
- id = "HPBAR"
- BackgroundShade = 0.2
- align = "hud_top"
- MaxValue = 100
- Thickness = 2
- selectedColour = Colour( 255, 0, 0 )
- StartColour = Colour( 255, 0, 0 )
- EndColour = Colour( 0, 210, 0 )
- Size = VectorScreen(63, 23)
- Value = H // reduces along with the health
- move = { down = 118, left = 226}
- })
- // label shows the hp player has
- UI.Label({
- id = "Bar"
- align = "hud_top"
- Text = H
- TextColour = Colour( 255, 255, 255 )
- FontFlags = GUI_FFLAG_BOLD | GUI_FFLAG_OUTLINE
- FontSize = 12
- move = { down = 117, left = 228}
- })
- ]
- })
- /* The following is same as the above health canvas, just sprites are changed and value is set to armour */
- UI.Canvas({
- id = "acanvy"
- align = "bottom_left"
- children = [
- UI.Sprite({
- id = "arm"
- file = "ArmourBar.png"
- align = "hud_top"
- move = { down = 92, left = 200}
- Size = VectorScreen( 270, 60 )
- })
- UI.ProgressBar({
- id = "ARMBAR"
- BackgroundShade = 0.2
- align = "hud_top"
- MaxValue = 100
- Thickness = 2
- selectedColour = Colour( 160, 160, 160 )
- StartColour = Colour( 160, 160, 160 )
- EndColour = Colour( 160, 160, 160 )
- Size = VectorScreen(63, 23)
- Value = A
- move = { down = 120, left = 106}
- })
- UI.Label({
- id = "ABar"
- align = "hud_top"
- Text = A
- TextColour = Colour( 255, 255, 255 )
- FontFlags = GUI_FFLAG_BOLD | GUI_FFLAG_OUTLINE
- FontSize = 12
- move = { down = 119, left = 107}
- })
- ]
- })
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement