resource.AddFile

From GMod Wiki

Revision as of 08:38, 17 November 2011 by Di-0xide :: K0m[pwn]3nt Killa (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
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: NewerServer.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=Resource.AddFile]Resource.AddFile [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]



Examples

DescriptionSend the counter strike font to all the clients that decide to play on the server.
Used onNewerServer.png
Code
 
resource.AddFile( "resource/fonts/csd.ttf" )
 
OutputN/A


DescriptionSends models, and materials for the Sourceforts model pack.
Used onNewerServer.png
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")
OutputN/A


DescriptionAdds directories and all the files inside recursively.
Used onNewerServer.png
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")
OutputN/A


Additional Notes

See Also

resource.AddSingleFile

Generating A Resources File for a SWEP or SENT (Linux)

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox