Global/AddCSLuaFile

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
(shared function note.)
(various changes)
Line 1: Line 1:
 
{{Func
 
{{Func
|Description=Marks a Lua file to be sent to clients when they join the server.
+
|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.
{{Note|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 {{GlobalFunction|AddCSLuaFile}}("otherstuff.lua") and {{GlobalFunction|AddCSLuaFile}}("myfolder/otherstuff.lua") is the same thing.}}
+
 
{{Note|If the file that is pointed to by the 'file' argument is empty, the function will return an error, and the marked file will not be sent to the client.}}
+
{{Warning|If the file trying to be added is empty, an error will occur, and the file will not be sent to the client.}}
{{Note|This is a shared function but it doesn't do anything on the client.}}
+
 
|Realm=Shared
 
|Realm=Shared
 
|IsClass=No
 
|IsClass=No
Line 12: Line 11:
 
|type=string
 
|type=string
 
|name=file
 
|name=file
|desc=The name/path (relative to the garrysmod/lua folder) to the Lua file that should be sent. If no parameter is specified, it sends the current file.
+
|desc=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 {{GlobalFunction|AddCSLuaFile}}("otherstuff.lua") and {{GlobalFunction|AddCSLuaFile}}("myfolder/otherstuff.lua") is the same thing.
 
|default=current file
 
|default=current file
 
}}
 
}}
 
{{Example
 
{{Example
|Description=Adds the cl_init.lua file in the "lua" folder to be downloaded by connecting clients.
+
|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.
 
|Code=AddCSLuaFile( "cl_init.lua" )
 
|Code=AddCSLuaFile( "cl_init.lua" )
 
}}
 
}}
 
{{Example
 
{{Example
|Description=Adds the current file to the list of files to be downloaded by clients.
+
|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.
 
|Code=AddCSLuaFile()
 
|Code=AddCSLuaFile()
 
}}
 
}}

Revision as of 21:04, 26 August 2016

 AddCSLuaFile( )

Contents

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.

Arguments

string file=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 AddCSLuaFile("otherstuff.lua") and AddCSLuaFile("myfolder/otherstuff.lua") is the same thing.

Examples

Example

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.

AddCSLuaFile( "cl_init.lua" )


Examples

Example

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.

AddCSLuaFile()


Personal tools
Navigation