Pakuss
Pakuss

Reputation: 1

Fivem lua config

I am pretty new in lua and wanted to create a client sided script that draws a marker on specific coordinates. unfortunately, when i reload the resource it says

attempt to index a nil value (global 'Config') This is my config file:

Config = {}

Config.MarkerType=1

And this is the method I am trying to work with:

Citizen.CreateThread(function()
    while true do
        Citizen.Wait(1)
        DrawMarker(Config.MarkerType, 400.3, -1157.4, 28.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4.0, 4.0, 4.0, 255, 0, 0, 170, false, true, 2, nil, nil," ", false)
    end
end)

Can anyone help me? I have 2 folders in my resource folder named "client" and "server". Both contain a file named "main.lua". __resource.lua contains:

shared_script 'client/config.lua'
server_scripts {
    'server/main.lua'
}

client_scripts {
    'client/main.lua'
}

I have ESX=nil at the begining of my client sided script, so I don't really understand the problem here.

Upvotes: 0

Views: 2917

Answers (1)

Blaizz
Blaizz

Reputation: 57

The error indicates that the scripts attempts to index something that hasn't been defined (Config.MarkerType), it could be meaning multiple things :

  • The file containing the Config array wasn't loaded
  • There is an error in the file containing the Config array definition
  • The file containing the Config array is loaded after the client file

It doesn't seem to be the last two, therefore :

I have 2 folders in my resource folder named "client" and "server". Both contain a file named "main.lua". __resource.lua contains:

Where is your config.lua located ?

If it's next to __resource.lua then you should edit your file like so

shared_script 'config.lua'
server_scripts {
    'server/main.lua'
}

client_scripts {
    'client/main.lua'
}

Upvotes: 1

Related Questions