AddResourceConfig: Difference between revisions
		
		
		
		
		
		Jump to navigation
		Jump to search
		
				
		
 
		
	
mNo edit summary  | 
				KennyKiller (talk | contribs)   | 
				||
| Line 22: | Line 22: | ||
==Example==  | ==Example==  | ||
<section name="Server Example" class="server" show="true"><syntaxhighlight lang="lua">  | |||
function onStart()  | |||
   addResourceConfig(":ctf/settings.xml", "server")  | |||
end  | |||
addEventHandler("onResourceStart",getResourceRootElement(getThisResource()),onStart)  | |||
</syntaxhighlight></section>   | |||
<section name="Client Example" class="client" show="true"><syntaxhighlight lang="lua">  | |||
function onStart()  | |||
   addResourceConfig(":ctf/settings.xml", "client")  | |||
end  | |||
addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),onStart)  | |||
</syntaxhighlight></section>  | |||
==See Also==  | ==See Also==  | ||
{{Resource_functions}}  | {{Resource_functions}}  | ||
Revision as of 08:10, 31 January 2012
| Script Example Missing Function AddResourceConfig needs a script example, help out by writing one. | |
Before submitting check out Editing Guidelines Script Examples.  | 
This function adds a new empty config file to an existing resource.
Syntax
xmlnode addResourceConfig ( string filePath, [ string filetype = "server" ] )
Required Arguments
- filePath: The filepath of the file to be created in the following format: ":resourceName/path". 'resourceName' is the name of the resource the file is in, and 'path' is the path from the root directory of the resource to the file.
 
- For example, if you want to create a config named 'settings.xml' in the resource 'ctf', it can be created from another resource this way: addResourceConfig(":ctf/settings.xml", "server").
 - If you want to create the file in the current resource, only the file path is necessary, e.g. addResourceConfig("settings.xml", "server").
 
Optional Arguments
NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use. For more information on optional arguments, see optional arguments.
- filetype: a string indicating whether the file is serverside ("server") or clientside ("client").
 
Returns
Returns the new config's root xmlnode if the config was added successfully, false otherwise.
Example
Click to collapse [-]
Server Examplefunction onStart()
   addResourceConfig(":ctf/settings.xml", "server")
end
addEventHandler("onResourceStart",getResourceRootElement(getThisResource()),onStart)
Click to collapse [-]
Client Examplefunction onStart()
   addResourceConfig(":ctf/settings.xml", "client")
end
addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),onStart)
See Also
- abortRemoteRequest
 - call
 - fetchRemote
 - getResourceConfig
 - getResourceDynamicElementRoot
 - getResourceExportedFunctions
 - getResourceFromName
 - getResourceName
 - getResourceRootElement
 - getResourceState
 - getThisResource
 - getRemoteRequests
 - getRemoteRequestInfo