SA-Symon

Armour Help

Recommended Posts

function loadd()
        dxDrawLine(471 - 1, 358 - 1, 471 - 1, 411, tocolor(254, 254, 254, 254), 1, false)
        dxDrawLine(895, 358 - 1, 471 - 1, 358 - 1, tocolor(254, 254, 254, 254), 1, false)
        dxDrawLine(471 - 1, 411, 895, 411, tocolor(254, 254, 254, 254), 1, false)
        dxDrawLine(895, 411, 895, 358 - 1, tocolor(254, 254, 254, 254), 1, false)
        dxDrawRectangle(471, 358, 424, 53, tocolor(0, 0, 0, 182), false) --------- DX
        dxDrawRectangle(476, 360, 415, 47, tocolor(5, 76, 183, 144), false) --------progressbar=100
		dxDrawRectangle(476, 360, 5, 47, tocolor(5, 76, 183, 144), false)-----progressbar=0
        dxDrawText("WEARING ARMOUR (0%)", 486, 368, 871, 411, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "left", "top", false, false, false, false, false)
    end
addEventHandler("onClientRender", root, loadd)


local unlerp = function(from,to,lerp) return (lerp-from)/(to-from) end
 
function dxDrawProgressBar( startX, startY, width, height, progress, color, backColor )
        local progress = math.max( 0, (math.min( 100, progress) ) )
        local wBar = width*.18
        for i = 0, 4 do
                --back
                local startPos = (wBar*i + (width*.025)*i) + startX
                dxDrawRectangle( startPos, startY, wBar, height, backColor )
                --progress
                local eInterval = (i*20)
                local localProgress = math.min( 1, unlerp( eInterval, eInterval + 20, progress ) )
                        if localProgress > 0 then
                                dxDrawRectangle( startPos, startY, wBar*localProgress, height, color )
                        end
        end
end

i need when i use armour it's shown Progress count from 0 to 100

setTimer(addArmour, 5000, 1)

Share this post


Link to post

You can use .. to use variables in strings.

Just like this:

outputChatBox("You have "..getPedArmor(localPlayer).."% armour") 

and you can calculate the length of a dxRectangle with this formula:

maxLength*(currentValue/maxValue)

At armour it looks like this:

maxLength*(getPedArmor(localPlayer)/100)

Whereas getPedArmor is your current value, of how much armor a player has, and 100 is the max, since a full armor has a value of 100. The length can be decided by you. 

Share this post


Link to post
2 hours ago, WorthlessCynomys said:

You can use .. to use variables in strings.

Just like this:


outputChatBox("You have "..getPedArmor(localPlayer).."% armour") 

and you can calculate the length of a dxRectangle with this formula:

maxLength*(currentValue/maxValue)

At armour it looks like this:

maxLength*(getPedArmor(localPlayer)/100)

Whereas getPedArmor is your current value, of how much armor a player has, and 100 is the max, since a full armor has a value of 100. The length can be decided by you. 

I didn't understand u

Can u explain to me, Please ?

Share this post


Link to post

Something like this to get the player health.

local armor = math.ceil(getPedArmor(localPlayer))

 

Share this post


Link to post
11 hours ago, mazarati21 said:

Something like this to get the player health.


local armor = math.ceil(getPedArmor(localPlayer))

 

getting armour working fine and everything

but i want add when player open inventory to use armour when he start use it this Gui shown for player WEARING ARMOUR (0 To 100%)

Share this post


Link to post

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.