Last active
January 15, 2023 12:16
-
-
Save outrowender/7f04f1c5123094c63c3af273ebb1ce7b to your computer and use it in GitHub Desktop.
Draw a native progressbar - FIVEM Lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Any photo?