Custom gamemode couldn't include file

Allright so i just added a few new things to my gamemode, and in gamemode i added a folder called modules and put my cl_hud.lua, salary.lua in there.
I changed the include paths to include( “modules/cl_hud.lua” ) same with the salary, and it still doesn’t seem to be working
Im getting this error in console:



Couldn't include file 'shared.lua' (File not found) (@gamemodes/seriousrp/gamemode/cl_init.lua (line 1))
Couldn't include file 'sh_player.lua' (File not found) (@gamemodes/seriousrp/gamemode/cl_init.lua (line 3))
Couldn't include file 'modules\cl_hud.lua' (File not found) (@gamemodes/seriousrp/gamemode/cl_init.lua (line 4))


Files must not be empty and clientside and shared files must be AddCSLuaFile’d on server.

SO this is my cl_init.lua file:



include("shared.lua")

include("sh_player.lua")
include("modules/cl_hud.lua")


Im guessing this is how it gotta be then:
[LUA]
include(“shared.lua”)

include(“sh_player.lua”)
include(“modules/cl_hud.lua”)

AddCSLuaFile(“shared.lua”)
AddCSLuaFile(“sh_player.lua”)
AddCSLuaFile(“modules/cl_hud.lua”)
[/LUA]

Try moving AddCSLuaFile stuff above include.

Okay, ill try thanks! Never knew about this :stuck_out_tongue:

[editline]7th October 2014[/editline]

Still getting the error :confused:

[xAl3xTh3K1nG | TheGmodCoder|2|STEAM_0:0:71196251] Lua Error:
Couldn’t include file ‘shared.lua’ (File not found) (@gamemodes/seriousrp/gamemode/cl_init.lua (line 1))

[xAl3xTh3K1nG | TheGmodCoder|2|STEAM_0:0:71196251] Lua Error:
Couldn’t include file ‘sh_player.lua’ (File not found) (@gamemodes/seriousrp/gamemode/cl_init.lua (line 3))

[xAl3xTh3K1nG | TheGmodCoder|2|STEAM_0:0:71196251] Lua Error:
Couldn’t include file ‘modules\cl_hud.lua’ (File not found) (@gamemodes/seriousrp/gamemode/cl_init.lua (line 4))

[editline]7th October 2014[/editline]

Actually its only the cl_hud that wont be found now.

Add me on Steam, I’ll help you out if you like.

If you’re writing your own game-mode and want to completely forget about needing include / AddCSLuaFile every again, check out my dev base. Has a lot of dev stuff integrated, new hooks, metatable objects, helper-functions with a lot more on the way.

If you just want to fix your issue and move on… Robot has valid points. AddCSLuaFile should be ran on the SERVER before the client includes. Additionally, if you want to simplify your include system, I’d recommend setting up a 3 file system. Basically, init and cl_init should point to shared or sh_init, whichever you prefer in naming the third. Then put the includes in there because either way it’ll only need to be done once instead of shared files needing to be included on both.

Notes:
Always AddCSLuaFile first; then include.
Simplify where you can; try to limit code repetition and create helper functions whenever a pattern emerges.
Empty files will report an error of file not found. Simple add a // to the file. If you want to add Right-Click>New>Lua File to the list which creates a new Lua file WITH default data, Open the link at the bottom of this post… The one pertaining to Useful Programs ( SteamCMD, Autosizer, Desktops, Process Explorer ) and Notepad++ Upgrades

This will show how to use the 3 file system:
https://dl.dropboxusercontent.com/u/26074909/tutoring/loading_files_across_realms.lua.html

The best load-order is SHARED, then client/server, then gamemode “addons”, then content…
Feel free to use this ( 2nd or 3rd example; first repeats code, the others don’t… ): https://dl.dropboxusercontent.com/u/26074909/tutoring/loading_files_across_realms_simple.lua.html

To use it, depending on which one you use, and after you set up sh_init.lua to be the only file to include ( by setting cl_init.lua and init.lua to the code provided in the “3 file system” file )… Add the 2nd or 3rd code example with enumerations to the top of sh_init.lua

2nd ( NOTE: You can use if SERVER / if CLIENT then … end but with the IncludeFiles helper-function, it isn’t needed. 1 line per file, define the realm and it’ll handle the AddCSLuaFile and include for you.


//
// Include Shared first...
//
IncludeFiles( "gamemode_name/shared/", "sh_player.lua", REALM_SHARED );


//
// Next, Client / Server, doesn't matter
//
IncludeFiles( "gamemode_name/modules/", "cl_hud.lua", REALM_CLIENT );

3rd - Only difference is this uses the game-mode name as an argument so the file string doesn’t appear to be as long… It can be changed in the code to use this “( GM or GAMEMODE ).FolderName” instead of the argument which will shorten it even further…


local _gm = ( GM or GAMEMODE ).FolderName;
//
// Include Shared first...
//
IncludeFiles( _gm, "shared/", "sh_player.lua", REALM_SHARED );


//
// Next, Client / Server, doesn't matter
//
IncludeFiles( _gm, "modules/", "cl_hud.lua", REALM_CLIENT );

Hey, welcome to FacePunch.
I have written over 400 tutorials and completed “systems” in Lua for Garry’s Mod. I tutor and answer questions for free; feel free to add me on Steam if you need some guidance. This forum is for devs that need help working on things. Here are some resources to help you get started:

Generalized Lua Help ( Links to Wikis, Answers the question of “Where do I post a simple question or DarkRP Specific question”, links to other resources compiled by forum members )
https://dl.dropboxusercontent.com/u/26074909/tutoring/___welcome_docs/_welcome_general_lua_learning.lua.html

Useful Programs ( SteamCMD, Autosizer, Desktops, Process Explorer ) and Notepad++ Upgrades
https://dl.dropboxusercontent.com/u/26074909/tutoring/___welcome_docs/_welcome_useful_programs_and_notepadpp_upgrades.lua.html

AcecoolDev_Base Skeletonized Dev Base Game-Mode ( Never worry about Include or AddCSLuaFile ever again; comes with New Hooks, Console Commands, Meta-Table Objects, Helper Functions, Extended Functionality, and more! )
https://dl.dropboxusercontent.com/u/26074909/tutoring/___welcome_docs/_welcome_acecooldev_base_gamemode_info.lua.html

Thank you, ill add you on steam.