• Smooth Money Bar
    1 replies, posted
I'm adding stuff to my printer for DarkRP, and I was wondering how I would make a smooth "money bar" on the printer. I tried using something like: [CODE] function ENT:Draw() local smooth = 0 Ang:RotateAroundAxis(Ang:Up(), 90) cam.Start3D2D(Pos + Ang:Up() * 11.5, Ang, 0.11) draw.RoundedBox(0, -101, 88, math.Approach(smooth, barmoney / 25.05, 50 * RealTime()), 5, Color(255, 255, 255, 255)) cam.End3D2D() end [/CODE] But that didn't work. Here's my full cl_init.lua code: [CODE] include("shared.lua") surface.CreateFont( "status", { font = "TreButchet24", size = 25, weight = 600, blursize = 0, scanlines = 0, antialias = true, underline = false, italic = false, strikeout = false, symbol = false, rotary = false, shadow = false, additive = false, outline = false, } ) surface.CreateFont( "statusmoney", { font = "TreButchet24", size = 20, weight = 900, blursize = 0, scanlines = 0, antialias = true, underline = false, italic = false, strikeout = false, symbol = false, rotary = false, shadow = false, additive = false, outline = false, } ) surface.CreateFont( "printmoney", { font = "TreButchet24", size = 20, weight = 900, blursize = 0, scanlines = 0, antialias = true, underline = false, italic = false, strikeout = false, symbol = false, rotary = false, shadow = false, additive = false, outline = false, } ) surface.CreateFont( "ownername", { font = "TreButchet24", size = 14, weight = 1000, blursize = 0, scanlines = 0, antialias = true, underline = false, italic = false, strikeout = false, symbol = false, rotary = false, shadow = false, additive = false, outline = false, } ) surface.CreateFont( "presse", { font = "TreButchet24", size = 14, weight = 900, blursize = 0, scanlines = 0, antialias = true, underline = false, italic = false, strikeout = false, symbol = false, rotary = false, shadow = false, additive = false, outline = false, } ) function ENT:Initialize() end function ENT:Draw() self:DrawModel() local Pos = self:GetPos() local Ang = self:GetAngles() local owner = self:Getowning_ent() owner = (IsValid(owner) and owner:Nick()) or DarkRP.getPhrase("unknown") local money = "Money: $" .. self:GetMoney() local barmoney = self:GetMoney() local text = DarkRP.getPhrase("money_printer") local text2 = "Standard Printer" local stats = "STATISTICS" local presse = "Printer is full!" local moneyprint = "$ per second: $1.00" local TextWidth = surface.GetTextSize(text) local TextWidth2 = surface.GetTextSize(owner) local smooth = 0 Ang:RotateAroundAxis(Ang:Up(), 90) if barmoney > 5000 then barmoney = 5000 end if barmoney < 0 then barmoney = 0 end cam.Start3D2D(Pos + Ang:Up() * 11.5, Ang, 0.11) draw.RoundedBox(0, -128, -138, 260, 40, Color(19, 87, 235, 255)) draw.RoundedBox(0, -128, -100, 260, 220, Color(36, 36, 36, 255)) draw.RoundedBox(0, -115, -70, 230, 120, Color(0, 0, 0, 255)) draw.RoundedBox(0, -115, 53, 230, 50, Color(0, 0, 0, 255)) --draw.RoundedBox(6, -37, 15, 75, 30, Color(math.Rand( 0, 255 ), math.Rand( 0, 255 ), math.Rand( 0, 255 ), 255)) draw.RoundedBox(0, -101, 88, math.Approach(smooth, barmoney / 25.05, 50 * RealTime()), 5, Color(255, 255, 255, 255)) draw.WordBox(0, -104, -135, text2, "HUDNumber5", Color(19, 87, 235, 255), Color(255,255,255,255)) draw.WordBox(0, -60, -65, stats, "status", Color(0, 0, 0, 255), Color(255,255,255,255)) draw.WordBox(0, -32 / 1, 68, owner, "ownername", Color(0, 0, 0, 0), Color(255,255,255,255)) draw.WordBox(0, -45, -30, money, "statusmoney", Color(0, 0, 0, 255), Color(255,255,255,255)) draw.WordBox(0, -75, -10, moneyprint, "printmoney", Color(0, 0, 0, 255), Color(255,255,255,255)) if barmoney == 5000 then draw.WordBox(0, -40, 22, presse, "presse", Color(0, 0, 0, 0), Color(32, 243, 23, 255) ) end cam.End3D2D() end function ENT:Think() end [/CODE]
[LUA] local smooth = 0 [/LUA] ... inside your hook... [LUA] local money = self:GetMoney() smooth = math.Approach( smooth, money, 100 * FrameTime() ) [/LUA] then use smooth to draw the money bar
Sorry, you need to Log In to post a reply to this thread.