MatreN Posted November 14, 2019 Share 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 Link to comment
MIKI785 Posted November 14, 2019 Share 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 Link to comment
MatreN Posted November 14, 2019 Author Share Posted November 14, 2019 I am not aware, I have to be careful with this. Link to comment
Moderators IIYAMA Posted November 14, 2019 Moderators Share 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 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