Jump to content

Help dxProgress


Jacobob14

Recommended Posts

Yes, you'll need a good knowledge of basic mathematics to get client's resolution, then get center, then divide center with number of rectangles and then draw the rectanles.

or, i don't know if its better way but you can create a guiLable in bottom-center of client's screen, then draw rectangle images inside it using images, then set image color one by one on regular intervals.

Link to comment

Just a simple progress that you can start from

local sX,sY = guiGetScreenSize() 
local progX = 200 
local progY = 25 
local moveSpeed = 3 -- per frame 
local prog = 0 
  
  
function render() 
    if prog >= progX then 
    removeEventHandler("onClientRender",root,render) 
    triggerEvent("onClientProgressFinish",localPlayer) 
    end 
  
    dxDrawRectangle((sX/2)-(progX/2)-1,(sY/2)-(progY/2)-1,progX+2,progY+2,tocolor(255,255,255,170)) -- background 
  
    prog = math.min(prog+moveSpeed,progX) -- move the progress 
    dxDrawRectangle((sX/2)-(progX/2),(sY/2)-(progY/2),prog,progY,tocolor(50,50,50,255)) -- progress 
end 
addEventHandler("onClientRender",root,render) 

Link to comment
Just a simple progress that you can start from
local sX,sY = guiGetScreenSize() 
local progX = 200 
local progY = 25 
local moveSpeed = 3 -- per frame 
local prog = 0 
  
  
function render() 
    if prog >= progX then 
    removeEventHandler("onClientRender",root,render) 
    triggerEvent("onClientProgressFinish",localPlayer) 
    end 
  
    dxDrawRectangle((sX/2)-(progX/2)-1,(sY/2)-(progY/2)-1,progX+2,progY+2,tocolor(255,255,255,170)) -- background 
  
    prog = math.min(prog+moveSpeed,progX) -- move the progress 
    dxDrawRectangle((sX/2)-(progX/2),(sY/2)-(progY/2),prog,progY,tocolor(50,50,50,255)) -- progress 
end 
addEventHandler("onClientRender",root,render) 

not work

client.lua: 1: attempt to call global 'guiGetScreenSize' ( a nil value ) 
client.lua: 1: attempt to call global 'guiGetScreenSize' ( a nil value ) 
client.lua: 1: attempt to call global 'guiGetScreenSize' ( a nil value ) 
client.lua: 1: attempt to call global 'guiGetScreenSize' ( a nil value ) 
client.lua: 1: attempt to call global 'guiGetScreenSize' ( a nil value ) 

Link to comment
Just a simple progress that you can start from
local sX,sY = guiGetScreenSize() 
local progX = 200 
local progY = 25 
local moveSpeed = 3 -- per frame 
local prog = 0 
  
  
function render() 
    if prog >= progX then 
    removeEventHandler("onClientRender",root,render) 
    triggerEvent("onClientProgressFinish",localPlayer) 
    end 
  
    dxDrawRectangle((sX/2)-(progX/2)-1,(sY/2)-(progY/2)-1,progX+2,progY+2,tocolor(255,255,255,170)) -- background 
  
    prog = math.min(prog+moveSpeed,progX) -- move the progress 
    dxDrawRectangle((sX/2)-(progX/2),(sY/2)-(progY/2),prog,progY,tocolor(50,50,50,255)) -- progress 
end 
addEventHandler("onClientRender",root,render) 

not work

client.lua: 1: attempt to call global 'guiGetScreenSize' ( a nil value ) 
client.lua: 1: attempt to call global 'guiGetScreenSize' ( a nil value ) 
client.lua: 1: attempt to call global 'guiGetScreenSize' ( a nil value ) 
client.lua: 1: attempt to call global 'guiGetScreenSize' ( a nil value ) 
client.lua: 1: attempt to call global 'guiGetScreenSize' ( a nil value ) 

This is client-sided, not server-side ...

Link to comment

@toni012899, you not know read, my friend ? :lol::lol:

client.lua

client.lua: 1: attempt to call global 'guiGetScreenSize' ( a nil value ) 
client.lua: 1: attempt to call global 'guiGetScreenSize' ( a nil value ) 
client.lua: 1: attempt to call global 'guiGetScreenSize' ( a nil value ) 
client.lua: 1: attempt to call global 'guiGetScreenSize' ( a nil value ) 
client.lua: 1: attempt to call global 'guiGetScreenSize' ( a nil value ) 

Link to comment
@toni012899, you not know read, my friend ? :lol::lol:
client.lua

client.lua: 1: attempt to call global 'guiGetScreenSize' ( a nil value ) 
client.lua: 1: attempt to call global 'guiGetScreenSize' ( a nil value ) 
client.lua: 1: attempt to call global 'guiGetScreenSize' ( a nil value ) 
client.lua: 1: attempt to call global 'guiGetScreenSize' ( a nil value ) 
client.lua: 1: attempt to call global 'guiGetScreenSize' ( a nil value ) 

Yes, I know. Lel, as the guy above said "post your meta here". I saw that it's named client.lua. If it can't call the "guiGetScreenSize" then you has set it as server-side script in the meta. Also the name of the file doesn't mean anything. ;)

Link to comment
progressBars = { }; 
  
function dxCreateProgressBar ( x, y, width, height, n ) 
    local id = #progressBars + 1; 
    progressBars[id] = { }; 
    progressBars[id]["x"] = x;       -- x position 
    progressBars[id]["y"] = y;       -- y position 
    progressBars[id]["w"] = width;   -- width 
    progressBars[id]["h"] = height;  -- height 
    progressBars[id]["n"] = n;       -- number of bars 
    progressBars[id]["p"] = 0;       -- progress 
     
    local element = createElement ( "dxProgressBar", tostring ( id ) ); 
    return element; 
end 
  
function dxProgressBarSetProgress ( element, progress ) 
    if ( progress >= 0 and progress <= 1 ) then 
        if ( isElement ( element ) ) then 
            progressBars [ tonumber ( getElementID ( element ) ) ]["p"] = progress; 
            return true; 
        end 
    end 
     
    return false; 
end 
  
function drawProgressBars ( ) 
    for _, p in pairs ( getElementsByType ( "dxProgressBar" ) ) do 
        local id = tonumber ( getElementID ( p ) ); 
        if ( id ) then 
            local x, y, w, h, n, p = progressBars[id]["x"], progressBars[id]["y"], progressBars[id]["w"], progressBars[id]["h"], progressBars[id]["n"], progressBars[id]["p"]; 
             
            local widthOfOne = ( w / n ) - 5; 
            local widthOfOneWithBreaks = widthOfOne + 5; 
             
            for i=0,n do 
                dxDrawRectangle ( x + ( i * widthOfOneWithBreaks ), y, widthOfOne, h, tocolor ( 0, 0, 0, 255 ) ); 
            end 
             
            local np = math.floor ( ( n * p ) + 0.5 ); 
            local wp = ( ( w + ( n * 5 ) ) * p ) / n 
            for i=0,np do 
                if ( i == np and p ~= 1 ) then widthOfOne = wp end 
                dxDrawRectangle ( x + ( i * widthOfOneWithBreaks ) + 2, y + 2, widthOfOne - 4, h - 4, tocolor ( 255, 255, 255, 255 ) ); 
            end 
        end 
    end 
end 
addEventHandler ( "onClientRender", root, drawProgressBars ); 

Done sth like this, didn't test it properly, but should work.

element dxCreateProgressBar ( int x, int y, int width,  int height, int n ) 
bool dxProgressBarSetProgress ( element ProgressBar, int n ) -- 0 to 1 

local p = dxCreateProgressBar ( 0, 0, 500, 50, 4 ); 
dxProgressBarSetProgress ( p, 0.5 ); 

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