Jump to content

dxprogressbar


Recommended Posts

شوف انا اليوم بطريقه ما فاضي شويه فسويت لك البروجرس بار ذا بس ما جربته صراحه و مكسل اجربو ف جربو انت و قولي اذا به اخطاء

local progressbar = {}

function dxCreatePrograssBar(id, x, y, w, h, progress)
	table.insert(progressbar, {id, x, y, w, h, 0, false})
end

function dxProgressBarSetVisible(id, bool)
	if id then
		for index,value in ipairs(progressbar) do
			if value[1] == id then
				progressbar[index][7] = bool
			end
		end
	end
end

function dxProgressBarGetVisible(id)
	if id then
		for _,value in ipairs(progressbar) do
			if value[1] == id then
				return value[7]
			end
		end
	end
end


function dxProgressBarSetProgress(id, progress)
	if id and progress then
		for index,value in ipairs(progressbar) do
			if value[1] == id then
				progressbar[index][6] = progress
			end
		end
	end
end

function dxProgressBarGetProgress(id)
	if id then
		for _,value in ipairs(progressbar) do
			if value[1] == id then
				return value[6]
			end
		end
	end
end

function dxRemoveProgressBar(id)
	if id then
		for index,value in ipairs(progressbar) do
			if value[1] == id then
				progressbar[index] = nil
			end
		end
	end
end

addEventHandler("onClientRender", root,
	function()
		if #progressbar > 0 then
			for _,value in ipairs(progressbar) do
				if value[1] and value[2] and value[3] and value[4] and value[5] and value[6] then
					if value[7] then
            			local x, y, w, h = value[2], value[3], value[4], value[5]
						dxDrawRectangle(x, y, w, h, tocolor(0, 0, 0, 150), false) -- background
						dxDrawRectangle(x, y, value[6]*(w/100), h, tocolor(0, 0, 0, 150), false) -- progress
					end
				end
			end
		end
	end
)

 

Edited by #َxLysandeR
Link to comment

شوف هذا اخذته لك من موضوع اليوزفل فنكشن

local dxProgressBar = { Data = {} }  
  
function dxCreateProgressBar (x,y,w,h,text,prog) 
local element = createElement('dxProgressBar') 
dxProgressBar.Data[element] = {x=x,y=y,w=w,h=h,text=text,prog=prog} 
return element 
end 
  
function dxProgressBarGetProgressBar ( element )  
if ( getElementType ( element ) == 'dxProgressBar' ) then  
return dxProgressBar.Data[element].prog 
end 
return false 
end 
  
function dxProgressBarSetProgressBar ( element , prog_ )  
if ( getElementType ( element ) == 'dxProgressBar' ) then  
dxProgressBar.Data[element].prog = prog_ 
end 
return false 
end 
  
function dxDrawProgressBar ( element1 )  
if ( getElementType ( element1 ) == 'dxProgressBar' ) then 
local element = dxProgressBar.Data [ element1 ] 
local x,y,w,h,text,prog = element.x,element.y,element.w,element.h,element.text,element.prog 
if ( prog >= 100 ) then  
prog = 100 
r,g,b,alpha = 0,255,0,255  
r1,g1,b1 = 0,0,0 
else 
prog = prog 
r,g,b,alpha = 255,0,0,255 
r1,g1,b1 = 255,255,255 
end 
dxDrawRectangle (x,y,w,h,tocolor(0,0,0,190),false) 
dxDrawRectangle (x,y,math.floor(prog)*w/100,h,tocolor(r,g,b,alpha),false) 
dxDrawText(text,x,y,x+w,y+h,tocolor(r1,g1,b1,255),1,'default-bold','center','center',false,false,false,true,true) 
end 
end 

----

D = dxCreateProgressBar (66, 296, 346, 36,'Testing',0) 
  
addEventHandler("onClientRender", root, 
    function( ) 
       dxDrawProgressBar ( D ) 
       dxProgressBarSetProgressBar ( D , dxProgressBarGetProgressBar ( D ) +1) 
    end 
) 

Source : @iMr.Omar 

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