resource.AddFile() quick help please

im new to LUA scripting (obviously) but ive used other scripting languages before.
im trying to add some custom models to the download list, without using fastDL.

this is the mod im using http://www.garrysmod.org/downloads/?a=view&id=76603
everything works except the models, and maybe sounds (i didnt have my headphones in).

i could just add the folder to my client addons folder, but i want people to have to download em to join my server.

this is what i have so far.


run()

end


function run()
	resource.AddFile("models\lambo\lambo.mdl")
	resource.AddFile("addons\rp_vehicles\models\mini\mini.mdl")

end


when i run my server, it says LUA initialized. so theres no errors running the script. but when i log into my server, it wont download any new files. and the cars still dont have models

i would appreciate any ideas or solutions. thanks

You’re probably just looking for

[lua]
resource.AddFile(“models\lambo\lambo.mdl”)
resource.AddFile(“addons\rp_vehicles\models\mini\mini.mdl”)
[/lua]

etc, the code is ran when the file is loaded, you don’t have to put it in any functions.

ok i changed it to


resource.AddFile("models\lambo\lambo.mdl")
resource.AddFile("addons\rp_vehicles\models\mini\mini.mdl")

and it initializes, but nothing downloads still…

also, i have the .lua in garrysmod\lua\autorun\server

its called downloads.lua

that will work right?

No need for the end

k i fixed that, but it still wont download.

i have it in the \garrysmod\lua\autorun\server folder. its called downloads.lua

file names dont matter right? and its in the correct folder?

Have you already got the addon installed on your client? If you have it isn’t going to download as you already have the content. Also bare in mind you haven’t added enough content for any vehicle to work properly on the client.

There is no need for the “addons/” part in the second file. It should be:
[lua]resource.AddFile(“models\lambo\lambo.mdl”)
resource.AddFile(“models\mini\mini.mdl”)[/lua]

(I think, maybe I’m wrong.)

i did not install it to my client, however i can drive the ERROR signs around with perfect physics and even the headlights turn on and off…

and what other files would i need besides the model?

i just searched my steam nick folder for lambo.mdl and mini.mdl. no results. so im sure nothing has downloaded.

nd i think ur right about the /addons/rp_vehicles part of the file path. but i was just trying both to make sure that wasnt the mistake i was making

also, thanks for ur help, and ur time.

In your first post you say you don’t want to use FastDL, is your server configured to use FastDL for anything else?

i havent done really anything to my server aside from adding entitys, addons, and setting the server.cfg

so i dont think i set fastDL to any certain mode. it should still be in the default mode… but i dont need fastDL for resource.AddFile(). do i?

i know its obviously better, and i plan on setting it up eventually. but if its only a few car models for now, i dont think people will mind the wait



resource.AddFile("models/lambo/lambo.mdl")
resource.AddFile("models/mini/mini.mdl")


Forward slashes, not backward slashes. Also Call all the files as if they were in the normal areas of the gamemode (ie, the first garrysmod folder is root. so you start off with models / materials/ sound whatever.
Hope this helps.

–edit
also, you don’t need FastDL for this code. resource.AddFIle simply tells the server to send certain files to the clients when they join the server. FastDL just makes that job a bit faster and more efficient.