Garry's Mod Wiki

Revision Difference

Global.AddCSLuaFile#518377

<function name="AddCSLuaFile" parent="Global" type="libraryfunc"> <description> Marks a Lua file to be sent to clients when they join the server. Doesn't do anything on the client - this means you can use it in a shared file without problems. <warning>If the file trying to be added is empty, an error will occur, and the file will not be sent to the client.</warning> <note>This function is not needed for scripts located in **lua/autorun/** and **lua/autorun/client/**: they are automatically sent to clients.</note> <note>You can add up to 8192 files.</note> </description> <realm>Shared</realm> <args> <arg name="file" type="string" default="current file">The name/path to the Lua file that should be sent, relative to the garrysmod/lua folder. If no parameter is specified, it sends the current file.&#xA;&#xA;The file path can be relative to the script it is ran from. For example, if your script is in lua/myfolder/stuff.lua, calling &lt;page&gt;Global.AddCSLuaFile&lt;/page&gt;(&quot;otherstuff.lua&quot;) and &lt;page&gt;Global.AddCSLuaFile&lt;/page&gt;(&quot;myfolder/otherstuff.lua&quot;) is the same thing.</arg>⤶ <arg name="file" type="string" default="current file">The name/path to the Lua file that should be sent, relative to the garrysmod/lua folder. If no parameter is specified, it sends the current file.⤶ The file path can be relative to the script it is ran from. For example, if your script is in lua/myfolder/stuff.lua, calling <page>Global.AddCSLuaFile</page>("otherstuff.lua") and <page>Global.AddCSLuaFile</page>("myfolder/otherstuff.lua") is the same thing.</arg>⤶ </args> </function> <example> <description>Adds the cl_init.lua file in the "lua" folder to be downloaded by connecting clients. This is required, and is normally done in init.lua.</description> <code>AddCSLuaFile( "cl_init.lua" )</code> </example> <example> <description>Adds the current file to the list of files to be downloaded by clients. This is usually done at the top of a shared file.</description> <code>AddCSLuaFile()</code> </example>