Jump to content

LoadScreen ( transferBox in DX_bar-progress )


#RooTs

Recommended Posts

I want to know if there is any way to make this example in DX
 

local function progressChange(downloadedSize, totalSize)
    if not data.browser then
        return false
    end
    if isVisible == false then
        showTransferBox()
    else
        local percentage = floor(min((downloadedSize / totalSize) * 100, 100))
        executeBrowserJavascript(data.browser, "document.querySelector('.bar-progress').style.width = '" .. percentage .. "%'")
    end
end
addEventHandler("onClientTransferBoxProgressChange", root, progressChange)


I want to make a slash in DX

my example:
 

--maybe in Render ??
addEventHandler("onClientTransferBoxProgressChange", root, function(downloadedSize, totalSize)
    local percentage = math.min((downloadedSize / totalSize) * 100, 100)
    dxDrawImage(botX+sizeX+343, botX2+sizeX2+701, 592/100*percentage, 6, 'assets/progress_bar.png', 0, 0, 0, tocolor(43, 171, 226, 255), true)
end)

--is it possible to make it inside the render?
addEventHandler("onClientRender", root, function(downloadedSize, totalSize)

 

Edited by #RooTs
Link to comment
  • #RooTs changed the title to LoadScreen ( transferBox in DX_bar-progress )

From your description I understand that you want to draw a progress bar using DX functions. Yes, you can do that! Please take a look at the wiki page of the dxDrawImage function. There you will see that it has to be put inside of an onClientRender event handler to function.

I recommend you to put at least two rectangles: one for the background of the loading bar and another for the region that fills it out.

local barx = 100
local bary = 100
local barw = 100
local barh = 20
local barvisible = true
local barprogress = 0.5
local barbgcolor = tocolor(255, 255, 255, 255)
local barfillcolor = tocolor(255, 0, 0, 255)

addEventHandler("onClientRender", root, function()
    if not (barvisible) then return end
    dxDrawRectangle( barx, bary, barw, barh, barbgcolor )
    dxDrawRectangle( barx, bary, math.floor(barw * barprogress), barh, barfillcolor )
  end
);

 

Edited by The_GTA
Link to comment
6 hours ago, The_GTA said:
...

addEventHandler("onClientTransferBoxProgressChange", root, function(size, total)
    barprogress = ( size / total )
  end
)

addEventHandler("onClientTransferBoxVisibilityChange", root, function(vis)
    barvisible = vis
  end
)

barvisible = isTransferBoxVisible()

 


what variable do I put in DX?
addEventHandler("onClientTransferBoxProgressChange", root, function(size, total)
    barprogress = ( size / total )
  end
)

addEventHandler("onClientTransferBoxVisibilityChange", root, function(vis)
    barvisible = vis
  end
)

barvisible = isTransferBoxVisible()

dxDrawImage(botX+sizeX+343, botX2+sizeX2+701, 592/100*barvisible, 6, 'assets/progress_bar.png', 0, 0, 0, tocolor(43, 171, 226, 255), true)
--or
dxDrawImage(botX+sizeX+343, botX2+sizeX2+701, 592/100*barprogress, 6, 'assets/progress_bar.png', 0, 0, 0, tocolor(43, 171, 226, 255), true)

sorry, but I confused 

  • Thanks 1
Link to comment

Please put the barprogress variable and use the script I gave you as template. Put the following line and other drawing code...

dxDrawImage(botX+sizeX+343, botX2+sizeX2+701, 592/100*barprogress, 6, 'assets/progress_bar.png', 0, 0, 0, tocolor(43, 171, 226, 255), true)

... into the onClientRender event handler which is about line 13 of my script.

Also, do not use dxDrawImage without dxCreateTexture.

Edited by The_GTA
  • Like 1
Link to comment

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...