JoZeFSvK Posted February 21, 2013 Share Posted February 21, 2013 Hey i dont know how use "local wtf= i wanna here text function createText ( ) local nazov = HELLO WORLD dxDrawText( nazov,sw/2-350, sh/2-75, 700, 150, tocolor ( 255, 0, 0, 255 ), 1.02, "defalut-blod" ) end addEvent( "onTravelScreenStart", true, createText ) it is good ? and dx code function dxDrawColorText(str, ax, ay, bx, by, color, scale, font, alignX, alignY) if alignX then if alignX == "center" then local w = dxGetTextWidth(str:gsub("#%x%x%x%x%x%x",""), scale, font) ax = ax + (bx-ax)/2 - w/2 elseif alignX == "right" then local w = dxGetTextWidth(str:gsub("#%x%x%x%x%x%x",""), scale, font) ax = bx - w end end if alignY then if alignY == "center" then local h = dxGetFontHeight(scale, font) ay = ay + (by-ay)/2 - h/2 elseif alignY == "bottom" then local h = dxGetFontHeight(scale, font) ay = by - h end end local pat = "(.-)#(%x%x%x%x%x%x)" local s, e, cap, col = str:find(pat, 1) local last = 1 while s do if cap == "" and col then color = tocolor(tonumber("0x"..col:sub(1, 2)), tonumber("0x"..col:sub(3, 4)), tonumber("0x"..col:sub(5, 6)), 255) end if s ~= 1 or cap ~= "" then local w = dxGetTextWidth(cap, scale, font) dxDrawText(cap, ax, ay, ax + w, by, color, scale, font) ax = ax + w color = tocolor(tonumber("0x"..col:sub(1, 2)), tonumber("0x"..col:sub(3, 4)), tonumber("0x"..col:sub(5, 6)), 255) end last = e + 1 s, e, cap, col = str:find(pat, last) end if last <= #str then cap = str:sub(last) local w = dxGetTextWidth(cap, scale, font) dxDrawText(cap, ax, ay, ax + w, by, color, scale, font) end end function dxDrawingColorText(str, ax, ay, bx, by, color, alpha, scale, font, alignX, alignY) if alignX then if alignX == "center" then local w = dxGetTextWidth(str:gsub("#%x%x%x%x%x%x",""), scale, font) ax = ax + (bx-ax)/2 - w/2 elseif alignX == "right" then local w = dxGetTextWidth(str:gsub("#%x%x%x%x%x%x",""), scale, font) ax = bx - w end end if alignY then if alignY == "center" then local h = dxGetFontHeight(scale, font) ay = ay + (by-ay)/2 - h/2 elseif alignY == "bottom" then local h = dxGetFontHeight(scale, font) ay = by - h end end local pat = "(.-)#(%x%x%x%x%x%x)" local s, e, cap, col = str:find(pat, 1) local last = 1 while s do if cap == "" and col then color = tocolor(tonumber("0x"..col:sub(1, 2)), tonumber("0x"..col:sub(3, 4)), tonumber("0x"..col:sub(5, 6)), alpha) end if s ~= 1 or cap ~= "" then local w = dxGetTextWidth(cap, scale, font) dxDrawText(cap, ax, ay, ax + w, by, color, scale, font) ax = ax + w color = tocolor(tonumber("0x"..col:sub(1, 2)), tonumber("0x"..col:sub(3, 4)), tonumber("0x"..col:sub(5, 6)), alpha) end last = e + 1 s, e, cap, col = str:find(pat, last) end if last <= #str then cap = str:sub(last) local w = dxGetTextWidth(cap, scale, font) dxDrawText(cap, ax, ay, ax + w, by, color, scale, font) end end Link to comment
tosfera Posted February 21, 2013 Share Posted February 21, 2013 The script is almost right, you should have gotten an error about a string. 'cause text is usually as a string. So, change the var to a string and it should work: function createText ( ) local nazov = "HELLO WORLD" dxDrawText( nazov,sw/2-350, sh/2-75, 700, 150, tocolor ( 255, 0, 0, 255 ), 1.02, "defalut-blod" ) end but before the dxDrawText is working, you need to use a onClientRender, try this: client: local screenWidth, screenHeight = guiGetScreenSize ( ) function errorMsg ( errorStr ) errorMsg = errorStr addEventHandler("onClientRender", root, drawErrorMsg ) setTimer ( function ( ) removeEventHandler("onClientRender", root, drawErrorMsg ) end ,5000, 1 ) end function drawErrorMsg ( ) dxDrawText ( errorMsg, (screenWidth / 2 ) + 10, (screenHeight /4), screenWidth, screenHeight, tocolor ( 255, 255, 255, 255 ), 1, "default-bold" ) end To call this functions, use the clientTriggerEvent in the server script, like this: triggerClientEvent(thePlayer, "errorMsg", root, "This is being drawed on the screen!") Link to comment
PaiN^ Posted February 21, 2013 Share Posted February 21, 2013 Why use local ?? dxDrawText( "HELLO WORLD",sw/2-350, sh/2-75, 700, 150, tocolor ( 255, 0, 0, 255 ), 1.02, "defalut-blod" ) + you didn't but strings "" at your local Hey i dont know how use "local wtf= i wanna here text local nazov = HELLO WORLD Link to comment
JoZeFSvK Posted February 21, 2013 Author Share Posted February 21, 2013 Why use local ?? dxDrawText( "HELLO WORLD",sw/2-350, sh/2-75, 700, 150, tocolor ( 255, 0, 0, 255 ), 1.02, "defalut-blod" ) + you didn't but strings "" at your local Hey i dont know how use "local wtf= i wanna here text local nazov = HELLO WORLD Thank you, i need this ^^, i use local text= ... therefore they i search on wiki, but thank you script work, i wish you good day 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