xXMADEXx Posted February 5, 2013 Posted February 5, 2013 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) The Ultimate Lua Tutorial! | MTA PHP SDK
Castillo Posted February 5, 2013 Posted February 5, 2013 Do you have permission to use that code? San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
AJXB Posted February 5, 2013 Posted February 5, 2013 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.
Castillo Posted February 5, 2013 Posted February 5, 2013 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. Education is the most powerful weapon which you can use to change the world.
AJXB Posted February 5, 2013 Posted February 5, 2013 Thank you, A question about another script, How is getPlayerAccount returns nil value? ~ 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.
Castillo Posted February 5, 2013 Posted February 5, 2013 You are using it client side? San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
AJXB Posted February 5, 2013 Posted February 5, 2013 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.
Castillo Posted February 5, 2013 Posted February 5, 2013 All account functions are server side only. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
AJXB Posted February 5, 2013 Posted February 5, 2013 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.
AJXB Posted February 5, 2013 Posted February 5, 2013 Castillo, this script do outputChatBox too ~ 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.
Castillo Posted February 5, 2013 Posted February 5, 2013 Of what script are you talking about? San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
AJXB Posted February 5, 2013 Posted February 5, 2013 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.
Castillo Posted February 5, 2013 Posted February 5, 2013 Oh, yeah, I forgot to remove it, remove this line: outputChatBox ( ContextBar.entries[#ContextBar.entries].text ) San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
AJXB Posted February 5, 2013 Posted February 5, 2013 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.
Castillo Posted February 5, 2013 Posted February 5, 2013 You're welcome. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now