Jump to content

[Solved]Making a bar (for health & Armour)


Xierra

Recommended Posts

Posted (edited)

Hi guys once again.

I want to make a new script, which is putting a bar. I know about the healthbar as seen on the nametag.

But If I want to make my own, how? Any ideas? (And of course not progress bar on GUI)

And if you are grateful, is it possible to put custom bars on a GUI window?

Edited by Guest
Posted

You want it as bar form?

lol srry i didnt knew it ,here i dont know how to help you

i thinked only to show a player his health

so:

Health:getElementHealth

Armor:getPlayerArmor

Here it is a example:

local rootElement = getRootElement()
local screenWidth, screenHeight = guiGetScreenSize()
local playerHealth = getElementHealth(player)
local playerArmor = getPlayerArmor(player)
 
function createText( )
dxDrawText( playerHealth, 44, screenHeight-41, screenWidth, screenHeight, tocolor ( 0, 0, 0, 255 ), 1.02, "pricedown" )
dxDrawText( playerArmor, 44, screenHeight-43, screenWidth, screenHeight, tocolor ( 255, 255, 255, 255 ), 1, "pricedown" )
 
 
-- etc im to lazy 

Posted (edited)

Ahh thanks for the reference.

I'll take a look. Thanks 50p (and your peds script, it's cool!)

Edit:

I have made it! Sucess!

But It only renders once, how should I make it update everytime when I reduced my health or armor?

Script (client):

local health = getElementHealth( getLocalPlayer() )
local lineLength1 = 114 * ( health / 100 )
 
local armor = getPedArmor( getLocalPlayer() )
local lineLength2 = 114 * ( armor / 100 )
 
-- Direct X Drawings
addEventHandler("onClientRender",getRootElement(),
function()
dxDrawText("50",646.0,731.0,694.0,766.0,tocolor(0,255,255,175),1.0,"bankgothic","right","top",false,false,false)
dxDrawRectangle(818.0,725.0,lineLength2,14.0,tocolor(200,200,200,200),true)
dxDrawRectangle(818.0,745.0,114.0,14.0,tocolor(50,0,0,150),false)
dxDrawText("50",684.0,731.0,732.0,766.0,tocolor(0,255,255,175),1.0,"bankgothic","left","top",false,false,false)
dxDrawText("|",665.0,731.0,677.0,762.0,tocolor(255,200,0,200),1.0,"bankgothic","left","top",false,false,false)
dxDrawText("50",611.0,731.0,659.0,766.0,tocolor(0,255,255,175),1.0,"bankgothic","right","top",false,false,false)
dxDrawRectangle(818.0,725.0,114.0,14.0,tocolor(100,100,100,150),false)
dxDrawRectangle(818.0,745.0,lineLength1,14.0,tocolor(175,0,0,200),false)
end
)

Credits to R3mp for the guieditor.

Tips: those DX texts are for finding ammo and max ammo, plus one more text for throwing weapons and shotgun.

I'll ask that after I made the bar first. That will be later. ;)

Edited by Guest
Posted

Anyone?

I tried to make a timer, but instead just keep creating, not updating. :(

Anyway, does DX drawings detect resolutions?

Posted
Anyone?

I tried to make a timer, but instead just keep creating, not updating. :(

Anyway, does DX drawings detect resolutions?

this is weird, never happend to me b4, im trying many things and nothing works :S

Posted

The code which gets health and armor of player should be put into the same function where drawing code is. And DX drawings don't detect resolutions, but you can use guiGetScreenSize().

Posted

Yes! It's working nicely!

Thanks Doomed_space_marine, you really helped me! Later I'll try for the weapon ammo DX text.

Thanks to everyone who helped me. Issue Solved.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...