Meta.xml: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
(23 intermediate revisions by 14 users not shown)
Line 10: Line 10:
** '''description:''' A brief description of this resource
** '''description:''' A brief description of this resource
** '''type:''' The type of this resource, that can be "gamemode", "script", "map" or "misc".
** '''type:''' The type of this resource, that can be "gamemode", "script", "map" or "misc".
** '''gamemodes:''' The gamemodes to be compatible with the resource. It must be the name of the gamemode resource, not the gamemode name. If you want it to be compatible with multiple gamemodes, it must be in a comma-separated list without spaces. (e.g. gamemodes="test1,test2").
*'''<script />''' Source code for this resource, possible parameters are:
*'''<script />''' Source code for this resource, possible parameters are:
** '''src:''' The file name of the source code
** '''src:''' The file name of the source code
** '''type:''' The type of source code: "client", "server" or "shared".
** '''type:''' The type of source code: "client", "server" or "shared".
*** A '''shared''' script will be ran for both client and server, but separately as usual (basically adds the script twice: once for server and once for client)
**'''cache:''' When the script file type is "client", this setting controls whether the file is saved on the clients' hard drive. Default is "true". Using "false" will mean the file is not saved. ''(Note: cache=false files are started at the client first, so lua file load order might differ when mixing cache settings)''
**'''cache:''' When the script file type is "client", this setting controls whether the file is saved on the clients' hard drive. Default is "true". Using "false" will mean the file is not saved. ''(Note: cache=false files are started at the client first, so lua file load order might differ when mixing cache settings)''
**'''validate:''' If set to "false", compatibility checks are skipped.
**'''validate:''' If set to "false", compatibility checks are skipped.
Line 20: Line 22:
*'''<file />''' A client-side file. Generally these are images, .txd, .col, .dff or .xml files. They'll be downloaded by clients when the resources is started (or on join)
*'''<file />''' A client-side file. Generally these are images, .txd, .col, .dff or .xml files. They'll be downloaded by clients when the resources is started (or on join)
**'''src:''' client-side file name (can be path too eg. "images/image.png")
**'''src:''' client-side file name (can be path too eg. "images/image.png")
**'''download:''' Whether or not to be sent to the client automatically (optional). Default is "true". Using "false" will mean they are not sent on resource start but could later be used by [[downloadFile]] (from version 1.4)
**'''download:''' Whether or not to be sent to the client automatically (optional). Default is "true". Using "false" will mean they are not sent on resource start but could later be used by [[downloadFile]].
*'''<include />''' Include resources that this resource will use
*'''<include />''' Include resources that this resource will use
**'''resource:''' Resource name that you want to start with this resource
**'''resource:''' Resource name that you want to start with this resource
Line 31: Line 33:
**'''function:''' The function name
**'''function:''' The function name
**'''type''' Whether function is exported server-side or client-side (valid values are: "client", "server" and "shared")
**'''type''' Whether function is exported server-side or client-side (valid values are: "client", "server" and "shared")
*** A '''shared''' export will make the function callable from both client and server scripts (basically adds the export twice: once for server and once for client)
**'''http:''' Can the function be called via HTTP (true/false)
**'''http:''' Can the function be called via HTTP (true/false)
*'''<html />'''
*'''<html />'''
Line 36: Line 39:
**'''default:''' The html file is one that is shown by default when visiting /resourceName/ on the server. Only one html can be default, the rest are ignored. (true/false)
**'''default:''' The html file is one that is shown by default when visiting /resourceName/ on the server. Only one html can be default, the rest are ignored. (true/false)
**'''raw:''' The html file is not parsed by the Lua interpreter and is treated as binary data. Must be used for binary files (images mainly) (true/false)
**'''raw:''' The html file is not parsed by the Lua interpreter and is treated as binary data. Must be used for binary files (images mainly) (true/false)
*'''<settings> <setting name="" value=""/> </settings>:''' Most gamemodes use [[settings system]] to let server admins to configure it how they like. For instance you could set round time and then use [[get]] and [[set]] to get the value or change it, respectively.
*'''<settings />''' Most gamemodes use [[settings system]] to let server admins to configure it how they like. For instance you could set round time and then use [[get]] and [[set]] to get the value or change it, respectively.
** '''<setting />''' Resource settings can be accessed by resource and Admin panel, possible parameters are:
*** '''name:''' The setting name used by the scripts to get or set the setting value
*** '''value:''' The setting default value used by the scripts
*** '''friendlyname:''' A friendly name to the setting (optional)
*** '''accept:''' The values the setting could accept (optional)
*** '''examples:''' An Example of a value (optional)
*** '''desc:''' A description of the setting (optional)
*'''<min_mta_version />''' Minimum version requirements for this resource to run correctly. When authoring resources, the minimum version should usually be set to the current released version of MTA:SA (which at the moment is "{{Current Version|full}}"). See example for example.
*'''<min_mta_version />''' Minimum version requirements for this resource to run correctly. When authoring resources, the minimum version should usually be set to the current released version of MTA:SA (which at the moment is "{{Current Version|full}}"). See example for example.
**'''client:''' The minimum client version
**'''client:''' The minimum client version
**'''server:''' The minimum server version
**'''server:''' The minimum server version
*'''<aclrequest />''' A list of [[Access_Control_List|ACL]] rights this resource will need.
*'''<aclrequest />''' A list of [[Access_Control_List|ACL]] rights this resource will need. Any user with admin permission can accept or reject a resource ACL request by using the command: /aclrequest [list/allow/deny] <resourceName> [<right>/all]
** '''<right />''' an individual right
***'''name:''' The right name.
***'''access:''' Set to ''true'' to allow the resource to access this right. Set to ''false'' to deny the access to this right.
{{New items|3.0132|1.3.1 r4141|
{{New items|3.0132|1.3.1 r4141|
*'''<sync_map_element_data />''' Controls whether map [[Element_data|element data]] such as "PosX" and "DoubleSided" are transferred to the client. This data is usually not required by most gamemodes or resources. (Map Editor and Interiors require this to be not set to false to work). When set in a gamemode meta.xml, the setting will apply to all maps loaded by that resource.
*'''<sync_map_element_data />''' Controls whether map [[Element_data|element data]] such as "PosX" and "DoubleSided" are transferred to the client. This data is usually not required by most gamemodes or resources. (Map Editor and Interiors require this to be not set to false to work). When set in a gamemode meta.xml, the setting will apply to all maps loaded by that resource.
Line 47: Line 60:
}}
}}
{{New items|3.0140|1.4.0 r5313|
{{New items|3.0140|1.4.0 r5313|
*'''<oop/>''' OOP - Please refer to [[OOP]] for documentation.
*'''<oop />''' OOP - Please refer to [[OOP]] for documentation.
**'''false:''' Disable OOP.
**'''false:''' Disable OOP.
**'''true:''' Enable OOP.
**'''true:''' Enable OOP.
}}
}}
{{New feature/item|3.0150|1.5.0|7308|
{{New feature/item|3.0150|1.5.0|7308|
*'''<download_priority_group/>''' If not set, the download priority group for a resource defaults to 0. If this is set higher than 0, then the resource will be downloaded and started on the client earlier than other resources. If set to less than 0, the resource will be downloaded and started on the client later than other resources.
*'''<download_priority_group />''' If not set, the download priority group for a resource defaults to 0. If this is set higher than 0, then the resource will be downloaded and started on the client earlier than other resources. This option is useful for resources with critical client functionality that other things in your gamemode (or fair play) rely on. If set to less than 0 (a negative number, like -1), the resource will be downloaded and started on the client later than other resources. As this can be confusing, here is an example:
**'''Resource A: <download_priority_group>20</download_priority_group>''' will start earlier than..
**'''Resource B: <download_priority_group>10</download_priority_group>'''<br/>In this case, Resource A will start earlier than Resource B because its value (20) is higher than (10). In turn, Resource B will still start earlier than a resource with a negative value or a value below 10 (like 5).
 
}}
}}


== Example ==
== Example ==
Heres an example of a meta file using some of the tags mentioned:
Here's an example of a meta file using some of the tags mentioned:
{{#tag:code |
{{#tag:syntaxhighlight |
<meta>
<meta>
     <info author="Slothman" type="gamemode" name="Stealth" />
     <info author="Slothman" version="1.0.2" name="Stealth" description="Allow scripts to insert a ped that simulates combat with a real player" type="gamemode" />
    <config src="help.xml" type="client"/>
 
    <download_priority_group>0</download_priority_group>
    <min_mta_version client="{{Current Version|full}}" server="{{Current Version|full}}" />
 
    <sync_map_element_data>false</sync_map_element_data>


     <script src="stealthmain_server.lua" />
     <script src="stealthmain_server.lua" />
Line 76: Line 86:
     <script src="spycam.lua" type="client"/>
     <script src="spycam.lua" type="client"/>
     <script src="riemann_z_demonstration.lua" type="client" cache="false"/>
     <script src="riemann_z_demonstration.lua" type="client" cache="false"/>
     <map src="base.map" dimension="1"/>
     <map src="base.map" dimension="1"/>


     <file src="riot_shield.txd" />
     <file src="riot_shield.txd" download="false" />
     <file src="riot_shield.dff" />
     <file src="riot_shield.dff" download="false" />
     <file src="riot_shield.col" />
     <file src="riot_shield.col" download="false" />
     <file src="armor.png" download="true"/>
     <file src="armor.png" />
     <file src="camera.png" download="false"/>
     <file src="camera.png" />
     <file src="cloak.png" />
     <file src="cloak.png" />
     <file src="goggles.png" />
     <file src="goggles.png" />
Line 93: Line 104:
     <include resource="maplimits" />
     <include resource="maplimits" />
      
      
    <config src="help.xml" type="client"/>
     <export function="exampleExport1" type="server" />
     <export function="exampleExport1" type="server" />
     <export function="exampleExport2" type="client" />
     <export function="exampleExport2" type="client" />
Line 98: Line 111:


     <settings>
     <settings>
        <setting name="roundlimit" value="[6]" /> <!-- round length in minutes -->
        <setting name="roundlimit" value="[6]" /> <!-- round length in minutes -->
<setting name="teamdamage" value="[1]" /> <!-- 0 for team protection off, 1 for team protection on -->
<setting name="teamdamage" value="[1]" /> <!-- 0 for team protection off, 1 for team protection on -->
<setting name="teambalance" value="[1]" /> <!--  difference limit of amount of players between teams -->
<setting name="teambalance" value="[1]" /> <!--  difference limit of amount of players between teams -->
<setting name="spazammo" value="[25]" /> <!-- ammo amounts -->
<setting name="isAllowedToShoot" value="true" />
<setting name="m4ammo" value="[100]" />
<setting name="admingroup" value="Admin,AdminPlus"
<setting name="shotgunammo" value="[25]" />
friendlyname="Admin group list"
<setting name="sniperammo" value="[20]" />
group="_Advanced"
<setting name="ak47ammo" value="[120]" />
accept="*"
<setting name="rifleammo" value="[40]" />
examples="Admin,Moderator,SuperModerator"
<setting name="deserteagleammo" value="[45]" />
desc="To use this resource, the player must belong to one of the groups listed."
<setting name="pistolammo" value="[132]" />
/> <!-- a setting example using all optional parameters -->
<setting name="uziammo" value="[150]" />
<setting name="spazammo" value="[25]" /> <!-- ammo amounts -->
<setting name="tec9ammo" value="[150]" />
<setting name="m4ammo" value="[100]" />
<setting name="silencedammo" value="[65]" />
<setting name="shotgunammo" value="[25]" />
<setting name="grenadeammo" value="[4]" />
<setting name="sniperammo" value="[20]" />
<setting name="satchelammo" value="[4]" />
<setting name="ak47ammo" value="[120]" />
<setting name="teargasammo" value="[4]" />
<setting name="rifleammo" value="[40]" />
<setting name="molatovammo" value="[4]" />
<setting name="deserteagleammo" value="[45]" />
<setting name="isAllowedToShoot" value="true" />
<setting name="pistolammo" value="[132]" />
    </settings>
<setting name="uziammo" value="[150]" />
<setting name="tec9ammo" value="[150]" />
<setting name="silencedammo" value="[65]" />
<setting name="grenadeammo" value="[4]" />
<setting name="satchelammo" value="[4]" />
<setting name="teargasammo" value="[4]" />
<setting name="molatovammo" value="[4]" />
    </settings>
 
    <min_mta_version server="1.5.2-9.07903" client="1.5.2-9.07903" />
 
    <aclrequest>
        <right name="function.startResource" access="true" />
        <right name="function.stopResource" access="true" />
        <right name="function.setPlayerMuted" access="true" />
    </aclrequest>


    <aclrequest>
    <sync_map_element_data>false</sync_map_element_data>
<right name="function.startResource" access="true" />
 
<right name="function.stopResource" access="true" />
    <oop>false</oop>
<right name="function.setPlayerMuted" access="true" />
 
    </aclrequest>
    <download_priority_group>0</download_priority_group>
</meta>
</meta>
|lang="xml"}}
|lang="xml"}}
[[Category:Scripting Concepts]]
[[Category:Scripting Concepts]]
[[hu:Meta.xml]]
[[cs:Meta.xml]]
[[cs:Meta.xml]]
[[de:Meta.xml]]
[[de:Meta.xml]]

Revision as of 13:56, 17 May 2021

The meta.xml file presents MTA with a set of metadata, such as the resource's name, the scripts to include, and which files to precache for sending to clients among other things. It is also the scope of "elements". It is written in XML, which is based on HTML and is the parent of XHTML.

Tags

XML is a textual data format which is widely used for the representation of data. MTA uses an XML-based language to describe the metadata for resources by using the tags below:

  • <info /> Information about this resource, possible parameters include (any arbitrary parameters can be used and read using getResourceInfo):
    • author: The author of this resource
    • version: The version of this resource
    • name: The name of this resource
    • description: A brief description of this resource
    • type: The type of this resource, that can be "gamemode", "script", "map" or "misc".
    • gamemodes: The gamemodes to be compatible with the resource. It must be the name of the gamemode resource, not the gamemode name. If you want it to be compatible with multiple gamemodes, it must be in a comma-separated list without spaces. (e.g. gamemodes="test1,test2").
  • <script /> Source code for this resource, possible parameters are:
    • src: The file name of the source code
    • type: The type of source code: "client", "server" or "shared".
      • A shared script will be ran for both client and server, but separately as usual (basically adds the script twice: once for server and once for client)
    • cache: When the script file type is "client", this setting controls whether the file is saved on the clients' hard drive. Default is "true". Using "false" will mean the file is not saved. (Note: cache=false files are started at the client first, so lua file load order might differ when mixing cache settings)
    • validate: If set to "false", compatibility checks are skipped.
  • <map /> The map for a gamemode, possible parameters are:
    • src: .map file name (can be path too eg. "maps/filename.map")
    • dimension: Dimension in which the map will be loaded (optional)
  • <file /> A client-side file. Generally these are images, .txd, .col, .dff or .xml files. They'll be downloaded by clients when the resources is started (or on join)
    • src: client-side file name (can be path too eg. "images/image.png")
    • download: Whether or not to be sent to the client automatically (optional). Default is "true". Using "false" will mean they are not sent on resource start but could later be used by downloadFile.
  • <include /> Include resources that this resource will use
    • resource: Resource name that you want to start with this resource
    • minversion: Minimum version that resource needs to be (optional)
    • maxversion: Maximum version that resource needs to be (optional)
  • <config /> Config file (.xml) can be accessed by resource, possible parameters are:
    • src: The file name of the config file
    • type: The type of the config file: "client" or "server"
  • <export /> This exports functions from this resource, so other resources can use them with call
    • function: The function name
    • type Whether function is exported server-side or client-side (valid values are: "client", "server" and "shared")
      • A shared export will make the function callable from both client and server scripts (basically adds the export twice: once for server and once for client)
    • http: Can the function be called via HTTP (true/false)
  • <html />
    • src: The filename for the HTTP file (can be a path)
    • default: The html file is one that is shown by default when visiting /resourceName/ on the server. Only one html can be default, the rest are ignored. (true/false)
    • raw: The html file is not parsed by the Lua interpreter and is treated as binary data. Must be used for binary files (images mainly) (true/false)
  • <settings /> Most gamemodes use settings system to let server admins to configure it how they like. For instance you could set round time and then use get and set to get the value or change it, respectively.
    • <setting /> Resource settings can be accessed by resource and Admin panel, possible parameters are:
      • name: The setting name used by the scripts to get or set the setting value
      • value: The setting default value used by the scripts
      • friendlyname: A friendly name to the setting (optional)
      • accept: The values the setting could accept (optional)
      • examples: An Example of a value (optional)
      • desc: A description of the setting (optional)
  • <min_mta_version /> Minimum version requirements for this resource to run correctly. When authoring resources, the minimum version should usually be set to the current released version of MTA:SA (which at the moment is "1.6.0"). See example for example.
    • client: The minimum client version
    • server: The minimum server version
  • <aclrequest /> A list of ACL rights this resource will need. Any user with admin permission can accept or reject a resource ACL request by using the command: /aclrequest [list/allow/deny] <resourceName> [<right>/all]
    • <right /> an individual right
      • name: The right name.
      • access: Set to true to allow the resource to access this right. Set to false to deny the access to this right.
  • <sync_map_element_data /> Controls whether map element data such as "PosX" and "DoubleSided" are transferred to the client. This data is usually not required by most gamemodes or resources. (Map Editor and Interiors require this to be not set to false to work). When set in a gamemode meta.xml, the setting will apply to all maps loaded by that resource.
    • false: Disable transfer of map element data for all resources. This can reduce map download times considerably.
    • true: Enable transfer of map element data for all resources. (If false and true are set in different resources, true will have priority and all resources will transfer map element data)
  • <oop /> OOP - Please refer to OOP for documentation.
    • false: Disable OOP.
    • true: Enable OOP.
  • <download_priority_group /> If not set, the download priority group for a resource defaults to 0. If this is set higher than 0, then the resource will be downloaded and started on the client earlier than other resources. This option is useful for resources with critical client functionality that other things in your gamemode (or fair play) rely on. If set to less than 0 (a negative number, like -1), the resource will be downloaded and started on the client later than other resources. As this can be confusing, here is an example:
    • Resource A: <download_priority_group>20</download_priority_group> will start earlier than..
    • Resource B: <download_priority_group>10</download_priority_group>
      In this case, Resource A will start earlier than Resource B because its value (20) is higher than (10). In turn, Resource B will still start earlier than a resource with a negative value or a value below 10 (like 5).

Example

Here's an example of a meta file using some of the tags mentioned:

<meta>
    <info author="Slothman" version="1.0.2" name="Stealth" description="Allow scripts to insert a ped that simulates combat with a real player" type="gamemode" />

    <script src="stealthmain_server.lua" />
    <script src="noiseblip.lua" />
    <script src="mission_timer.lua" />
    <script src="gadgets_server.lua" />
    <script src="gadgets_client.lua" type="client"/>
    <script src="stealthmain_client.lua" type="client" validate="true"/>
    <script src="noisebar.lua" type="client"/>
    <script src="spycam.lua" type="client"/>
    <script src="riemann_z_demonstration.lua" type="client" cache="false"/>

    <map src="base.map" dimension="1"/>

    <file src="riot_shield.txd" download="false" />
    <file src="riot_shield.dff" download="false" />
    <file src="riot_shield.col" download="false" />
    <file src="armor.png" />
    <file src="camera.png" />
    <file src="cloak.png" />
    <file src="goggles.png" />
    <file src="mine.png" />
    <file src="radar.png" />
    <file src="shield.png" />

    <include resource="scoreboard" />
    <include resource="killmessages" />
    <include resource="maplimits" />
    
    <config src="help.xml" type="client"/>

    <export function="exampleExport1" type="server" />
    <export function="exampleExport2" type="client" />
    <export function="exampleExport3" type="shared" />

    <settings>
        <setting name="roundlimit" value="[6]" /> 
	<setting name="teamdamage" value="[1]" /> 
	<setting name="teambalance" value="[1]" /> 
	<setting name="isAllowedToShoot" value="true" />
	<setting name="admingroup" value="Admin,AdminPlus"
		friendlyname="Admin group list"
		group="_Advanced"
		accept="*"
		examples="Admin,Moderator,SuperModerator"
		desc="To use this resource, the player must belong to one of the groups listed."
		/> 
	<setting name="spazammo" value="[25]" /> 
	<setting name="m4ammo" value="[100]" />
	<setting name="shotgunammo" value="[25]" />
	<setting name="sniperammo" value="[20]" />
	<setting name="ak47ammo" value="[120]" />
	<setting name="rifleammo" value="[40]" />
	<setting name="deserteagleammo" value="[45]" />
	<setting name="pistolammo" value="[132]" />
	<setting name="uziammo" value="[150]" />
	<setting name="tec9ammo" value="[150]" />
	<setting name="silencedammo" value="[65]" />
	<setting name="grenadeammo" value="[4]" />
	<setting name="satchelammo" value="[4]" />
	<setting name="teargasammo" value="[4]" />
	<setting name="molatovammo" value="[4]" />
    </settings>

    <min_mta_version server="1.5.2-9.07903" client="1.5.2-9.07903" />

    <aclrequest>
        <right name="function.startResource" access="true" />
        <right name="function.stopResource" access="true" />
        <right name="function.setPlayerMuted" access="true" />
    </aclrequest>

    <sync_map_element_data>false</sync_map_element_data>

    <oop>false</oop>

    <download_priority_group>0</download_priority_group>
</meta>