MatreN Posted November 14, 2019 Posted November 14, 2019 local sX, sY = guiGetScreenSize() local customFonts = dxCreateFont("Roboto-Light.ttf", 82, true) local scale = {(sX/1920) * (sY/1080)}/2 local R, G, B = 255, 255, 255 function drawRects() --dxDrawRectangle(0, 0, sX*0.104, sY*0.185, tocolor(R, G, B)) --dxDrawRectangle(sX*0.104, 0, sX*0.104, sY*0.185, tocolor(0, 255, 0)) dxDrawText("Hello There!", 0, 0, sX, sY, tocolor(R, G, B) , scale*0.5, customFonts "right", "bottom") end addEventHandler("onClientRender", root, drawRects) function changeColor(_, r, g, b) R, G, B = r, g, b end addCommandHandler("rekt", changeColor) I want to print a text on the screen, but I get this error. ERROR : dxDrawText/text.Lua:5: attempt to perform arithmetic on a table value I'am HAPPY ( ͡°◡ ͡° )
MIKI785 Posted November 14, 2019 Posted November 14, 2019 local scale = {(sX/1920) * (sY/1080)}/2 You're making a table here, isn't it supposed to be regular brackets here? local scale = ((sX/1920) * (sY/1080))/2 Lua Scripter Owner of mshost.cz MTA portal.
MatreN Posted November 14, 2019 Author Posted November 14, 2019 I am not aware, I have to be careful with this. I'am HAPPY ( ͡°◡ ͡° )
Moderators IIYAMA Posted November 14, 2019 Moderators Posted November 14, 2019 (edited) Also don't forget to convert strings to numbers, when typing the command. (+ fallback) R, G, B = tonumber(r) or 255, tonumber(g) or 255, tonumber(b) or 255 Edited November 14, 2019 by IIYAMA Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
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