Skip to content

Instantly share code, notes, and snippets.

@outrowender
Last active January 15, 2023 12:16
Show Gist options
  • Save outrowender/7f04f1c5123094c63c3af273ebb1ce7b to your computer and use it in GitHub Desktop.
Save outrowender/7f04f1c5123094c63c3af273ebb1ce7b to your computer and use it in GitHub Desktop.
Draw a native progressbar - FIVEM Lua
--put this along a __resource.lua file
Citizen.CreateThread(function()
while true do
local playerArmour = GetPedArmour(GetPlayerPed(-1)) --get player armor level (0-100)
--x, y, width, height
--Color must be passed as parameter as: {R, G, B, ALPHA}
--percent must be passed from 0 to 100
drawProgressBar(0.120, 0.975, 0.0690, 0.0085, {33, 78, 106, 255}, playerArmour) --armour progressbar
Citizen.Wait(0) -- at every frame
end
end)
--Draw this at every frame
function drawProgressBar(x, y, width, height, colour, percent)
local w = width * (percent/100)
local x = (x - (width * (percent/100))/2)-width/2
DrawRect(x+w, y, w, height, colour[1], colour[2], colour[3], colour[4])
end
Copy link

ghost commented Jan 15, 2023

Any photo?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment