Jump to content

progress


#Paper

Recommended Posts

The progressbar doesn't increment :S

function createProgressBar(player, time) 
local x, y = guiGetScreenSize() 
local toAdd = 100/time 
progress = guiCreateProgressBar(x/2, y/3, 300, 30, false) 
setTimer(function () 
            local prog = guiProgressBarGetProgress(progress) 
            if prog <= 99 then 
                guiProgressBarSetProgress(progress, math.floor(tonumber(prog + toAdd))) 
            elseif prog >= 100 then 
                destroyElement(progress) 
            end 
         end, 1000, time/1000) 
end 

or insted to make how i made it, how can i make the bar increment smootly proportional the time?

P.S: Time value is 8000

Link to comment

Try this, quickly made and not tested

function createProgressBar(player, time) 
  local x, y = guiGetScreenSize() 
  progress = guiCreateProgressBar(x/2, y/3, 300, 30, false) 
  setTimer(function (starttick, time) 
             local prog = (getTickCount() - starttick)/time * 100 
             if prog < 100 then 
                 guiProgressBarSetProgress(progress, prog ) 
             else 
                 destroyElement(progress) 
             end   
          end, 
          1000, time/1000, getTickCount(), time) 
end 

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