[Solved] script:chat SCRIPT ERROR: type 'function' is not supported by JSON (problem when I use /setjob)

image

Idk why o how solve this… problem when I use /setjob

Somewhere in your code you are using json.encode - to convert a Lua table into a JSON encoded string. However the issue lies in your Lua table you are attempting to convert, which contains a function. To resolve this issue, remove the function, and the error message should disappear.

For example, before:

RegisterCommand('setjob', function()
    -- Your Lua table with a function
    local myTable = {
        key1 = "value1",
        key2 = "value2",
        myFunction = function()
            -- Your function code here
        end
    }
    json.encode(myTable)
end)

After:

RegisterCommand('setjob', function()
    -- Your Lua table with a function
    local myTable = {
        key1 = "value1",
        key2 = "value2",
    }
    json.encode(myTable)
end)

Maybe is a possible solution but I this time I changed this code:

Code Location: es_extended/server/commands
Lines: 33 and 34

1 Like

what did you exactly change, because im having same problem

You’re passing a function into a json.encode()