Jump to content

Help on Notification Bar


xXMADEXx

Recommended Posts

Posted

Hey guys, i got the notification bar from GUI-editor (thank you, Remp.) But, when i tried to use it, no luck. Any probs seen below, please comment.

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 = {} 
} 
function ContextBar.add(text) 
    if not gEnabled then 
        return 
    end 
     
    local y = gScreen.y - 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 = (gScreen.y - 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, gScreen.x, ContextBar.height, tocolor(0, 0, 0, math.lerp(0, 170, bar.alpha)), true) 
            dxDrawText(bar.text, 0, bar.y, gScreen.x, 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, gScreen.x, 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 > gScreen.y 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 > (gScreen.y - ContextBar.height) then 
                            ContextBar.entries[i].y = gScreen.y - 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 add() 
    ContextBar.add("Basic Testing.") 
end 
addCommandHandler("test",add) 

Posted

Do you have permission to use that code?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Yes, Castillo, We have.

~ This has to be the worst board post I have ever read. It simply makes no sense. You start off by talking about space or something, then you randomly start babbling about cupcakes, and you end off with random fish names.

~ Don't listen to this guy, any board with the categories 'dinosaurs, spaceships, fried foods, wild animals, alien abductions, business casual, robots, and fireworks' has true potential.

 

Posted

Ok, I asked to Remp and he says that he gave permission, so I've fixed the code ( you had missing stuff, plus "test" command is built-in MTA, so I renamed it to "test2" ).

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) 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Thank you, A question about another script, How is getPlayerAccount returns nil value? :S

~ This has to be the worst board post I have ever read. It simply makes no sense. You start off by talking about space or something, then you randomly start babbling about cupcakes, and you end off with random fish names.

~ Don't listen to this guy, any board with the categories 'dinosaurs, spaceships, fried foods, wild animals, alien abductions, business casual, robots, and fireworks' has true potential.

 

Posted

You are using it client side?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

yes?

~ This has to be the worst board post I have ever read. It simply makes no sense. You start off by talking about space or something, then you randomly start babbling about cupcakes, and you end off with random fish names.

~ Don't listen to this guy, any board with the categories 'dinosaurs, spaceships, fried foods, wild animals, alien abductions, business casual, robots, and fireworks' has true potential.

 

Posted

All account functions are server side only.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

thank you. :-)

~ This has to be the worst board post I have ever read. It simply makes no sense. You start off by talking about space or something, then you randomly start babbling about cupcakes, and you end off with random fish names.

~ Don't listen to this guy, any board with the categories 'dinosaurs, spaceships, fried foods, wild animals, alien abductions, business casual, robots, and fireworks' has true potential.

 

Posted

Castillo, this script do outputChatBox too :S

~ This has to be the worst board post I have ever read. It simply makes no sense. You start off by talking about space or something, then you randomly start babbling about cupcakes, and you end off with random fish names.

~ Don't listen to this guy, any board with the categories 'dinosaurs, spaceships, fried foods, wild animals, alien abductions, business casual, robots, and fireworks' has true potential.

 

Posted

Of what script are you talking about?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

this, the one you fixed, it output to the message box, and to chat box

~ This has to be the worst board post I have ever read. It simply makes no sense. You start off by talking about space or something, then you randomly start babbling about cupcakes, and you end off with random fish names.

~ Don't listen to this guy, any board with the categories 'dinosaurs, spaceships, fried foods, wild animals, alien abductions, business casual, robots, and fireworks' has true potential.

 

Posted

Oh, yeah, I forgot to remove it, remove this line:

outputChatBox ( ContextBar.entries[#ContextBar.entries].text ) 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

thanks

~ This has to be the worst board post I have ever read. It simply makes no sense. You start off by talking about space or something, then you randomly start babbling about cupcakes, and you end off with random fish names.

~ Don't listen to this guy, any board with the categories 'dinosaurs, spaceships, fried foods, wild animals, alien abductions, business casual, robots, and fireworks' has true potential.

 

Posted

You're welcome.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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...