• Player xp bar, need help with some math
    1 replies, posted
i am having a hard time trying to find out what should i do to make it work ive deleted my stupid math since it din't work.. this is how the script looks :) ehm when CurXp = 250 amd NextLvlXp is 500 the bar should be half full no matter the screen resolution [lua] local Text = "Level: 1" local function ShowPlyXp() local H = ScrH() local W = ScrW() local H1P = H/100 local W1P = W/100 local CurXp = 250 local NextLvlXp = 500 local WidthStatus = CurXp draw.RoundedBox( 6, W1P*30, H1P*4.16, W/2.5, 20, Color( 0, 0, 0, 180 ) ) draw.RoundedBox( 6, W1P*30, H1P*4.16, math.Clamp( WidthStatus, 12, W/2.5 ), 20, Color( 0, 255, 165, 150 ) ) surface.SetTextPos( W1P*32, H1P*4.16 ) surface.SetFont("Trebuchet19") surface.SetTextColor( 255, 255, 255, 255 ) surface.DrawText( Text ) surface.SetTextPos( W/2, H1P*4.16 ) local text = CurXp .. "/" .. NextLvlXp surface.DrawText( text ) end hook.Add( "HUDPaint", "tell's the palyer how much xp he got, and how much is for next lvl", ShowPlyXp ) [/lua] ive just taking this from another of my scripts, normally the bar is a timer lawl :P
[lua] local padding = 4 local w, h = ScrW() / 4, 25 local x, y = 20, ScrH() - 25 - h local barWidth = ply.CurXP / ply.DesiredXP draw.RoundedBox( 4, x, y, w, h, Color(0, 0, 0, 180) ) --Draw background. draw.RoundedBox( 4, x + padding, y + padding, (w - padding * 2) * barWidth, h - padding * 2, Color(0, 255, 165, 150) ) --Draw inner. [/lua]
Sorry, you need to Log In to post a reply to this thread.