• Cannot draw progress bar for swep
    2 replies, posted
The lockpick did not show a progress bar, so i made my own, but it won't show either, help? Garrysmod 13. [CODE] if CLIENT then local Height = 20 local Width = 300 local function CenterX() return ScrW() / 2 - Width / 2 end local function CenterY() return ScrH() / 2 - Height / 2 end function SWEP:DrawHUD() if self.IsLockPicking then surface.SetDrawColor( 180, 180, 180, 255 ) surface.DrawOutlinedRect( CenterX(), CenterY() + 50, Width, Height ) surface.SetDrawColor( 180, 180, 180, 255 ) surface.DrawRect( CenterX() + 2, CenterY() + 50 + 2, Width - 4 , Height - 4 ) surface.SetDrawColor( 255, 25, 25, 255 ) surface.DrawRect( CenterX() + 2, CenterY() + 50 + 2, ( self.PickpocketLength - ( self.PickpocketTime - CurTime() ) ) / self.PickpocketLength * ( Width - 4 ), Height - 4 ) draw.SimpleText( "Lockpicking...", "TabLarge", ScrW() / 2, ScrH() / 2 + 50, Color( 255, 255, 255 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER ) end end end [/CODE]
do some prints to make sure your code gets run atleast. Like so: [lua]if CLIENT then local Height = 20 local Width = 300 local function CenterX() return ScrW() / 2 - Width / 2 end local function CenterY() return ScrH() / 2 - Height / 2 end function SWEP:DrawHUD() MsgN("DrawHUD!") if self.IsLockPicking then MsgN("IsLockPicking!") surface.SetDrawColor( 180, 180, 180, 255 ) surface.DrawOutlinedRect( CenterX(), CenterY() + 50, Width, Height ) surface.SetDrawColor( 180, 180, 180, 255 ) surface.DrawRect( CenterX() + 2, CenterY() + 50 + 2, Width - 4 , Height - 4 ) surface.SetDrawColor( 255, 25, 25, 255 ) surface.DrawRect( CenterX() + 2, CenterY() + 50 + 2, ( self.PickpocketLength - ( self.PickpocketTime - CurTime() ) ) / self.PickpocketLength * ( Width - 4 ), Height - 4 ) draw.SimpleText( "Lockpicking...", "TabLarge", ScrW() / 2, ScrH() / 2 + 50, Color( 255, 255, 255 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER ) end end end[/lua] If neither of those prints you should probably look up what it takes for DrawHUD to get called, look on other sweps which has a HUD or something, or look at the wiki (both old and new)
I think you need to add if player has pressed or held the left mouse button so its called at least once. Also if you want to do anything with progress bars, try this [URL="http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index0814.html"]here[/URL]
Sorry, you need to Log In to post a reply to this thread.