Jump to content

Expected string at argument 1, got nil


Mersad

Recommended Posts

Hello!
I ran into some problems while coding:

Server:
function VoteSystem(title)
	outputChatBox ("Your Vote Title: " .. title, client)
end
addEvent("VoteConnection", true)
addEventHandler("VoteConnection", resourceRoot, VoteSystem)
Client:
sx, sy = guiGetScreenSize()
ClientGUI = {}
function VoteCommand (commandName, ...)
    local title = table.concat ( { ... }," " )
    TextDraw = tostring(title)
    triggerServerEvent ( "VoteConnection", resourceRoot, tostring(title) )
    outputChatBox(title)
end
addCommandHandler ( "vote", VoteCommand )


--ClientGUI[3] = guiCreateStaticImage( sx*0.03, sy*0.03, sx*0.5, sy*0.5, "/files/BG.png", false )
guiMoveToBack(ClientGUI[3])
addEventHandler("onClientRender", root, function()
    ClientGUI[2] = dxDrawRectangle(sx*0.2, sy*0.3, sx*0.6, sy*0.5, tocolor(0,0,0,150))
    ClientGUI[1] = dxDrawText(TextDraw, sx*0.21, sy*0.31, sx, sy, tocolor(255,0,0,255), 2)
end)

After running the code and entering /debugscript 3, the following error appears:

WARNING: vote\votes_c.lua:17: Bad argument @'dxDrawText' [Expected string at argument 1, got nil] [DUP x213]
WARNING: vote\votes_c.lua:17: Bad argument @'dxDrawText' [Expected string at argument 1, got nil]
WARNING: vote\votes_c.lua:17: Bad argument @'dxDrawText' [Expected string at argument 1, got nil] [DUP x214]
WARNING: vote\votes_c.lua:17: Bad argument @'dxDrawText' [Expected string at argument 1, got nil]
WARNING: vote\votes_c.lua:17: Bad argument @'dxDrawText' [Expected string at argument 1, got nil] [DUP x215]
WARNING: vote\votes_c.lua:17: Bad argument @'dxDrawText' [Expected string at argument 1, got nil]
WARNING: vote\votes_c.lua:17: Bad argument @'dxDrawText' [Expected string at argument 1, got nil] [DUP x213]
WARNING: vote\votes_c.lua:17: Bad argument @'dxDrawText' [Expected string at argument 1, got nil]
WARNING: vote\votes_c.lua:17: Bad argument @'dxDrawText' [Expected string at argument 1, got nil] [DUP x212]
WARNING: vote\votes_c.lua:17: Bad argument @'dxDrawText' [Expected string at argument 1, got nil]
WARNING: vote\votes_c.lua:17: Bad argument @'dxDrawText' [Expected string at argument 1, got nil] [DUP x79]
WARNING: vote\votes_c.lua:17: Bad argument @'dxDrawText' [Expected string at argument 1, got nil]
WARNING: vote\votes_c.lua:17: Bad argument @'dxDrawText' [Expected string at argument 1, got nil] [DUP x71]
WARNING: vote\votes_c.lua:17: Bad argument @'dxDrawText' [Expected string at argument 1, got nil]
WARNING: vote\votes_c.lua:17: Bad argument @'dxDrawText' [Expected string at argument 1, got nil] [DUP x87]
WARNING: vote\votes_c.lua:17: Bad argument @'dxDrawText' [Expected string at argument 1, got nil]

But the code works and by writing /vote [text], the text [text] is entered into dxDrawText

How do I fix the error?

The second problem:

In the client file:

sx, sy = guiGetScreenSize()
ClientGUI = {}
--General
function VoteCommand (commandName, ...)
    local title = table.concat ( { ... }," " )
    TextDraw = tostring(title)
    triggerServerEvent ( "VoteConnection", resourceRoot, tostring(title) )
    outputChatBox(title)
end
addCommandHandler ( "vote", VoteCommand )


ClientGUI[3] = guiCreateStaticImage( sx*0.03, sy*0.03, sx*0.5, sy*0.5, "/files/BG.png", false ) -- Image Background
guiMoveToBack(ClientGUI[3])
addEventHandler("onClientRender", root, function()
    ClientGUI[2] = dxDrawRectangle(sx*0.2, sy*0.3, sx*0.6, sy*0.5, tocolor(0,0,0,150))
    ClientGUI[1] = dxDrawText(TextDraw, sx*0.21, sy*0.31, sx, sy, tocolor(255,0,0,255), 2) -- Title
end)
--General ENDho

How do I put ClientGUI[3] = guiCreateStaticImage( sx*0.03, sy*0.03, sx*0.5, sy*0.5, "/files/BG.png", false )" under "ClientGUI[1] = dxDrawText(TextDraw, sx*0.21, sy*0.31, sx, sy, tocolor(255,0,0,255), 2)?

Link to comment
Server:
function VoteSystem(title)
	outputChatBox ("Your Vote Title: " .. title, client)
end
addEvent("VoteConnection", true)
addEventHandler("VoteConnection", resourceRoot, VoteSystem)
Client:
sx, sy = guiGetScreenSize()
ClientGUI = {}
function VoteCommand (commandName, ...)
    local title = table.concat ( { ... }," " )
    TextDraw = tostring(title)
    triggerServerEvent ( "VoteConnection", resourceRoot, tostring(title) )
    addEventHandler("onClientRender",root,render) 
    outputChatBox(title)
end
addCommandHandler ( "vote", VoteCommand )
 
function render()
    ClientGUI[2] = dxDrawRectangle(sx*0.2, sy*0.3, sx*0.6, sy*0.5, tocolor(0,0,0,150))
    ClientGUI[1] = dxDrawText(TextDraw, sx*0.21, sy*0.31, sx, sy, tocolor(255,0,0,255), 2)
    if not ClientGUI[3] then
        -- create static image
    end
end)

 

  • Thanks 1
Link to comment
2 hours ago, shishani said:

did it help you? let me know

It Works To Some Extent!❤️

I made the previous code more complete and still dxDrawText placed under guiCreateStaticImage!

Server:

function VoteSystem(title)
	outputChatBox ("Your Vote Title: " .. title, client)
end
addEvent("VoteConnection", true)
addEventHandler("VoteConnection", resourceRoot, VoteSystem)

Client:

sx, sy = guiGetScreenSize()
ClientGUI = {}
VoteStatus = false

function votepanel()
    VoteStatus = true
    ClientGUI[3] = guiCreateStaticImage(0, 0, sx, sy, "/files/BG.png", false)
    ClientGUI[4] = guiCreateStaticImage(sx*0.85, sy*0.08, sx*0.1, sy*0.1, "/files/exit.png", false)
    ClientGUI[5] = guiCreateStaticImage(sx*0.3, sy*0.3, sx*0.4, sy*0.09, "/files/yes.png", false)
    ClientGUI[6] = guiCreateStaticImage(sx*0.3, sy*0.41, sx*0.4, sy*0.09, "/files/no.png", false)
    showCursor(true)
end

addCommandHandler("ray", function()
    votepanel()
end)

function HideVotePanel()
    for i, v in pairs(ClientGUI) do
        if (v) then
            destroyElement(v)
        end
    end
    VoteStatus = false
    showCursor(false)
end

addEventHandler("onClientGUIClick", root, function()
    if (VoteStatus) then
        if (source == ClientGUI[4]) then
            HideVotePanel()
        end
    end
end)

function VoteCommand (commandName, ...)
    local title = table.concat ( { ... }," " )
    TextDraw = tostring(title)
    triggerServerEvent ( "VoteConnection", resourceRoot, tostring(title) )
    addEventHandler("onClientRender",root,render) 
    outputChatBox(title)
end
addCommandHandler ( "vote", VoteCommand )

function render()
    ClientGUI[1] = dxDrawText(TextDraw, sx*0.21, sy*0.31, sx, sy, tocolor(255,0,0,255), 2)
end

Many Thanks!

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