• Help for Vgui Progress Bar
    9 replies, posted
Hello, I need some help for a Vgui progress bar. I would like to make a frame, but i'd like to add a progress bar activable with a button. I make this and this work. But the problem is that the progress bar doesn't disappear when I close the windows. So i try this but it doesn't work : [CODE] function frame.OnClose() ProgressBar.Remove() end [/CODE] And this too : [CODE] function frame.OnClose() ProgressBar.Close() end [/CODE] Could you help me please ?
Can I see the whole source code? I can't help much if I don't even know how you are drawing the progress bar.
yes : [CODE] nclude('shared.lua') net.Receive( "MyNpcFunction", function() local frame = vgui.Create( "DFrame" ) -- Main Frame frame:SetTitle("Title") frame:SetSize( 800, 800 ) frame:Center() frame:GetBackgroundBlur() frame:MakePopup() frame.Paint = function( self, w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 50, 50, 50, 150 ) ) end function frame.OnClose() -- PROBLEM HERE ProgressBar:SetFraction( 0 ) ProgressBar.Remove() -- Or Close but it doen't work too... end local ProgressBar = vgui.Create( "DProgress" ) -- Progress Bar ProgressBar:SetPos( 600, 500 ) ProgressBar:SetSize( 400, 30 ) ProgressBar:SetFraction( 0 ) local i=0 local Button = vgui.Create( "DButton", frame ) -- Button Button:SetText( "Progress Bar Start" ) Button:SetPos( 250, 500 ) Button:SetSize( 250, 30 ) function Button.DoClick() print( "[DARKRP] Progress..." ) timer.Create( "TraitementBar", 0.3, 100, function() i = i+0.01 ProgressBar:SetFraction( i ) end ) end end ) [/CODE]
Set the parent of the DProgress to the DFrame.
Thank you very munch, [CODE]ProgressBar:SetParent( frame )[/CODE] work !
It's the second argument of [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/vgui/Create]vgui.Create[/url].
-snip- Got ninja'd :(
[QUOTE=Meninist;52496196][CODE]local ProgressBar = vgui.Create( "DProgress" )[/CODE] Set this to: [CODE]local ProgressBar = vgui.Create( "DProgress","DFrame" )[/CODE] This. If you look at the vgui.Create() wiki page it says the second argument is where you set the parent frame.[/QUOTE] The second argument needs to be a panel, not a string.
[QUOTE=Sean Bean;52496200]The second argument needs to be a panel, not a string.[/QUOTE] Yes, my bad I had just woken up.
[QUOTE=Ezotose;52496184]Thank you very munch, [CODE]ProgressBar:SetParent( frame )[/CODE] work ![/QUOTE] Also, have in mind next time that it isn't [CODE]ProgressBar.Remove()[/CODE] but rather [CODE]ProgressBar:Remove()[/CODE] Notice the two dots. One is a reference to an object/entity/table and the other isn't, as it needs to take the panel as a parameter to be able to get removed.
Sorry, you need to Log In to post a reply to this thread.