Jump to content

[Help] Prograss Bar


brocky

Recommended Posts

I really want to make a progress bar in my script and I know the function to make the progress bar, but the problem is that I can't get the progress bar to work!. Can you give me some examples? I want a progress Bar from 1% to 100% and after it is done, then a function will be triggered and it can be anything as you like "setPlayerName", "givePlayerMoney" or anything.

But the main thing is that I want a progress bar that works from 1% to 100% and when it is finished to 100% then a function will be called/trigger.

Sorry, If you didn't understood what I said.

Link to comment
  
start = getTickCount() 
function loading () 
 local now = getTickCount() 
            with = interpolateBetween(0,0,0,532,0,0, (now - start) / (( start + 10000 ) - start ) , "Linear" ) 
         dxDrawRectangle(142, 222, 532, 41, tocolor(0, 0, 0, 255), false) 
        dxDrawRectangle(142, 222, with, 41, tocolor(55, 215, 0, 255), false) 
     end 
   end 
addEventHandler("onClientRender",root,lodaing) 
bindKey("c","down",function () 
local now = getTickCount() 
start = getTickCount() 
with = interpolateBetween(with,0,0,0,0,0, (now - start) / (( start + 3000 ) - start ) , "Linear" ) 
givePlayerMoney(5000) 
end) 
  

Link to comment

You have some mistakes there

  
  
start = getTickCount() 
function loading() 
    local now = getTickCount() 
    with = interpolateBetween(0,0,0,532,0,0, (now - start) / (( start + 10000 ) - start ) , "Linear" ) 
    dxDrawRectangle(142, 222, 532, 41, tocolor(0, 0, 0, 255), false) 
    dxDrawRectangle(142, 222, with, 41, tocolor(55, 215, 0, 255), false) 
end 
addEventHandler("onClientRender",root,loading) 
    bindKey("c","down",function () 
     local now = getTickCount() 
      start = getTickCount() 
      with = interpolateBetween(with,0,0,0,0,0, (now - start) / (( start + 3000 ) - start ) , "Linear" ) 
        givePlayerMoney(5000) 
end 
) 
  
  

Link to comment

Did you even saw what I just said?

I know that every thing is defined in MTA SA Scripting introduction or here, but I have some questions that needs to be simply answered and don't post things that are useless and won't help me, Please and once again sorry for this rude message to you. Anyways.

What I just said is Can you explain the upper codes with comments? Because I didn't properly understood it.

Q1 = In interpolateBetween function...Why did we subtracted variable "now" from "start", what was the purpose? and why did we divided it? and then added 1000 constant to "start " variable?

Q2 = Why did you wrote "Linear" at the end of the interpolateBetween function.

Q3 = when we created the second dxDrawRectangle, and at argument three you wrote "with", Why so? what was the reason?

Q4 = I checked the MTA scripting introduction about interpolateBetween, but can you explain it little bit and tell me the "actual" purpose of it?

Link to comment

Just it Example Progress Bar

screenX,screenY = guiGetScreenSize() 
function startTheClock () 
  
    if not systemUpTime then 
            systemUpTime = getTickCount () --Store the system tick count, this will be 0 for us 
    end 
  
    currentCount = getTickCount () 
  
    dxDrawRectangle (screenX *.40, screenY * .09, 250, 50, tocolor(0,0,0,150)) 
    dxDrawText ( currentCount - systemUpTime, screenX * .48, screenY * .1, screenX, screenY, tocolor(255,255,255), 2) 
end 
addEventHandler ( "onClientRender", root, startTheClock ) 

Link to comment

Did you check Dealman's post? He posted full code and he explained each and every line and more importantly its related to what you want. I never used interpolate functions because they suck pretty much. I can write my own code which is easier to understand for anyone.

Anyhow getTickCount doesn't return 0 when its called @Aristates. getTickCount returns time. Lets say you want to know the execution time of a code.

  
local start = getTickCount() -- the return value will be different at different time depending on date like year, month, minute, second etc 
for i= 1, 40000 do  
   -- this loop will repeat 40 k times 
end 
local ms = start - getTickCount() -- milliseconds now 
local seconds = ms/1000 -- seconds 
local minutes = seconds/60 -- minutes  
outputChatBox ( minutes .. " minutes ".. seconds .."  seconds " ..ms.." milliseconds passed ") -- this will tell you how much time passed 
  
  

I'm on phone and thats all I can explain for now

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