Popular Post NeXuS™ Posted March 18, 2017 Popular Post Share Posted March 18, 2017 (edited) NeXuS™ presents dxDrawScrollingText Introduction Do you want to make a scrolling text? It's easy with just a function. Status IN DEVELOPMENT It's still IN DEVELOPMENT but it's published. Screenshot Usage example exports.dxDrawScrollingText:dxCreateScrollingText(500, 400, 100, "Test scrolling text", 60) (This is shown on the screenshot.) Download MTA:SA Community Link Syntax nil dxCreateScrollingText ( float x, float y, float width, string text, int pixelPer60 ) Spoiler x: the absolute X coordinate of the top left corner of the text y: the absolute Y coordinate of the top left corner of the text width: An float representing the width of the text, drawn in a right direction from the origin. text: the text to draw pixelPer60: An float representing how much pixel should the text be shifted after 60 frames are gone. Source code Spoiler local sX, sY = guiGetScreenSize() local scrollingTexts = {} local textsPerRenderTarget = 40 local renderTargets = {} local cFps function getCFPS(timeSlice) cFps = (1/timeSlice)*1000 end addEventHandler("onClientPreRender", root, getCFPS) function dxCreateScrollingText(x, y, width, text, pixelPer60) local renderTargetN = math.floor(#scrollingTexts/textsPerRenderTarget)+1 > #renderTargets and #renderTargets + 1 or #renderTargets if renderTargetN > #renderTargets then table.insert(renderTargets, dxCreateRenderTarget(1366, textsPerRenderTarget*15, true)) end table.insert(scrollingTexts, {x, y, width, text, pixelPer60, -dxGetTextWidth(text, 1, "default-bold"), renderTargetN, true}) outputChatBox(#scrollingTexts) outputChatBox(#renderTargets) end addEventHandler("onClientRender", getRootElement(), function() for i, k in ipairs(scrollingTexts) do if k[8] then local movePixel = (k[5]/60*(60/cFps)) outputChatBox(movePixel) k[6] = k[6] + movePixel dxSetRenderTarget(renderTargets[k[7]], true) dxDrawText(k[4], k[6], (i-1)*15, k[3], i*15, tocolor(255, 255, 255, 255), 1, "default-bold", nil, nil, true) dxSetRenderTarget() dxDrawImageSection(k[1], k[2], 1366, 15, 0, (i-1)*15, 1366, 15, renderTargets[k[7]]) if k[6] > k[3] then k[6] = -dxGetTextWidth(k[4], 1, "default-bold") end end end end) Edited March 18, 2017 by NeXuS™ Added source code 5 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