AddResourceMap: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
 
(11 intermediate revisions by 9 users not shown)
Line 1: Line 1:
{{Server function}}
{{Server function}}
__NOTOC__
__NOTOC__
This function retrieves a table of all the resources that exist on the server.
This function adds a new empty mapfile to an existing resource.
{{Note| You can't add a map to a running resource.}}


==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
xmlnode addResourceMap ( resource theResource, string name, [ dimension = 0 ] )
xmlnode addResourceMap ( string filePath, [ int dimension = 0 ] )
</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 resource map in the following format: '''":resourceName/path"'''. 'resourceName' is the name of the resource the map file will be 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 map file named 'manycars.map' in the resource 'cdm', it can be created from another resource this way: ''addResourceMap(":cdm/manycars.map")''.
:If you want to create the map file in the current resource, only the file path is necessary, e.g. ''addResourceMap("manycars.map")''.


<!-- Only include this section below if there are optional arguments -->
===Optional Arguments===  
===Optional Arguments===  
{{OptionalArg}}  
{{OptionalArg}}  
*'''argumentName2:''' description
*'''dimension:''' the [[dimension]] in which the map's objects will be placed.
*'''argumentName3:''' description


===Returns===
===Returns===
Returns a table of resources.
Returns the new map's root [[xmlnode]] if the map was added successfully, ''false'' otherwise.


==Example==
==Example==
This function lists all loaded resources in the console.
This example just adds a map to a gamemode resource called "cdm".
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">addResourceMap(":cdm/[maps]/New.map",0)</syntaxhighlight>
function blabla ()
    --this does blabla
end
</syntaxhighlight>
 
==See Also==
==See Also==
{{Resource_functions}}
{{Resource_functions|server}}

Latest revision as of 22:45, 6 September 2024

This function adds a new empty mapfile to an existing resource.

[[{{{image}}}|link=|]] Note: You can't add a map to a running resource.

Syntax

xmlnode addResourceMap ( string filePath, [ int dimension = 0 ] )

Required Arguments

  • filePath: The filepath of the resource map in the following format: ":resourceName/path". 'resourceName' is the name of the resource the map file will be in, and 'path' is the path from the root directory of the resource to the file.
For example, if you want to create a map file named 'manycars.map' in the resource 'cdm', it can be created from another resource this way: addResourceMap(":cdm/manycars.map").
If you want to create the map file in the current resource, only the file path is necessary, e.g. addResourceMap("manycars.map").

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.

  • dimension: the dimension in which the map's objects will be placed.

Returns

Returns the new map's root xmlnode if the map was added successfully, false otherwise.

Example

This example just adds a map to a gamemode resource called "cdm".

addResourceMap(":cdm/[maps]/New.map",0)

See Also