FlyingSpoon Posted July 31, 2016 Share Posted July 31, 2016 I have an almost finished notifications system, how can I check for the end of the rectangle? so when the text reaches the end it starts a new line, how would I do this? if (finda) then local height = (finda*14)+30 dxDrawRectangle(screenW * 0.8336, screenH * 0.0221 + yOffset, screenW * 0.1586, height, tocolor(0, 0, 0, v.alpha * 0.6)) dxDrawRectangle(screenW * 0.8289, screenH * 0.0221 + yOffset, screenW * 0.0047, height, tocolor(28, 96, 118, v.alpha * 0.6)) dxDrawText(v.text, screenW * 0.8391, screenH * 0.0299 + yOffset, screenW * 0.9844, screenH * 0.0885, tocolor(255, 255, 255, v.alpha), 1.00, "default", "left", "top", false, false, false, false, false) yOffset = yOffset + (v.heightMultiplier or 1) * (height + margin) Link to comment
Wumbaloo Posted July 31, 2016 Share Posted July 31, 2016 set the dxDrawText wordBreak value to true ? wordBreak: if set to true, the text will wrap to a new line whenever it reaches the right side of the bounding box. If false, the text will always be completely on one line. Link to comment
LabiVila Posted July 31, 2016 Share Posted July 31, 2016 No, wordBreak won't do stuff if it's inside a dxDrawRectangle and you using a table, then you can make a count = 0 then start count = count + 1 for every loop it passes. Then you can do if (k == 5 [like 5 elements (or five texts) fill a rectangle]) then you can create a scrollBar. I don't think there is a function to check a bottom like say) Link to comment
FlyingSpoon Posted August 2, 2016 Author Share Posted August 2, 2016 Okay forget that, how would I do it so there is a dx scrollbar and text, without a memo, and I can scroll down the text, I saw it on some servers and was wondering how to do it. Link to comment
roaddog Posted August 2, 2016 Share Posted August 2, 2016 Use scrollpane https://wiki.multitheftauto.com/wiki/Gu ... ScrollPane Link to comment
Bonus Posted August 2, 2016 Share Posted August 2, 2016 scrollpane is a GUI ... You can use dxDrawRectangle (2x) and onClientClick so you can click on it. Can show you an example in some minutes. local screenX, screenY = guiGetScreenSize() local sx, sy = screenX/1920, screenY/1080 local scrollplayers = 0 local maxplayerswithoutscroll = 15 dxDrawRectangle ( screenX*0.4, screenY*0.35, screenX*0.02, screenY*0.01, tocolor ( 160, 160, 160, 184 ), true ) -- Scroll rectangle to click (up) dxDrawRectangle ( screenX*0.4, screenY*0.64, screenX*0.02, screenY*0.01, tocolor ( 160, 160, 160, 184 ), true ) -- Scroll rectangle to click (down) dxDrawRectangle ( screenX*0.4, screenY*0.36, screenX*0.02, screenY*0.28, tocolor ( 50, 50, 50, 184 ), true ) -- Scroll background dxDrawLine ( screenX*0.41, screenY*0.37, screenX*0.41, screenY*0.63, tocolor ( 0, 0, 0, 184 ), 1*sx, true ) -- Scroll line for optics local amount = #playersinlobby[playerlobby] - maxplayerswithoutscroll -- amount not showing if amount > 0 then -- if you can scroll dxDrawRectangle ( screenX*0.401, screenY*0.361+scrollplayers*screenY*0.2798/(amount+1), screenX*0.018, screenY*0.2798/(amount+1), tocolor ( 10, 10, 10, 184 ), true ) else -- if you cant scroll dxDrawRectangle ( screenX*0.401, screenY*0.361, screenX*0.018, screenY*0.2798, tocolor ( 10, 10, 10, 184 ), true ) end addEventHandler ( "onClientClick", root, function ( ) if x >= screenX*0.4 and x <= screenX*0.42 and y >= screenY*0.35 and y <= screenY*0.65 then if y < screenY*0.36 then scrollplayers = scrollplayers > 0 and scrollplayers - 1 or 0 elseif y > screenY*0.64 then scrollplayers = scrollplayers+maxplayerswithoutscroll < #playersinlobby[playerlobby] and scrollplayers + 1 or scrollplayers else local amount = #playersinlobby[playerlobby] if amount > maxplayerswithoutscroll then scrollplayers = roundNumber ( ( y - screenY*0.36 ) / ( screenY*0.28 ) * ( #playersinlobby[playerlobby]-maxplayerswithoutscroll ) ) else scrollplayers = 0 end end end end ) for i=1+scrollplayers, maxplayerswithoutscroll+scrollplayers do --- end You can see it better here: http://hastebin.com/ijopayeyay.lua 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