Jump to content

How to fix this warning message in my dx script?


Turbe$Z

Recommended Posts

local screenW, screenH = guiGetScreenSize()

addEventHandler("onClientRender", root,
    function()
        dxDrawRectangle(screenW * 0.0021, screenH * 0.7356, screenW * 0.2104, screenH * 0.0367, tocolor(0, 0, 0, 164), false)
        dxDrawText(text, screenW * 0.0014, screenH * 0.7367, screenW * 0.2125, screenH * 0.7722, tocolor(255, 255, 255, 255), 1.00, "default-bold", "center", "center", false, false, false, true, false)
    end
)

addEventHandler("onClientPlayerJoin", root, function()
  local l_2_0 = getPlayerName(source)
  text = "#00ff00" .. l_2_0 .. " csatlakozott!"
  pic = "j"
end
)
addEventHandler("onClientPlayerQuit", root, function(l_3_0)
  local l_3_1 = getPlayerName(source)
  text = "#FF0000" .. l_3_1 .. " lelépett!"
  pic = "q"
end
)

addEventHandler("onClientPlayerChangeNick", root, function(l_4_0, l_4_1)
  text = "" .. l_4_0 .. "#00FF00 Új neve #00BAFF: " .. l_4_1 .. ""
  pic = "c"
end
)


fileDelete("client.lua")

and i got this warning: : 6 : bad argument 'dxDrawText' [expected string at argument 1, got nil] how to fix this? -_- 

Link to comment

 

The variable "text" does not exist as global so in order to access it as a global variable you must define it globally. To make the variable available for access inside this lua file only then all you need to do is simply define it at top. Put this in line 2.

local text = "" -- Global within lua file only which means you can now access it via any function within lua file which has this defined.

If you want to make it accessible all client lua files then define it like this

text = "" -- Global to all client lua files within resource.

Now, it is fully global and available for all client files.

For more information, refer to https://www.lua.org/pil/14.html

Edited by Saml1er
Link to comment

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...