Hello, this baffels me, I have this script:
[CODE]local models = {
'astronauthelmet',
'cakehat',
'duncehat',
'gmod_tower',
'sam',
'santa',
'vikinghelmet',
'thresh'
}
local materials = {
'models/astronauthelmet',
'models/cakehat',
'models/duncehat',
'models/gmod_tower',
'models/sam',
'models/santa',
'models/vikinghelmet',
'models/thresh'
}
-- end
function resource.AddDir(dir)
local f, d = file.Find(dir .. '/*', 'GAME')
for k, v in pairs(f) do
resource.AddSingleFile(dir .. '/' .. v)
end
for k, v in pairs(d) do
resource.AddDir(dir .. '/' .. v)
end
end
for _, mf in pairs(models) do
resource.AddDir('models/' .. mf)
end
for _, mf in pairs(materials) do
resource.AddDir('materials/' .. mf)
end[/CODE]
it should download all of the above to garrysmod/models(garrysmod/download/models) and garrysmod/materials(garrysmod/download/materials), but it downloads all the files to garrysmod\download\addons\accessoriespack and even fails to download to garrysmod\download\addons\playermodels?
Here is the full addon(simply pointshop with a few modifications) as a zip: [url]http://speedy.sh/AEtZ7/pointshop.zip[/url]
I have tryed to keep everything in the pointshop content what relates to extra items to it - if you can't help me I would be so gradefull.
All of the items in both the "models" and "materials" tables you have created are missing file extensions.
mmm, it links all files in the materials/models and models in the folder from the addon where the above lua is places? or am I just dumb?
Sorry I didnt see the resource.AddDir, I thought it was resource.AddFile.
-SNIP-
I have been stuck and it should work, but it don't, if you can figure out what is wrong i'll gladly give you 10$ over paypal, I have been stuck with this so many hours now.
(I don't know if it is against the rules to post that you'll give a few bucks for a favor but i'll risk it in this case :P)
No solution for this?
[lua]resource.AddFile( "astronauthelmet.mdl"), -- Do this for all you materials, im not sure what your file extensions are so you may need to change it from .mdl--[/lua]
After creating all this put it inside a file called resource.lua and place it in [B]garrysmod/lua/autorun/server[/B] and restart your server.
what I was trying to avoid was that, so for each file under a location does not work anymore?
not that i am aware of, this appears to be the only method other than uploading them to the workshop.
The tricky thing is that is kind of works, it just downloads to wrong path.
it should download all of the above to garrysmod/models(garrysmod/download/models) and garrysmod/materials(garrysmod/download/materials), but it downloads all the files to garrysmod\download\addons\accessoriespack and even fails to download to garrysmod\download\addons\playermodels?
have you moved the files in question to the appropriate gmod path on your server? so fopr example the models are in the models folder?
nope, if you see zip they are located addon/lua/autorun/server/*lua
the materials and models in question is located at addon/models and addon/materials. they should be located here as to my understand.
[QUOTE=zassadgh2;45618172]nope, if you see zip they are located addon/lua/autorun/server/*lua
the materials and models in question is located at addon/models and addon/materials. they should be located here as to my understand.[/QUOTE]
It doesn't even matter....
[QUOTE=JasonMan34;45618197]It doesn't even matter....[/QUOTE]
Meaning what excatly? what am I doing wrong here?
[editline]7th August 2014[/editline]
Okay here is another for you.
[url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index5809.html[/url]
If I make an addon folder, adds the addon.txt empty, and adds a lua/autorun/server/download.lua
places this code inside:
function AddDir(dir) // Recursively adds everything in a directory to be downloaded by client
local list = file.FindDir("../"..dir.."/*")
for _, fdir in pairs(list) do
if fdir != ".svn" then // Don't spam people with useless .svn folders
AddDir(dir.."/"..fdir)
end
end
for k,v in pairs(file.Find(dir.."/*", true)) do
resource.AddFile(dir.."/"..v)
end
end
AddDir("models")
AddDir("materials")
and I have folders inside the addon named models and materials, then all the files inside the two folder should be downlaoded to client in garrysmod/download/models and garrysmod/download/materials right? or am I just plain dumb here?
why are you putting the code into an addon? Addons are only called when the client connects (sending client info) so they would not download the models. You need to place code in autorun/server.
yes, that is what I've done here: addon/MyThing/lua/autorun/server/download.lua
function AddDir(dir) // Recursively adds everything in a directory to be downloaded by client
local list = file.FindDir("../"..dir.."/*")
for _, fdir in pairs(list) do
if fdir != ".svn" then // Don't spam people with useless .svn folders
AddDir(dir.."/"..fdir)
end
end
for k,v in pairs(file.Find(dir.."/*", true)) do
resource.AddFile(dir.."/"..v)
end
end
AddDir("models") // take models from addon/MyThing/models and adds them to the client at garrysmod/download/models
AddDir("materials") // take materials from addon/MyThing/materials and adds them to the client at garrysmod/download/materials
This takes the files from the addons folder where lua is located, right? local list = file.FindDir("../"..dir.."/*") - so why does this not make people download the folder located in addon/MyThing/materials and addon/MyThing/materials
try placing the lua file directly into garrysmod/lua/autorun/server
[QUOTE=prop11;45618575]try placing the lua file directly into garrysmod/lua/autorun/server[/QUOTE]
It's the server that sets up the StringTable for the client to request files from the server. Even if it's placed in an addon, the server will still run it before a player joins.
any idea why it does not force people to download from the models and materials folder located in the addon folder?
Just to be clear, everything is located in the addon/MyThing folder, also the materials.
Is what I am trying to do not possible? I want the models and material folder to be under addon/MyThing and the lua aswell, so here is simple path overview:
garrymod/addon/MyThing/lua/autorun/server/download.lua - make this lua link from below folders.
garrymod/addon/MyThing/models - what some files and folders
garrymod/addon/MyThing/material - what some files and folders
[code]
function resource.AddDir(dir)
local f, d = file.Find(dir .. '/*', 'GAME')
for k, v in pairs(f) do
resource.AddSingleFile(dir .. '/' .. v)
end
for k, v in pairs(d) do
resource.AddDir(dir .. '/' .. v)
end
end
for _, mf in pairs(models) do
resource.AddDir('models/' .. mf)
end
for _, mf in pairs(materials) do
resource.AddDir('materials/' .. mf)
end
[/code]
Seen as you are putting the materials and models in an addon, 'game' parameter will not search there. Instead of searching in [I]garrysmod/addons/myaddon/[/I], you are searching in [i]garrysmod/[/i]. Small change should do the trick:
[code]
for _, mf in pairs(models) do
resource.AddDir('addons/myaddon/models/' .. mf)
end
for _, mf in pairs(materials) do
resource.AddDir('addons/myaddon/materials/' .. mf)
end
[/code]
Hope this helps.
Thank you, it downloads this location to the client:
garrysmod\download\addons\pointshop\* models and materials folder
can't I get them to sent them to client in garrysmod\download\*models and materials folder?
code is the following:
[CODE]local models = {
'astronauthelmet',
'cakehat',
'duncehat',
'gmod_tower',
'sam',
'santa',
'vikinghelmet',
'thresh'
}
local materials = {
'models/astronauthelmet',
'models/cakehat',
'models/duncehat',
'models/gmod_tower',
'models/sam',
'models/santa',
'models/vikinghelmet',
'models/thresh'
}
-- end
function resource.AddDir(dir)
local f, d = file.Find(dir .. '/*', 'GAME')
for k, v in pairs(f) do
resource.AddSingleFile(dir .. '/' .. v)
end
for k, v in pairs(d) do
resource.AddDir(dir .. '/' .. v)
end
end
for _, mf in pairs(models) do
resource.AddDir('addons/pointshop/models/' .. mf)
end
for _, mf in pairs(materials) do
resource.AddDir('addons/pointshop/materials/' .. mf)
end[/CODE]
All models/materials/etc will be downloaded into [i]garrysmod/download/*[/i]. A client will never download something where it will be automatically executed when next running Garry's Mod.
Have you tested the code? That behaviour which you have mentioned should not occur.
[QUOTE=dingusnin;45622672]All models/materials/etc will be downloaded into [i]garrysmod/download/*[/i]. A client will never download something where it will be automatically executed when next running Garry's Mod.
Have you tested the code? That behaviour which you have mentioned should not occur.[/QUOTE]
If you have gmod, here is the server IP: 185.38.148.28:27145
Here is the full addon (pointshop with some modifications) uploaded in a zip:
[url]http://www.speedyshare.com/NmDUB/pointshop.zip[/url]
The files you can look at are in pointshop/models and pointshop/materials and pointshop/lua/autorun/server
it downloads to garrysmod\download\addons\pointshop\* models and materials folder
And as said previously I want them to client in garrysmod\download\*models and materials folder.
Nothing you can do to change that unless you put the materials and models in their respective directories branching from [i]garrysmod/[/i].
Why do you need them to download there anyway? What is so important?
I really don't like them being in the respective directories because it gets messy.
What more concers me is why this does not work...
[QUOTE=zassadgh2;45623965]I really don't like them being in the respective directories because it gets messy.
What more concers me is why this does not work...[/QUOTE]
I don't see how this is messy, it's actually the cleanest and simplest solution. The fact is it is working, just not the way you want it. I have told you how to do it the way you want it to work.
Sorry, you need to Log In to post a reply to this thread.