Files won't include

So I have the following code:



//Include them all
util.IncludeFolder( "jobs" )
util.AddCSLuaFiles( "jobs" )


Which is supposed to include everything in a folder and also send it to the client:



function util.IncludeFolder( path )

	for k, v in pairs( file.Find( "../"..GM.Folder.."/gamemode/"..path.."/*.lua" ) ) do
		include( path.."/"..v )
	end
	
end

function util.AddCSLuaFiles( path )
	
	if ( CLIENT ) then return end
	for k, v in pairs( file.Find( "../"..GM.Folder.."/gamemode/"..path.."/*.lua" ) ) do
		AddCSLuaFile( path.."/"..v )
	end
	
end


Now, this works on the server in multiplayer but the client fails to include the files. The files are being sent as including them separately like so works:



include( "jobs/superman.lua" ) // etc 

So my question is, why does my function, util.IncludeFolder, not work on the client? I assume it’s something up with the file.Find part, but I see no reason why it should do that.

If the client downloads them from the server, they are not in those folders. They are in, I believe, “lua_temp/”…GM.Folder… …

The normal include works because it’s starting directory is the current one where the file including is.

Thanks alot BigA



function util.IncludeFolder( path )

	local searchpath
	
	if ( CLIENT ) then
		searchpath = "../lua_temp/roleplay/gamemode/"..path.."/*.lua"
	else
		searchpath = "../gamemodes/roleplay/gamemode/"..path.."/*.lua" 
	end

	for k, v in pairs( file.Find( searchpath ) ) do
		include( path.."/"..v )
	end
	
end


This works now. Shame that I can’t use GM.Folder because on the client the path is lua_temp/roleplay instead of lua_temp/gamemodes/roleplay. Ah well, least it works. Thanks.

Well actually I could remove the ‘gamemodes’ part on the client.

They actually start at lua/gamemodename/gamemode/foldername, I believe.

OP, you should be using the function file.FindInLua to do this.

That’s what file.FindInLua is for.
_Muffin, just change the code from file.Find("…/lua/"…the_file_to_search) to file.FindInLua(the_file_to_search).

Does work on client with files sent by the server.