Not

Apparently my title didn’t work properly, it meant to say Functions Not Running

Me again. I must be doing something wrong, but am trying to keep my files split up to make it easier later as things progress.

I’ve got my sv_init.lua file with is in addons/sgn_darkrpmod/lua/autorun/server/sv_init.lua.



SGNDarkRP = {}
SGNDarkRP.Config = {}
SGNDarkRP.Config.Dev = {}
SGNDarkRP.Config.Client = {}
SGNDarkRP.Config.Misc = {}
SGNDarkRP.Config.Server = {}

print("=========================================================")
print("SGNDARKRP IS LOADING...")
print("INCLUDING ALL FILES")
print("=========================================================")

include("../../functions.lua")

include("../../databases.lua")

include("../../settings/config.lua")

include("../../playerlogin.lua")

include("../../modules/apartments/sv_apartments.lua")
AddCSLuaFile("../../modules/apartments/cl_apartments.lua")

include("../../modules/charactercreation/sv_charactercreation.lua")
AddCSLuaFile("../../modules/charactercreation/cl_charactercreation.lua")

include("../../modules/hud/sv_hud.lua")
AddCSLuaFile("../../modules/hud/cl_hud.lua")

include("../../modules/inventory/sv_inventory.lua")
AddCSLuaFile("../../modules/inventory/cl_inventory.lua")

include("../../modules/laws/sv_laws.lua")

include("../../modules/quests/sv_quests.lua")
AddCSLuaFile("../../modules/quests/cl_quests.lua")



print("=========================================================")
print("SGNDARKRP HAS LOADED")
print("=========================================================")


As this includes functions.lua, it then runs the following in addons/sgn_darkrpmod/lua/functions.lua

The hook.Call at the end makes sure that the next part isn’t ran until these functions has been read ( was having a problem with then the dbcreation function not being ready when the next part is called.)

It also includes databases.lua, found in the same directory as functions.lua



print("database.lua has loaded." )

local function createDBTables()
	print("We are now attempting to create the tabes needed............................")
	dbTableCreation( "characterdata", "CREATE TABLE characterdata ( steamid varchar(255), characterid int, firstname varchar(255), lastname varchar(255), bio varchar(255), charactermodel varchar(255), posx int, posy int, posz int )" )
	print("We have now finsihed........................................................")
end
hook.Add( "FunctionsLuaHasLoaded", "FunctionsLuaHasLoaded", createDBTables )

print("database.lua has loaded." )


At the moment, createDBTables is not being called from the FunctionsLuaHasLoaded hook, however it was a while back when I moved some files around. Even then, it didn’t run dbTableCreation ( no errors, just didn’t happen ), which can be found in functions.lua.

Any help would be appreciated as I’ve been looking at this for a while now. I’ll keep looking over this to see if I’ve missed anything, but any input would be great!

From the console…

functions.lua has loaded.
functions.lua has loaded.
database.lua has loaded.
database.lua has loaded.

Those all get printed, one print at the top and bottom of each file, so I’m guessing they are both loading, but…

print(“The function was called…”) does not print, and neither does:

print(“We are now attempting to create the tabes needed…”)

[editline]7th June 2014[/editline]

Why mark it as dumb, if I’m being dumb then tell me lol but at least point me in the right direction.



hook.Call( "FunctionsLuaHasLoaded" )


Should become



hook.Call( "FunctionsLuaHasLoaded", GAMEMODE )


and somewhere else in your code add this:



local gm = GM or GAMEMODE or {}

function gm:FunctionsLuaHasLoaded( )

end


Hey, thanks for your reply. I’ve moved it around a bit to make things easier.

Here are the three files I am currently having issues with, as I think my problem lies with not understanding something else:

(I am print screening them as code tags seem to be screwing up with some things)

addons/sgn_darkrpmod/lua/autorun/server/init.lua

addons/sgn_darkrpmod/lua/functions.lua

addons/sgn_darkrpmod/lua/databases.lua

Ok so on start, it includes functions.lua and databases.lua.



functions.lua has loaded.
functions.lua has loaded.
database.lua has loaded.
We are now attempting to create the tabes needed............................
The function was called.............................................
We have now finsihed........................................................
database.lua has loaded.
playerlogin.lua has been loaded.
playerlogin.lua has been loaded.


It loads functions, then goto’s databases. It loads that, tries to create the tables, the “The function was called…” message is printing, so it does call dbTableCreation, however then doesn’t print any of the debugText about whether it happens or not. So it obviously isn’t doing the debugText. I have just removed the variable check " if SGNDarkRP.Config.Dev.debugEnabled == true then" however it still doesn’t print it :confused:

[editline]7th June 2014[/editline]

Ok thanks guys I’ve narrowed it down to an issue with my config file :slight_smile: I will take another look.