Resources: Difference between revisions

no edit summary
No edit summary
No edit summary
Tags: Mobile edit Mobile web edit
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== What is a resource? ==
== What is a resource? ==
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.  
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 resource can be used by placing it's content in either a folder or zipped up in a [https://en.wikipedia.org/wiki/Tar_(computing) tar file].
A resources' content can be used in either a folder or zipped up in a [https://en.wikipedia.org/wiki/Tar_(computing) tar file].




== Using resources ==
== Using resources ==
Place the resource in your server's "resources" folder. Then, 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:
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>
{{XMLCode|1=<resources>
<resource src="something"/>
<resource src="something"/>
<resource src="something-else" />
<resource src="something-else" />
</resources>}}
</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).




Line 17: Line 19:


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.
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




Line 40: Line 57:
<file url="" src="" type=""  />
<file url="" src="" type=""  />
</meta>}}
</meta>}}
== Client-side Files ==
Resources that contain client-side files are cached. If the built-in HTTP server is enabled, this will be used to distribute these files to clients when they connect or when the resource is updated and restarted. The default folder is "htdocs" in the GTAC server's main directory. You can also use your own HTTP server (like apache2 or nginx) as long as you add a virtual directory pointing to that "htdocs" folder in your GTAC server. Please note that this only applies to client-side files (used in ''<file>'' tag of the resource's meta.xml), not script files!
== Other Notes ==
* The server will ignore any folders named with open and close square brackets, meaning they will not be loaded or cached as resources. This is useful if you want to group resources into subfolders for organization. Example name: [foobar]
2,591

edits