Adding Resources(1000)

Okay guys, I recently discovered that having 1000 lines of code fucks up your gamemodes init and doesn’t let the gamemodes cl_init.lua work. How do I add my resources to another file and make them download when people join?

Ive tried putting inside lua/autorun/server/resources.lua and then adding AddCSluaFile(“lua/autorun/serrver/resources.lua”) or whatever the AddCSthing is called.

The point is … What’s the easiest way to do this?

You shouldn’t need 1000 lines of adding resources anyways. For loop through the folder/folders you’re adding resources from.

Code and what to do with it?
If I put in init it doesnt work anymore.

1000 lines of code fucks up your init? Uhh, sorry, but I don’t think that’s your problem.

http://dl.dropbox.com/u/8416055/Okay.png

I have a feeling you have no idea what you’re doing, and are just doing a trivial error. Such as, for example, not even knowing what the AddCSLuaFile function is, or how it works.

So what is this “trivial error”?

http://pastebin.com/6u5tTJXH My init.lua for darkRP

pfffttt nah i parse my food all the time

Okay, well, first of all, you have way more redundancy than you need in your resource.AddFile’s. Throw these at the top of the script, and use these instead.

[lua]function resource.AddFolder(folder)
for k,v in pairs(file.Find("…/"…folder)) do
resource.AddFile(folder…v)
end
end

function resource.AddWildcard(folder,card)
for k,v in pairs(file.Find("…/"…folder)) do
if string.find(v,card) then
resource.AddFile(folder…v)
end
end
end[/lua]

You use them like so:

To add every single file in, for example, the models/humans/mafia/ directory:

[lua].Resource.AddFolder(“models/humans/mafia/”)[/lua]

To add only the MDLs in that folder (don’t; include everything):

[lua]resource.AddWildcard(“models/humans/mafia/”,".mdl")[/lua]

Will shorten that code up a lot.

Secondly, throw a print in at the very top of both your init and cl_init’s.

In init.lua, add this:
[lua]print(“init.lua initialized”)[/lua]

And in cl_init, add this:
[lua]print(“cl_init.lua initialized”)[/lua]

Then fire up Garry’s Mod, type “clear” into the console, load your game up on any particular map, and copy-paste the entire console into a pastebin and post it here. We’ll see if it’s an issue of the cl_init not loading at all, or something else.

This is my resource list with your code:

http://pastebin.com/ALu8TMbp

This is my console:

http://pastebin.com/UTaPLv8b

[editline]8th December 2011[/editline]

Hold that thought.

[editline]8th December 2011[/editline]

This is the CORRECT resource:
http://pastebin.com/X301BBCe

This is the correct console:
http://pastebin.com/JyMSsxxw

Well, this may be an issue:


Couldn't include file 'DarkRP\gamemode\cl_init.lua' (File not found) (<nowhere>)

Yeah I noticed… How could I fix it?

Are you doing this on singleplayer or on a dedicated server?

Server hosted by xenon.
I have a AddCSLuaFile(“cl_init.lua”)

Now this isn’t loading…

Redownloading all lightmaps
Unknown command: _sendDarkRPvars
Go to www.truegamers.ca to donate.
Unknown command: _sendDarkRPvars
Unknown command: _sendDarkRPvars

Scratch that… How do I add another file for ALL OF MY RESOURCES and have everyone download them when i join my server.

I tried putting resources.lua inside lua/autorun/server/ and adding AddCSLuaFile(“lua/autorun/server/resources.lua”) to my init.lua for DarkRP and I didn’t download the files when I joined.

Scratch that… How do I add another file for ALL OF MY RESOURCES and have everyone download them when i join my server.

I tried putting resources.lua inside lua/autorun/server/ and adding AddCSLuaFile(“lua/autorun/server/resources.lua”) to my init.lua for DarkRP and I didn’t download the files when I joined.

-Bump still not solved-

You don’t need to AddCSLuaFile serverside files since you’re not sending them to the client (I hope not). Just include the file in init.lua somewhere near the top.