Jump to content

[HELP] Notification Bar [HELP]


Recommended Posts

Since iv'e been seeking for an notification bar i had find one...

This is an notification bar also released @ community and seems to be fixed by Castillo [solidsnake14]

    gColours = { 
        primary = {255, 69, 59, 255}, 
        secondary = {255, 118, 46, 255}, 
        tertiary = {232, 42, 104, 255}, 
        defaultLabel = {255, 255, 255}, 
        grey = {120, 120, 120}, 
    } 
    ContextBar = { 
        height = 28, 
        speed = 20, 
        step = 2, 
        life = 8000, 
        update = 0, 
        textColour = {unpack(gColours.primary)}, 
        lineColour = {0, 0, 0}, 
        entries = {} 
    } 
      
    local sx, sy = guiGetScreenSize ( ) 
      
    gEnabled = true 
      
    function ContextBar.add(text) 
        if not gEnabled then 
            return 
        end 
        
        local y = sy - ContextBar.height 
        
        if #ContextBar.entries > 0 then 
            if ContextBar.entries[#ContextBar.entries].text == text then 
                return 
            end 
            
            y = ContextBar.entries[#ContextBar.entries].y - ContextBar.height 
        end 
        
        local pixelsPerSecond = (1000 / ContextBar.speed) * ContextBar.step 
        local alphaStep = (sy - y - ContextBar.height) / pixelsPerSecond 
        
        ContextBar.entries[#ContextBar.entries + 1] = { 
            text = text, 
            creation = getTickCount(), 
            y = y, 
            landed = false, 
            alphaStep = alphaStep == 0 and 0.05 or (1 / ((alphaStep * 1000) / ContextBar.speed)), 
            alpha = alphaStep == 0 and 1 or 0, 
        } 
    end 
      
    addEventHandler("onClientRender", root, 
        function() 
            for _,bar in ipairs(ContextBar.entries) do 
                dxDrawRectangle(0, bar.y, sx, ContextBar.height, tocolor(0, 0, 0, math.lerp(0, 170, bar.alpha)), true) 
                dxDrawText(bar.text, 0, bar.y, sx, bar.y + ContextBar.height, tocolor(ContextBar.textColour[1], ContextBar.textColour[2], ContextBar.textColour[3], math.lerp(0, 255, bar.alpha)), 1, "default-bold", "center", "center", true, true, true) 
                
                dxDrawLine(0, bar.y, sx, bar.y, tocolor(ContextBar.lineColour[1], ContextBar.lineColour[2], ContextBar.lineColour[3], math.lerp(0, 255, bar.alpha)), 1, true) 
            end 
            
            local tick = getTickCount() 
            
            if tick > (ContextBar.update + ContextBar.speed) then 
                ContextBar.update = tick 
                
                if #ContextBar.entries > 1 then 
                    for i = #ContextBar.entries, 1, -1 do 
                        if ContextBar.entries[i].y > sy then 
                            table.remove(ContextBar.entries, i) 
                        else 
                            ContextBar.entries[i].alpha = math.min(1, ContextBar.entries[i].alpha + ContextBar.entries[i].alphaStep) 
                            ContextBar.entries[i].y = ContextBar.entries[i].y + ContextBar.step 
                            if i ~= 1 and #ContextBar.entries == 2 and ContextBar.entries[i].y > (sy - ContextBar.height) then 
                                ContextBar.entries[i].y = sy - ContextBar.height 
                            end 
                        end 
                    end 
                elseif #ContextBar.entries == 1 then 
                    if not ContextBar.entries[1].landed then 
                        ContextBar.entries[1].landed = true 
                        ContextBar.entries[1].creation = tick 
                    end 
      
                    if tick > (ContextBar.entries[1].creation + ContextBar.life) then                   
                        ContextBar.entries[1].alpha = ContextBar.entries[1].alpha - ContextBar.entries[1].alphaStep 
                        
                        if ContextBar.entries[1].alpha <= 0 then 
                            ContextBar.entries[1] = nil 
                        end 
                    end 
                end 
            end 
        end 
    ) 
      
    function math.lerp(from, to, t) 
        return from + (to - from) * t 
    end 
      
    function add() 
        ContextBar.add("Basic Testing.") 
    end 
    addCommandHandler("test2",add) 

i wanted a function the same as output chatbox but than @ the notification bar, i saw in the resource description you have to use a line that i currently cant get because the resource page seems not to work atm

i wanted to set the following line in the box but it didnt succes : output("This vehicle is locked to the the following account's: "..tostring(datato), player, 200, 0, 0) [sERVER SIDE SCRIPT]

Link to comment

The community is working fine, make sure the resource has exported functions ( server side ).

P.S: I didn't "fix" it, since it was from GUIeditor by Remp, it couldn't exactly be stripped out, you had to take other parts to make it work, searching them is all I did.

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...