Cocodrilo Posted March 23, 2016 Share Posted March 23, 2016 Here i have a variable "ttime" which is used to define seconds, in this case. I calculate the 1% of the variable "ttime" to add to the progressBar every second. The problem is this: If my variable "ttime" is <= 100 everything works fine, but when "ttime" > 100 , the progressBar just don't increases. I've noticed that when the "value" variable's result is 0.5, 0.58, 0.9, anything between 0 and 1 this happens. is there any solution? or some other way to do this? ayuntamiento_panel_mejorar = guiCreateWindow(0.29, 0.27, 0.51, 0.55, "", true) guiWindowSetSizable(ayuntamiento_panel_mejorar, false) casa_lbl_me = guiCreateLabel(0.27, 0.11, 0.46, 0.06, "", true, ayuntamiento_panel_mejorar) guiLabelSetHorizontalAlign(casa_lbl_me, "center", false) casa_mejorar_confirmar = guiCreateButton(0.38, 0.78, 0.27, 0.09, "upgrade", true, ayuntamiento_panel_mejorar) casacerrarme = guiCreateButton(0.89, 0.08, 0.07, 0.08, "x", true, ayuntamiento_panel_mejorar) lbl_info = guiCreateLabel(0.26, 0.26, 0.49, 0.34, "Upgrade this building.", true, ayuntamiento_panel_mejorar) guiLabelSetHorizontalAlign(lbl_info, "center", false) guiLabelSetVerticalAlign(lbl_info, "center") tiempo = guiCreateLabel(0.44, 0.71, 0.18, 0.07, "0 %", true, ayuntamiento_panel_mejorar) label = guiCreateLabel(0.47, 0.88, 0.12, 0.07, "", true, ayuntamiento_panel_mejorar) guiLabelSetHorizontalAlign(label, "center", false) guiLabelSetVerticalAlign(label, "center") guiLabelSetHorizontalAlign(tiempo, "center", false) Bar = guiCreateProgressBar(0.31, 0.62, 0.39, 0.07, true, ayuntamiento_panel_mejorar) showCursor ( true ) ttime = 10 value = 0 function conf() if source == casa_mejorar_confirmar then theTimer = setTimer( func, 1000, 0) guiSetText(label,ttime.. " sec") guiSetProperty(casa_mejorar_confirmar,"Disabled","true") end end addEventHandler ("onClientGUIClick", getRootElement(), conf) function func() local percent = guiProgressBarGetProgress(Bar) local value = (100/ttime) local progress = percent + value guiProgressBarSetProgress(Bar, progress) guiSetText(tiempo,percent.. " %") if guiProgressBarGetProgress(Bar) == 100 then guiProgressBarSetProgress(Bar, 0) killTimer ( theTimer ) outputChatBox("Done!", 0,255,0) guiSetText(tiempo,"0 %") guiSetText(label,"") guiSetProperty(casa_mejorar_confirmar,"Disabled","false") end end function close_panel() if source == casacerrarme then guiSetVisible ( ayuntamiento_panel_mejorar, false ) showCursor ( false ) end end addEventHandler ("onClientGUIClick", getRootElement(), close_panel) 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