Resources: Difference between revisions

Jump to navigation Jump to search
1,279 bytes added ,  17 October 2021
no edit summary
No edit summary
 
No edit summary
(7 intermediate revisions by one other user not shown)
Line 1: Line 1:
== What is a resource? ==
== What is a resource? ==
A resource is a folder that contains a file to identify information about the resource and the files associated with the resource, such as the script files. The meta file tells the server how to use the resource, such as what scripts the server runs and which scripts and files the client will have to download and run.  
Resources contain content for a server. This can include scripts, audio, images, game files, etc. You can reload, start, and stop resources, and you can have more than 1 resource running at the same time. Resources would usually contain a script for game modes or can also contain other tasks to help control/manage the server, add commands, provide separate content, etc.
A resources' content can be used in either a folder or zipped up in a [https://en.wikipedia.org/wiki/Tar_(computing) tar file].


You can reload, start, and stop resources, and you can have more than 1 resource running at the same time. Resources would usually contain a script for game modes or can also contain other tasks to help control/manage the server, add commands, provide separate content, etc.


Resources can be created with any of the supported languages: Lua, Squirrel, or JavaScript. These can be mixed in the same resource (although in different file types). You can have one file running Lua, another with JavaScript, and another with Squirrel, all working together in the same resource.
== Using resources ==
Place the resource in your server's "resources" folder. To make the resource automatically start when running the server, open the [[ServerConfiguration|server config]] (default is server.xml) in Notepad or your preferred code editor, and find the <code><resources></code> section. Add resources by inserting a new line containing the resource: <code><resource src="something" /></code>. This new line must be '''inside''' the resources section. Here's an example:
{{XMLCode|1=<resources>
<resource src="something"/>
<resource src="something-else" />
</resources>}}
 
You can also start, stop, restart and refresh resources without restarting the server. To do this, type one of the commands (start, stop, refresh, or restart) in the server console. Example: <code>start something</code>. The refresh command is needed when you're finished editing a resource because the server loads all resources into memory so any edits won't have any effect until you use the refresh command. You can also use these commands in game, if your [[client.administrator|client.administrator]] is set to true (any running resource can set this).
 


== Creating a resource ==
== Creating a resource ==
To create a resource for the server you would simply create a new folder with the name of the resource.  
To create a resource for the server you would simply create a new folder with the name of the resource.  
Then to configure it you will need to create a file inside the resource folder named "meta.xml" (without the quotes) and open it in Notepad or your favorite code editor. We recommend [http://notepad-plus-plus.org/ Notepad++].
Then to configure it you will need to create a file inside the resource folder named "meta.xml" (without the quotes) and open it in Notepad or your favorite code editor. See the Meta File section below to learn how to use it.


Script files can be created with any of the supported languages: Lua, Squirrel, or JavaScript. These can be mixed in the same resource (although in different files). You can have one file running Lua, another with JavaScript, and another with Squirrel, all working together in the same resource.
== Example Directory Structure ==
Server.exe<br>
Server.xml<br>
resources/<br>
resources/resource1/<br>
resources/resource1/meta.xml<br>
resources/resource1/ResourceScript.js<br>
resources/resource2/<br>
resources/resource2/meta.xml<br>
resources/resource2/ResourceScript.js<br>
resources/resource2/ResourceScript.lua<br>
resources/resource2/ResourceScript.nut
== Meta File ==
Here is an example for the contents of the meta file:
Here is an example for the contents of the meta file:
{{XMLCode|1=<meta>
{{XMLCode|1=<meta>
Line 22: Line 49:
The language attribute tells the server which language to interpret the script. <br>GTA Connected supports Lua (language="lua"), JavaScript (language="javascript"), and Squirrel (language="squirrel")
The language attribute tells the server which language to interpret the script. <br>GTA Connected supports Lua (language="lua"), JavaScript (language="javascript"), and Squirrel (language="squirrel")


== Resource Meta File ==
Below is a list of all accepted meta.xml nodes.
Below is a list of all accepted meta.xml nodes.
{{XMLCode|1=<meta>
{{XMLCode|1=<meta>
Line 31: Line 57:
<file url="" src="" type=""  />
<file url="" src="" type=""  />
</meta>}}
</meta>}}
== Default resources ==
You can check out the default resources for the server [https://github.com/jack9267/GTACResources/ here].
6,833

edits

Navigation menu