Including Files Help Needed

Hello, I have the following code that shows my 3 files and the errors, it looks as though functions.lua isn’t loading till after all the others, even though it’s at the top of the sv_init.lua file:

Sorry for the huge wall of code :smiley:




addons/sgn_darkrpmod/lua/autorun/server/sv_init.lua
 
print("=========================================================")
print("SGNDarkRP IS LOADING...")
print("INCLUDING ALL FILES")
print("=========================================================")
 
include("../../functions.lua")
 
include("../../databases.lua")
 
include("../../settings/config.lua")
 
include("../../modules/apartments/sv_apartments.lua")
include("../../modules/apartments/cl_apartments.lua")
 
include("../../modules/character/sv_character.lua")
include("../../modules/character/cl_character.lua")
 
include("../../modules/hud/sv_hud.lua")
include("../../modules/hud/cl_hud.lua")
 
include("../../modules/inventory/sv_inventory.lua")
include("../../modules/inventory/cl_inventory.lua")
 
include("../../modules/laws/sv_laws.lua")
include("../../modules/laws/cl_laws.lua")
 
include("../../modules/quests/sv_quests.lua")
include("../../modules/quests/cl_quests.lua")
 
 
 
print("=========================================================")
print("SGNDarkRP HAS LOADED")
print("=========================================================")
 
SGNDarkRP = {}
SGNDarkRP.Config = {}
SGNDarkRP.Config.Misc = {}
SGNDarkRP.Config.Client = {}
 
 
=====================================================================================================
=====================================================================================================
=====================================================================================================
=====================================================================================================
=====================================================================================================
=====================================================================================================
 
addons/sgn_darkrpmod/lua/functions.lua
 
print(" THE CONFIG FILE HAS LOALDED ==========================132913570159871529871598751298790")
 
//Prints debut text to the console
function debugTextA( message )
                print( "DEBUG: " .. message )
end
 
//Function for creating a table and checking it was created fully
function dbTableCreation( tablename, queryString )
        if ( sql.TableExists( tablename ) ) then
            debugText( "The table '" .. tablename .. "' was found." )
            sql.Query( "DROP TABLE " .. tablename )
            debugText( "The table '" .. tablename .. "' was dropped." )
        end
    if ( !sql.TableExists( tablename ) ) then
        query = queryString
        result = sql.Query( query )
        debugText( "The table " .. tablename .. " was not found.")
        if ( sql.TableExists( tablename ) ) then
            debugText( "The table '" .. tablename .. "' was created." )
        else
            debugText( "The table '" .. tablename .. "' was not created, something went wrong." )
            debugText( sql.LastError( result ) )
        end
    end
end
 
 
=====================================================================================================
=====================================================================================================
=====================================================================================================
=====================================================================================================
=====================================================================================================
 
addons/sgn_darkrpmod/lua/modules/inventory/sv_inventory.lua
 
debugText("sv_inventory.lua has been loaded.")
 
=====================================================================================================
=====================================================================================================
=====================================================================================================
=====================================================================================================
=====================================================================================================
 
 
ERROR:
 
=========================================================
SGNDARKRP IS LOADING...
INCLUDING ALL FILES
=========================================================
 
[ERROR] addons/sgn_darkrpmod/lua/autorun/server/../../modules/apartments/sv_apartments.lua:1: attempt to call global 'debugText' (a nil value)
  1. unknown - addons/sgn_darkrpmod/lua/autorun/server/../../modules/apartments/sv_apartments.lua:1
   2. include - [C]:-1
    3. unknown - addons/sgn_darkrpmod/lua/autorun/server/sv_init.lua:8
 
Couldn't include file '../../modules/apartments/cl_apartments.lua' (File not found) (@addons/sgn_darkrpmod/lua/autorun/server/sv_init.lua (line 9))
 
[ERROR] addons/sgn_darkrpmod/lua/autorun/server/../../modules/character/sv_character.lua:1: attempt to call global 'debugText' (a nil value)
 1. unknown - addons/sgn_darkrpmod/lua/autorun/server/../../modules/character/sv_character.lua:1
  2. include - [C]:-1
   3. unknown - addons/sgn_darkrpmod/lua/autorun/server/sv_init.lua:11
 
Couldn't include file '../../modules/character/cl_character.lua' (File not found) (@addons/sgn_darkrpmod/lua/autorun/server/sv_init.lua (line 12))
 
[ERROR] addons/sgn_darkrpmod/lua/autorun/server/../../modules/hud/sv_hud.lua:1: attempt to call global 'debugText' (a nil value)
  1. unknown - addons/sgn_darkrpmod/lua/autorun/server/../../modules/hud/sv_hud.lua:1
   2. include - [C]:-1
    3. unknown - addons/sgn_darkrpmod/lua/autorun/server/sv_init.lua:14
 
Couldn't include file '../../modules/hud/cl_hud.lua' (File not found) (@addons/sgn_darkrpmod/lua/autorun/server/sv_init.lua (line 15))
 
[ERROR] addons/sgn_darkrpmod/lua/autorun/server/../../modules/inventory/sv_inventory.lua:1: attempt to call global 'debugText' (a nil value)
 1. unknown - addons/sgn_darkrpmod/lua/autorun/server/../../modules/inventory/sv_inventory.lua:1
  2. include - [C]:-1
   3. unknown - addons/sgn_darkrpmod/lua/autorun/server/sv_init.lua:17
 
Couldn't include file '../../modules/inventory/cl_inventory.lua' (File not found) (@addons/sgn_darkrpmod/lua/autorun/server/sv_init.lua (line 18))
[AddCSLuaFile] Couldn't find 'autorun/client/cl_laws.lua' (@addons/sgn_darkrpmod/lua/autorun/server/../../modules/laws/sv_laws.lua (line 1))
 
[ERROR] addons/sgn_darkrpmod/lua/autorun/server/../../modules/laws/sv_laws.lua:5: attempt to call global 'debugText' (a nil value)
 1. unknown - addons/sgn_darkrpmod/lua/autorun/server/../../modules/laws/sv_laws.lua:5
  2. include - [C]:-1
   3. unknown - addons/sgn_darkrpmod/lua/autorun/server/sv_init.lua:20
 
 
[ERROR] addons/sgn_darkrpmod/lua/autorun/server/../../modules/laws/cl_laws.lua:27: attempt to index global 'surface' (a nil value)
 1. unknown - addons/sgn_darkrpmod/lua/autorun/server/../../modules/laws/cl_laws.lua:27
  2. include - [C]:-1
   3. unknown - addons/sgn_darkrpmod/lua/autorun/server/sv_init.lua:21
 
 
[ERROR] addons/sgn_darkrpmod/lua/autorun/server/../../modules/quests/sv_quests.lua:1: attempt to call global 'debugText' (a nil value)
 1. unknown - addons/sgn_darkrpmod/lua/autorun/server/../../modules/quests/sv_quests.lua:1
  2. include - [C]:-1
   3. unknown - addons/sgn_darkrpmod/lua/autorun/server/sv_init.lua:23
 
Couldn't include file '../../modules/quests/cl_quests.lua' (File not found) (@addons/sgn_darkrpmod/lua/autorun/server/sv_init.lua (line 24))
 THE CONFIG FILE HAS LOALDED ==========================132913570159871529871598751298790
 
[ERROR] addons/sgn_darkrpmod/lua/autorun/server/../../databases.lua:3: attempt to call global 'debugText' (a nil value)
  1. unknown - addons/sgn_darkrpmod/lua/autorun/server/../../databases.lua:3
   2. include - [C]:-1
    3. unknown - addons/sgn_darkrpmod/lua/autorun/server/sv_init.lua:26
 
 THE CONFIG FILE HAS LOALDED ==========================132913570159871529871598751298790
Couldn't include file '../../settings/config.lua' (File not found) (@addons/sgn_darkrpmod/lua/autorun/server/sv_init.lua (line 30))
=========================================================
SGNDARKRP HAS LOADED
=========================================================


Don’t use …/ in include, just put path relative to lua/ folder. For example include(“myaddon/test.lua”) will include “lua/myaddon/test.lua”

I keep hearing people say this. So in my case, in addons/myaddon/lua/autorun/server/sv_init.lua to include addons/myaddon/lua/functions.lua I’d just do

include(“functions.lua”) However it doesn’t find it if I do that.

Isn’t it relative to the directory you’re in? Also, I know it’s including the files as it does print: THE CONFIG FILE HAS LOALDED ==========================132913570159871529871598751298790

The couldn’t include cl_ files can be ignored as they are empty. The problem I want to fix it the fact that it says debugText is a nil value, when it’s not, it’s a function in functions.lua which I know gets included as it prits the config print.

Maybe you are right, anyway, I don’t see the function debugText anywhere, your is called debugTextA.

Why do you include clientside files on server? You are not adding clientside lua files for client to download using AddCSLuaFile().

I think it’s time to goto bed :frowning: debugTextA really? I can’t believe I missed that. But yes, I will be AddCSLuaFile() to clientside files just haven’t done it yet :slight_smile: Thanks, sorry for wasting your time, should have noticed that.