Jump to content

dxDrawText Error Help!


MatreN

Recommended Posts

Posted
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 ( ͡°◡ ͡°   )

  • Moderators
Posted (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 by IIYAMA

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...