From GMod Wiki
Function |
Syntax |
resource.AddFile( String filename ) Where is this used? |
Description: |
Adds a file (and all related files) to the download list for clients. |
Returns: |
nil |
Part of Library: |
resource |
Realm: |
|
BBCode Link: |
[b][url=http://wiki.garrysmod.com/?title=Resource.AddFile]Resource.AddFile [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] |
Examples
Description | Send the counter strike font to all the clients that decide to play on the server. |
Used on | |
Code |
resource.AddFile( "resource/fonts/csd.ttf" )
|
Output | N/A |
Description | Sends models, and materials for the Sourceforts model pack. |
Used on | |
Code |
//This requires the "Sourceforts Model Pack"
//Models for the 3d 1*2 block
resource.AddFile("models/sf/block_3d_1x2.mdl")
//SourceForts Materials
resource.AddFile("materials/models/sf_block_black.vmt")
resource.AddFile("materials/models/SF_Block_Blue.vmt")
resource.AddFile("materials/models/SF_Block_Blue_lod1.vmt")
resource.AddFile("materials/models/sf_block_gib_crosssection.vmt")
resource.AddFile("materials/models/sf_block_metal.vmt")
resource.AddFile("materials/models/sf_block_metal_lod1.vmt")
resource.AddFile("materials/models/sf_block_red.vmt")
resource.AddFile("materials/models/sf_block_red_lod1.vmt") |
Output | N/A |
Description | Adds directories and all the files inside recursively. |
Used on | |
Code |
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/yourmodels") |
Output | N/A |
Additional Notes
- garrysmod/ is the root folder.
- The capitalization of the path must match the actual path.
- For convenience, this function will automatically add any other files that are related to the selected one, and throw an error if it can't find them. For example, a .vmt file will automatically add the .vtf with the same name, and a .mdl file will automatically add all .vvd, .ani, .dx80.vtx, .dx90.vtx, .sw.vtx, .phy and .jpg files with the same name, with a separate error for each missing file. If you do not want it to do this, use resource.AddSingleFile.
See Also
resource.AddSingleFile
Generating A Resources File for a SWEP or SENT (Linux)