Hero192 Posted August 10, 2015 Share Posted August 10, 2015 it's topbarchat system, i want let the first rectangle shows with dark color and others shows with alpha 100 for example , local timer = nil local text = "" local text2 = "" local messages = { } local r,g,b = 255,255,255 local isColorCoded = false function sendMessage( message, red, green, blue, colorCoded ) if colorCoded == nil then colorCoded = false end text = message r = red g = green b = blue isColorCoded = colorCoded if isTimer( timer ) then killTimer( timer ) end timer = setTimer( function() text = "" end, 200, 1 ) end addEvent( "onTextAdd", true ) addEventHandler( "onTextAdd", getRootElement(), sendMessage ) addEventHandler ( "onClientRender", root, function ( ) local tick = getTickCount ( ) local sx,sy = guiGetScreenSize ( ) if ( text ~= text2 and text ~= "" ) then table.insert ( messages, { text, true, tick + 7100, 120, r, g, b, isColorCoded }) end text2 = text if ( #messages > 5 ) then table.remove ( messages, 1 ) end for index, data in ipairs ( messages ) do local v1 = data[1] local v2 = data[2] local v3 = data[3] local v4 = data[4] local v5 = data[5] local v6 = data[6] local v7 = data[7] local v8 = data[8] dxDrawRectangle ( 390, (-22)+(index*21), 593, 21, tocolor( 0, 0, 0, v4+90 ) ) dxDrawText ( v1, 700, (-21)+(index*42), sx/2, 0, tocolor( v5, v6, v7, v4+100 ), 0.85, "default-bold", "center", "center", false, true, false, v8 ) if ( tick >= v3 ) then messages[index][4] = v4-120 if ( v4 <= 1 ) then table.remove ( messages, index ) end end end end) Link to comment
Hero192 Posted August 11, 2015 Author Share Posted August 11, 2015 To be more clear there's 5 max messages, i want the first message be always with (0,0,0,240) others with this color (0,0,0,140), anyone can help me? Link to comment
Olle Risk Posted August 11, 2015 Share Posted August 11, 2015 We don't give support with leaked scripts. Link to comment
Hero192 Posted August 12, 2015 Author Share Posted August 12, 2015 It's not leaked script and im not from these people who steal scripts, the author released it and i have his permission. So can anyone give me a hand ? Link to comment
Olle Risk Posted August 12, 2015 Share Posted August 12, 2015 Did the author also allow you to remove his name? who's the author? why don't you ask him for help? Link to comment
t3wz Posted August 12, 2015 Share Posted August 12, 2015 Just check if the index is equal to 1, if is you draw the text with alpha 240, otherwise with alpha 140 if index == 1 then dxDrawText ( v1, 700, (-21)+(index*42), sx/2, 0, tocolor( 0, 0, 0, 240), 0.85, "default-bold", "center", "center", false, true, false, v8 ) else dxDrawText ( v1, 700, (-21)+(index*42), sx/2, 0, tocolor( 0, 0, 0, 140), 0.85, "default-bold", "center", "center", false, true, false, v8 ) end lines 38~49. is this what you want?. Link to comment
Hero192 Posted August 13, 2015 Author Share Posted August 13, 2015 Not that but thanks for your try, i want to change the ALPHA of Rectangle not texts, i need the Last Rectangle always be with 240 and others with 140 Aplha Link to comment
Mr_Moose Posted August 13, 2015 Share Posted August 13, 2015 Still close enough, the rectangle is drawn on line 48 and the text on line 49. You just have to move the if statement one line up and it does exactly what you want. Sometimes it's wise to read the code you try to edit. if index == 1 then dxDrawRectangle ( 390, (-22)+(index*21), 593, 21, tocolor( 0, 0, 0, 240 )) else dxDrawRectangle ( 390, (-22)+(index*21), 593, 21, tocolor( 0, 0, 0, 120 )) end Link to comment
Hero192 Posted August 13, 2015 Author Share Posted August 13, 2015 I mean always the lastest message be with 240 Alpha and others with 140. like if 3 Messages sents, the last message of these 3 lines be with 240 others with 140 and if it draw only one message then it show with 240 so last message shows with this alpha 240 I hope you understand abit more Link to comment
Mr_Moose Posted August 13, 2015 Share Posted August 13, 2015 Use the length of the array "messages" then, obtained by #messages. The code will still be very similar to gl0ck's example. if index == #messages then dxDrawRectangle ( 390, (-22)+(index*21), 593, 21, tocolor( 0, 0, 0, 240 )) else dxDrawRectangle ( 390, (-22)+(index*21), 593, 21, tocolor( 0, 0, 0, 120 )) end * You may need to use "#messages - 1" if the index never get's equal to the length of table "messages", if that happens you'll see all rectangles with alpha 120. Otherwise it should work as you described. Link to comment
Hero192 Posted August 13, 2015 Author Share Posted August 13, 2015 exactly, thanks man you're the best Link to comment
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