LyricalMM Posted November 12, 2018 Share Posted November 12, 2018 Hello, i've made a script for a new job, so when he is in the marker, he freeze for a random time. timer = math.random(4000,6000) setTimer(function() local freeze = getElementData(getLocalPlayer(), "curierFreeze") if freeze then setElementFrozen(getPedOccupiedVehicle(getLocalPlayer()), false) toggleAllControls(true, true, false) setElementData(getLocalPlayer(), "curierFreeze", false) guiProgressBarSetProgress(progress, 100) end if (guiProgressBarGetProgress(progress) == 100) then destroyElement(progress) end end, timer, 0) how to set the progress bar percentage by the timer? like if the timer is 4.6 seconds, in 4.6 seconds to fill in the progress bar. Link to comment
VenomOG Posted November 12, 2018 Share Posted November 12, 2018 4 hours ago, LyricalMM said: Hello, i've made a script for a new job, so when he is in the marker, he freeze for a random time. timer = math.random(4000,6000) setTimer(function() local freeze = getElementData(getLocalPlayer(), "curierFreeze") if freeze then setElementFrozen(getPedOccupiedVehicle(getLocalPlayer()), false) toggleAllControls(true, true, false) setElementData(getLocalPlayer(), "curierFreeze", false) guiProgressBarSetProgress(progress, 100) end if (guiProgressBarGetProgress(progress) == 100) then destroyElement(progress) end end, timer, 0) how to set the progress bar percentage by the timer? like if the timer is 4.6 seconds, in 4.6 seconds to fill in the progress bar. You didnt define progress. Link to comment
LyricalMM Posted November 12, 2018 Author Share Posted November 12, 2018 7 minutes ago, Knuck said: You didnt define progress. any functions or methods? Link to comment
VenomOG Posted November 12, 2018 Share Posted November 12, 2018 2 minutes ago, LyricalMM said: any functions or methods? timer = math.random(4000,6000) setTimer(function() local freeze = getElementData(getLocalPlayer(), "curierFreeze") if freeze then progress = guiCreateProgressBar ( float x, float y, float width, float height, bool relative, [element parent = nil] ) setElementFrozen(getPedOccupiedVehicle(getLocalPlayer()), false) toggleAllControls(true, true, false) setElementData(getLocalPlayer(), "curierFreeze", false) guiProgressBarSetProgress(progress, 100) end if (guiProgressBarGetProgress(progress) == 100) then destroyElement(progress) end end, timer, 0) Link to comment
LyricalMM Posted November 12, 2018 Author Share Posted November 12, 2018 Just now, Knuck said: timer = math.random(4000,6000) setTimer(function() local freeze = getElementData(getLocalPlayer(), "curierFreeze") if freeze then progress = guiCreateProgressBar ( float x, float y, float width, float height, bool relative, [element parent = nil] ) setElementFrozen(getPedOccupiedVehicle(getLocalPlayer()), false) toggleAllControls(true, true, false) setElementData(getLocalPlayer(), "curierFreeze", false) guiProgressBarSetProgress(progress, 100) end if (guiProgressBarGetProgress(progress) == 100) then destroyElement(progress) end end, timer, 0) aah, I've defined the progress bar in another function, that's not the problem. Link to comment
VenomOG Posted November 12, 2018 Share Posted November 12, 2018 local lol = guiProgressBarGetProgress(progress) setTimer( guiProgressBarSetProgress, 5000, 1,progress,lol+10 ) setTimer( guiProgressBarSetProgress, 10000, 1,progress,lol+20 ) setTimer( guiProgressBarSetProgress, 15000, 1,progress,lol+30 ) setTimer( guiProgressBarSetProgress, 20000, 1,progress,lol+40 ) setTimer( guiProgressBarSetProgress, 25000, 1,progress,lol+50 ) setTimer( guiProgressBarSetProgress, 30000, 1,progress,lol+60 ) setTimer( guiProgressBarSetProgress, 35000, 1,progress,lol+70 ) setTimer( guiProgressBarSetProgress, 40000, 1,progress,lol+80 ) setTimer( guiProgressBarSetProgress, 45000, 1,progress,lol+90 ) setTimer( guiProgressBarSetProgress, 50000, 1,progress,lol+100 ) @LyricalMM Link to comment
LyricalMM Posted November 12, 2018 Author Share Posted November 12, 2018 1 minute ago, Knuck said: local lol = guiProgressBarGetProgress(progress) setTimer( guiProgressBarSetProgress, 5000, 1,progress,lol+10 ) setTimer( guiProgressBarSetProgress, 10000, 1,progress,lol+20 ) setTimer( guiProgressBarSetProgress, 15000, 1,progress,lol+30 ) setTimer( guiProgressBarSetProgress, 20000, 1,progress,lol+40 ) setTimer( guiProgressBarSetProgress, 25000, 1,progress,lol+50 ) setTimer( guiProgressBarSetProgress, 30000, 1,progress,lol+60 ) setTimer( guiProgressBarSetProgress, 35000, 1,progress,lol+70 ) setTimer( guiProgressBarSetProgress, 40000, 1,progress,lol+80 ) setTimer( guiProgressBarSetProgress, 45000, 1,progress,lol+90 ) setTimer( guiProgressBarSetProgress, 50000, 1,progress,lol+100 ) @LyricalMM nope, I want to set the progress by the timer. Link to comment
Addlibs Posted November 12, 2018 Share Posted November 12, 2018 (edited) Then you'll need to monitor getTimerDetails every now and then (perhaps even by render event but it's overkill - you do not need to do this every frame). local duration = --[[ define a duration in ms ]] local timeLeft = getTimerDetails(--[[ the timer ]]) local timeDone = duration - timeLeft local percent = timeDone / duration guiProgressBarSetProgress(--[[ progressbar element ]], percent) Edited November 12, 2018 by MrTasty Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now