Auto Sender -Lua file that sends all the files thats in an folder

<-> What is it ? <->
I was thinking about an script that will send the files that are in an folder like you make an folder called :

Send

and then …

an lua file That sends everything thats in that folder

<-> But isnt that just AddDir ?, <->

[li]Well on AddDir ( “directory” ) if you put all the files in 1 folder and use it with AddDir like this
[/li]
AddDir ( “addons/lua/maphere” )

[li]it will crash Like gmod wiki says “dont send big files it may will crash”
[/li]
<-Or something in that direction i know sure it will crash cause i tryd it with 20 folders in 1 map and then did AddDir > etc > etc

<-> Why not just use the normal AddDir ( “models/etc” )? <->

[li]Well its faster !
[/li][li]It is easy to use
[/li]
<->

[*]So just an lua file that sends every file in a folder and can handle lot of files :slight_smile: :smiley:

Just to put it out there, you can do AddCSLuaFile(“nameoffile.lua”)
And it will make anyone who comes to server download it. I know it’s not what your looking for, but if all else fails just put this in the file.

lol no

i got thousend files on my server but i dont want them all to send :stuck_out_tongue: ! another problem

Here it is:

[lua]
function AddCSLuaFolder(folder)
local files = file.Find(folder … “/*.lua”)
if files then --if there are files in the folder
for _, luafile in pairs(files) do --go through all the files in the folder
AddCSLuaFile(folder … luafile) --Send all the files
end
end
Msg("No files found in " … folder … "
") --if the folder was empty or it didn’t exists
end
[/lua]

Awsome man ! So i make a folder and put that in it And then it will send the files that 'r in that folder?

No, you just specify the folder’s path (IE: “lua/stuff”)

REMEMBER: all file operations begin in garrysmod/data directory, so if you want to send lua files you’ll have to add “…/” to your path (IE: AddCSLuaFolder("…/gamemodes/shit/clstuff")

thank you so much :slight_smile:

so i have to set the map

function AddCSLuaFolder(folder)
local files = file.Find(folder … "/*.lua < HERE > ")
if files then --if there are files in the folder
for _, luafile in pairs(files) do --go through all the files in the folder
AddCSLuaFile(folder … luafile) --Send all the files
end
end
Msg("No files found in " … folder … "
") --if the folder was empty or it didn’t exists
end

?

yes, but remove the < HERE >, then you’ll just add
[lua]AddCSLuaFolder("…/gamemodes/gmname/mystuff")[/lua]

thats freaking awsome dude Thanks :D!