AddResourceConfig: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(New page: {{Server function}} __NOTOC__ tba ==Syntax== <syntaxhighlight lang="lua"> xmlnode addResourceConfig ( resource, name, type = "server" ) </syntaxhighlight> ===Required Arguments=== <!-- List each argument one p...)
 
 
(9 intermediate revisions by 6 users not shown)
Line 1: Line 1:
{{Server function}}
{{Server function}}
__NOTOC__
__NOTOC__
tba
This function adds a new empty config file to an existing resource.


==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
xmlnode addResourceConfig ( resource, name, type = "server" )
xmlnode addResourceConfig ( string filePath, [ string filetype = "server" ] )
</syntaxhighlight>  
</syntaxhighlight>  


===Required Arguments===  
===Required Arguments===  
<!-- List each argument one per line. This should be the argument's name as in the argument list above, NOT the argument's data type -->
*'''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.
*'''argumentName:''' description
: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")''.


<!-- Only include this section below if there are optional arguments -->
===Optional Arguments===  
===Optional Arguments===  
{{OptionalArg}}  
{{OptionalArg}}  
*'''argumentName2:''' description
*'''filetype:''' a string indicating whether the file is serverside ("server") or clientside ("client").
*'''argumentName3:''' description


===Returns===
===Returns===
tba
Returns the new config's root [[xmlnode]] if the config was added successfully, ''false'' otherwise.


==Example==
==Example==
This function lists all loaded resources in the console.
 
<syntaxhighlight lang="lua">
<section name="Server Example" class="server" show="true"><syntaxhighlight lang="lua">
function blabla ()
function onStart()
    --this does blabla
  addResourceConfig(":ctf/settings.xml", "server")
end
end
</syntaxhighlight>
addEventHandler("onResourceStart",getResourceRootElement(),onStart)
</syntaxhighlight></section>


==See Also==
==See Also==
{{Resource_functions}}
{{Resource_functions}}

Latest revision as of 16:42, 11 February 2015

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 Example
function onStart()
   addResourceConfig(":ctf/settings.xml", "server")
end
addEventHandler("onResourceStart",getResourceRootElement(),onStart)

See Also

Shared