Resources: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
(Undo revision 60146 by Surge (talk))
(9 intermediate revisions by 7 users not shown)
Line 1: Line 1:
Los recursos son una parte clave de la MTA. Un recurso es básicamente un archivo de carpetas o zip que contiene una colección de archivos - incluso archivos de comandos, además de una meta''''archivo que describe cómo el recurso debe ser cargado. Un recurso puede ser visto como parte equivalente a un programa que se ejecuta en un sistema operativo - que puede ser iniciado y detenido, y múltiples recursos se pueden ejecutar al mismo tiempo. Vale la pena recordar, sin embargo, que a diferencia de los programas en un sistema operativo, no hay multitarea entre los recursos.
Resources are a key part of MTA. A resource is essentially a folder or zip file that contains a collection of files - including script files, plus a ''meta'' file that describes how the resource should be loaded. A resource can be seen as being partly equivalent to a program running in an operating system - it can be started and stopped, and multiple resources can run at once. Its worth remember though, that unlike programs on an operating system, there is no multi-tasking between resources.
 
==Terminology==
* '''Resource''' - A zip file or folder containing a meta.xml file and a number of resource items. These are placed in the ''mods/deathmatch/resources'' folder in the server directory.
* '''Resource item''' - A file contained within a resource, currently this can be a map, script, images etc.


* Terminología *
*''Recursos'' - Un archivo zip o carpeta que contiene un archivo meta.xml y una serie de elementos de recursos. Estos se colocan en los mods''/ deathmatch / recursos''carpeta en el directorio del servidor.
*''Tema'' - Un archivo contenido dentro de un recurso,esto puede ser un mapa, musica, imágenes, etc
==The Meta File==
==The Meta File==
''Ve la [[Meta.xml]] para detalles ( Abrela con Notepad )''
''See main article [[Meta.xml]] for details''


El archivo de Meta es el núcleo de cada recurso. En él se describe exactamente lo que los archivos en el recurso se debe utilizar y cómo. El siguiente es un ejemplo que cubre todas las opciones que hay, los archivos de metadatos puede tener tantas o tan pocas de estas etiquetas como tu quieras:  
The Meta file is the core of each the resource. It describes exactly what files in the resource should be used, and how. The following is an example that covers every option there is, your meta files can have as many or as few of these tags as you require:


<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
<meta>
<meta>
     <info author="eAi" description="Ejemplo basico de Scritp" version="4"/>
     <info author="eAi" description="This is a basic CTF script" version="4"/>


     <include resource="radarblips"/>
     <include resource="radarblips"/>
Line 37: Line 38:
</meta>
</meta>
</syntaxhighlight>
</syntaxhighlight>
Si bien un mapa CTF puede tener un meta.xml que se parece a:
While a CTF map may have a meta.xml that looks like:
<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
<meta>
<meta>
Line 48: Line 49:




Script/tipo, Config/tipo y Archivos/tipo los atributos especifican si el  script/resource necesita enviar los datos al cliente, o por defecto al "server".
Script/type, Config/type and File/type attributes specify if the script/resource should be sent to clients or not, and defaults to "server".
 
The include tag specifies other resources that should be started before this resoucre is started.  In other words, if your resource is dependent on another, you can include it so that the other resource is started first.
 


Las etiquetas incluyen especificaciones como recursos que se debe iniciar antes de un resource que se ha iniciadoEn otras palabras, si su recurso es dependiente de otro, puede incluir para que el otro recurso que se inicie en primer lugar,<--- ( En traduccion )
Each resource has its own virtual machine (VM). This contains every script in the resource.  This means that variables are not shared with other resources.  The best way to communicate with other resources is by using the ''export'' tag and exporting a function.  This will enable other resources to fire this function using the [[call]] scripting function.




Cada recurso tiene su propia máquina virtual (VM). Este contiene todos los scripts en el recurso. Esto significa que las variables no se comparten con otros recursos. La mejor manera de communictate con otros recursos es mediante la exportación''''etiquetas y exportación de una función. Por Esto hara Que Otros scritp Hagan la Fucion [[llamada]] Otros Haciendo funcionar.
Scripts sent to clients are started as soon as all the scripts have been downloaded.




Los scripts se envían a los clientes iniciar tan pronto como todos los scripts han sido descargados.
Scripts are able to read and write to their own resource folder with functions such as [[xmlCreateFile]] and [[fileCreate]]. They can also read and write to other resources, but must have [[Access_Control_List|ACL]] access.  


Los scripts son capaces de leer y escribir en su carpeta de recursos propios con funciones tales como [[xmlCreateFile]] y [[fileCreate]]. También pueden leer y escribir a otros recursos, pero debe tener [[Access_Control_List | ACL]] de acceso.


Cada recurso sólo puede ser cargado una vez, en el servidor que sea. Si un recurso se incluye más de una vez, la misma instancia serán utilizados por cada recurso que incluye.
Each resource can only be loaded once, the server will ensure this. If a resource is included more than once, the same instance will be used by each resource that includes it.


== == Archivos almacenados
==File storage==
Los archivos ''Resources'' pueden ser almacenados en un .zip o un directorio. Se encuentra en:
Resource files can either be stored in a zip or a directory. This is located in:


server/mods/deathmatch/resources/ (Si tienes el server instalado con el cliente)
server/mods/deathmatch/resources/ (if you've installed your server with the client)


o
or


mods/deathmatch/resources/ (para server dedicados)
mods/deathmatch/resources/ (for dedicated server installations)


Cada recurso puede tener un archivo zip, un directorio o ambos. En el caso de los dos existentes, el directorio tiene precedencia sobre el archivo zip, ya que este tipo de archivos se pueden colocar en el directorio a pasar por encima de los archivos en el archivo zip. Esto permite a los directorios que se utilizará para las pruebas y el desarrollo de mapas / scripts mientras que los archivos zip utilizados por los usuarios finales.
Each resource can have a zip file, a directory or both. In the case of both existing, the directory has precedence over the zip file, as such files can be placed in the directory to over-ride the files in the zip file. This allows directories to be used for testing and developing of maps/scripts while zip files used by end-users.


==Other things to note==
==Other things to note==
Line 88: Line 91:
{{Resource_events}}
{{Resource_events}}


[[hu:Resources]]
[[it:Introduzione alle Risorse]]
[[it:Introduzione alle Risorse]]
[[pt-br:Recursos]]
[[ru:Resources]]
[[ru:Resources]]
( Aun ando traduciendo este tema ) > By F4ST3R <

Revision as of 22:37, 28 October 2018

Resources are a key part of MTA. A resource is essentially a folder or zip file that contains a collection of files - including script files, plus a meta file that describes how the resource should be loaded. A resource can be seen as being partly equivalent to a program running in an operating system - it can be started and stopped, and multiple resources can run at once. Its worth remember though, that unlike programs on an operating system, there is no multi-tasking between resources.

Terminology

  • Resource - A zip file or folder containing a meta.xml file and a number of resource items. These are placed in the mods/deathmatch/resources folder in the server directory.
  • Resource item - A file contained within a resource, currently this can be a map, script, images etc.

The Meta File

See main article Meta.xml for details

The Meta file is the core of each the resource. It describes exactly what files in the resource should be used, and how. The following is an example that covers every option there is, your meta files can have as many or as few of these tags as you require:

<meta>
    <info author="eAi" description="This is a basic CTF script" version="4"/>

    <include resource="radarblips"/>
    <include resource="markermanagement" />

    <script src="ctf.lua" />
    <script src="flag.lua" />
    <script src="ctf_client.lua" type="client" />

    <file src="model.dff" />
    <file src="quitbutton.png" />
    <file src="killed.png"  />

    <html src="test.htm" default="true"/>
    <html src="logo.png" raw="true" />

    <export function="multiply" http="true" />
    <export function="getPlayerList" />
    <export function="getElementOwner" type="client"/>

    <config src="vehicle-list.xml" type="client" />
    <config src="markerconfig.xml" type="server"  />

    <map src="somestuff.map" dimension="99" />
</meta>

While a CTF map may have a meta.xml that looks like:

<meta>
    <include resource="ctf" />
    <map src="myuberl33tctfmap.map" />

    <info author="Tom" instructions="this is uber l33t !!!!!1111111" type="map" />
</meta>


Script/type, Config/type and File/type attributes specify if the script/resource should be sent to clients or not, and defaults to "server".

The include tag specifies other resources that should be started before this resoucre is started. In other words, if your resource is dependent on another, you can include it so that the other resource is started first.


Each resource has its own virtual machine (VM). This contains every script in the resource. This means that variables are not shared with other resources. The best way to communicate with other resources is by using the export tag and exporting a function. This will enable other resources to fire this function using the call scripting function.


Scripts sent to clients are started as soon as all the scripts have been downloaded.


Scripts are able to read and write to their own resource folder with functions such as xmlCreateFile and fileCreate. They can also read and write to other resources, but must have ACL access.


Each resource can only be loaded once, the server will ensure this. If a resource is included more than once, the same instance will be used by each resource that includes it.

File storage

Resource files can either be stored in a zip or a directory. This is located in:

server/mods/deathmatch/resources/ (if you've installed your server with the client)

or

mods/deathmatch/resources/ (for dedicated server installations)

Each resource can have a zip file, a directory or both. In the case of both existing, the directory has precedence over the zip file, as such files can be placed in the directory to over-ride the files in the zip file. This allows directories to be used for testing and developing of maps/scripts while zip files used by end-users.

Other things to note

  • Resource names can't have dots in.
  • If the resource does any file saving, the file names used should not be listed in the meta.xml
  • Files listed in the meta.xml should be considered read only by your scripts. Do not modify them with xmlSaveFile, FileSave etc.
  • When making a zip file of your resource, do not include save files. If your resource uses save files, they must be created by your resource when needed.
  • When making a zip file of your resource, only include files that are listed in the meta.xml. Do not include 'example' save files, otherwise bad things will happen.
  • We recommend avoiding spaces and exotic characters from resources names.

Script functions

The resource system can be manipulated by script. As such, the following Serverside scripting functions are provided:


The following events are also provided: