It's best to structure your gamemode so that it's easy for you to find things.
If you have a set of functions designed for loading/saving players, you might have a sv_playersave.lua file or something like that.
If you want to keep your custom hud code separate, you could have a cl_hud.lua
That being said.. garrysmod will only load 3 files by default when your gamemode starts.
init.lua
cl_init.lua
shared.lua
You'll need to include your files you wish to load inside of those files. As well as AddCSLuaFile them if they are client or shared files.
Personally, I have a modules folder inside my gamemode folder that I iterate through and include all of the files in my gamemode. This makes adding new files very easy.
This is what the top of my init.lua file looks like.
AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
include( "shared.lua" )
local files, dirs = file.Find("gmstranded/gamemode/modules/client/*.lua", "LUA")
for k, v in pairs( files ) do
ServerLog("Stranded: Loading module (" .. v .. ")\n")
AddCSLuaFile( "gmstranded/gamemode/modules/client/" .. v )
end
local files, dirs = file.Find("gmstranded/gamemode/modules/server/*.lua", "LUA")
for k, v in pairs( files ) do
ServerLog("Stranded: Loading module (" .. v .. ")\n")
include( "gmstranded/gamemode/modules/server/" .. v )
end
Top of my cl_init.lua:
include( "shared.lua" )
local files, dirs = file.Find("gmstranded/gamemode/modules/client/*.lua", "LUA")
for k, v in pairs( files ) do
print("Stranded: Loading module (" .. v .. ")")
include( "gmstranded/gamemode/modules/client/" .. v )
end
And, top of my shared.lua file:
local files, dirs = file.Find("gmstranded/gamemode/modules/*.lua", "LUA")
for k, v in pairs( files ) do
print("Stranded: Loading module (" .. v .. ")")
include( "gmstranded/gamemode/modules/" .. v )
AddCSLuaFile( "gmstranded/gamemode/modules/" .. v )
end
Essentially at this point, if I want to add a new shared file, I just create a new lua file in gamemode/modules and it loads the file in both the clientside and serverside lua states.
If I want to create just a clientside file, I add one to gamemode/modules/client
and likewise for serverside: gamemode/modules/server
I hope this points you in the right direction.. if you want more info or help, just ask.