Need Halp: Download a model on server to all clients...

I am an admin on a friend’s build server and wanted to have the owner to put a model of my choice on for all clients to download so that I could use it and everyone who joined could see me instead of invisible or error. The owner of the server is both lazy and doesn’t really know how to do this. I already asked how to do this on WireMod.com but was told to ask someone who “knew what they were doing” (which is why i was there) then came here…

I am VERY unclear about recource.addfile and all that jazz. So all I want is a variant of .zip for the model that i have linked below or something, so that i just have to send it to the owner so that he can put it on the server and everything will be fine…

If you need any more info please reply here and I will get back to you really soon.
the model is downloadable in the form I want to keep it here: http://www.mediafire.com/?a9sc623tcvncy35

(i have been at this for a long time now and its only for 1 model wtf)

As far as I know, you have to add ’ resource.addfile (directory) ’ in a file that auto-runs as soon as the server starts, otherwise things like custom sounds or custom models won’t work

Open up the me2_players.lua located in ME2Models/lua/autorun and add this below the current code:


function resource.AddDir(dir)
	for k,v in pairs(file.Find("../"..dir.."/*")) do
		if !file.IsDir( "../"..dir.."/"..v ) then
			resource.AddSingleFile( dir.."/"..v)
		end
	end
end

resource.AddDir ("materials/models/slash/garrus")
resource.AddDir ("models/slash/garrus")

No, that code is buggy and found not always working.
Use this instead:
http://www.wiremod.com/forum/off-topic/18560-fox-warriors-resources-generator.html

so i just edit me2_players.lua then send it to him, or does the owner have to have the program?

EDIT: i have tried this program out and i think i got the me2_players.lua file to work, now i just need to send him the me2models folder, where should he put it?

No listen. If you have the addon locally, you select that folder using the program. It makes a file saying if (SERVER) then
<loads of lines>
end
Remove the “if (SERVER) then” and “end” and then add those lines to a file in garrysmod/lua/autorun/server/<anyfilenameyouwant>.lua.
So you can name it “forcedownloads.lua” or “idontknowwhatnametopick.lua”. then, make sure it’s on the server, clientsided it won’t do a thing.

I’ve never had any problems with that code so far. Have you experienced any lately?

Excl aka Newbee_ told me not to use it, he told me he wrote that code and put it up the wiki but it was found not working by some others. Why not use something that is 100% reliable over something that even takes more work because you still need to add all the directories?

so the forcedownloads.lua itself has to have “if (SERVER) then” at the top and “end” at the bottom like a regular lua has?
so you are saying just to add all the files to a full .lua

Yes, add all the files you want to be downloaded to a single file, not one per download. That’s easier if you need to modify it, just update the list. But the if (SERVER) then isn’t allowed if you put it in lua/autorun/server, because that will only run if you’re on the server.

ok just to be sure: I send the ME2models folder to the owner to put in the Addons folder then give him the editied ME2_Players.lua to put in “garrysmod/lua/autorun/server”. is that right?

Yes, but only if the ME2_Players.lua file contains lines like:
File.AddResource(“models/path/to/model.mdl”)

you mean recource.addfile?

Yes, sorry.

k im good now thank you

ok i finally got the contact to the owner that was on vacation and had him upload it and everything. but when i try the model out only %50 of the people on the server can see it, the rest wonder why a flying ERROR or physgun is just flying around. -_- i did everything right so what’s up? do the models and materials have to be in separate folders in the addons folder or can the single ME2Modles folder sit in addons?

…?

come on, this can’t take more than a week to get one model onto a server with recource.addfile

No offence, but I explained you pretty well how it works. If you don’t know how to add a simple addon to GMod, don’t try to run it on a server.

i know, it’s just that i did it the way it was explained and it doesn’t really work