[HELP] Progress bar

how can i make a notification with progress bar ?

KOcW_Kb4Sqy5KP3UmK6tJQ

2 Likes

That is an example of how you could do it.

local X, Y, W; H = 0.0125
local Duration = 7500
local timer = GetGameTimer()

if not HasStreamedTextureDictLoaded('timerbars') then
	RequestStreamedTextureDict('timerbars')
	while not HasStreamedTextureDictLoaded('timerbars') do
		Citizen.Wait(0)
	end
end

if GetTimeDifference(GetGameTimer(), timer) < Duration then
	W = (GetTimeDifference(GetGameTimer(), timer) * (0.085 / Duration))
end

local correction = ((1.0 - round(GetSafeZoneSize(), 2)) * 100) * 0.005
X, Y = 0.9255 - correction, 0.94 - correction

Set_2dLayer(0)
DrawSprite('timerbars', 'all_black_bg', X, Y, 0.15, 0.0325, 0.0, 255, 255, 255, 180)

Set_2dLayer(1)
DrawRect(X + 0.0275, Y, 0.085, 0.0125, 100, 0, 0, 180)

Set_2dLayer(2)
DrawRect(X - 0.015 + (W / 2), Y, W, H, 150, 0, 0, 180)

SetTextColour(255, 255, 255, 180)
SetTextFont(0)
SetTextScale(0.3, 0.3)
SetTextCentre(true)
SetTextEntry('STRING')
AddTextComponentString(GetLabelText('KS_RESPAWN_B'))
Set_2dLayer(3)
DrawText(X - 0.06, Y - 0.012)

Can you provide a complete example, I have used this example for no effect, I don’t know how to use it, thank you.

Thank you for your reply @Flatracer :slight_smile:

I have no effect with this example :confused:

Because it is not complete, to use it you have to adapt it to what you need it for.

function drawHelpTxt(x,y ,width,height,scale, text, r,g,b,a,font)
	SetTextFont(font)
	SetTextProportional(0)
	SetTextScale(scale, scale)
	SetTextColour(r, g, b, a)
	SetTextDropShadow(0, 0, 0, 0,255)
	SetTextEdge(1, 0, 0, 0, 255)
	SetTextDropShadow()
	SetTextOutline()
	SetTextEntry("STRING")
	AddTextComponentString(text)
	DrawText(x - width/2, y - height/2 + 0.005)
end

function DrawTimerBar(startT, endT, r, g, b)
	local value = math.floor(((startT + endT) - GetGameTimer())*0.001)
	local maxvalue = math.floor(endT*0.001)
	local width = 0.2
	local height = 0.025
	local xvalue = 0.38
	local yvalue = 0.05
	local outlinecolour = {0, 0, 0, 150}
	local barcolour = {r, g, b}
	local minutes = math.floor(value/60)
	local time = ""..minutes.." minutes and "..math.floor(value - (minutes*60)).." seconds"
	DrawRect(xvalue + (width/2), yvalue, width + 0.004, height + 0.006705, outlinecolour[1], outlinecolour[2], outlinecolour[3], outlinecolour[4]) -- Box that creates outline
	drawHelpTxt(xvalue + (((maxvalue/2)/((maxvalue/2)/width))/2), yvalue + 0.0275, 0.1, 0.1, 0.5, time, 255, 255, 255, 255, 6) -- Text display of timer
	DrawRect(xvalue + (width/2), yvalue, width, height, barcolour[1], barcolour[2], barcolour[3], 75) --  Static full bar
	DrawRect(xvalue + ((value/(maxvalue/width))/2), yvalue, value/(maxvalue/width), height, barcolour[1], barcolour[2], barcolour[3], 255) -- Moveable Bar  
end

Here’s something i made a while ago

Haha thanks it works :grinning::+1:

another question, How can I disable the box ??

Remove start scoreboard from your server.cfg if you want to disable it completely :wink:

Ahhh … ok :joy: thanks @Vespura :+1:

Here is an example of how to draw a native progressbar