From GTA Connected
Jump to navigation Jump to search

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. A resources' content can be used in either a folder or zipped up in a tar file.

Using resources

Place the resource in your server's "resources" folder. To make the resource automatically start when running the server, open the server config (default is server.xml) in Notepad or your preferred code editor, and find the <resources> section. Add resources by inserting a new line containing the resource: <resource src="something" />. This new line must be inside the resources section. Here's an example:

    <resource src="something"/>
    <resource src="something-else" />

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: start something. 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 is set to true (any running resource can set this).

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


Meta File

Here is an example for the contents of the meta file:

    <info author="jack9267" type="script" version="1.0.0" description="Provides something awesome." />

    <script src="server.lua" type="server" language="lua" />

The info element would contain who made the script, the type of script and the version of the script.
You would have a script element for each script file you wish to load.
The type attribute refers to where the script will run, specify "server" for server code or "client" to have the script download and run on the client.
The language attribute tells the server which language to interpret the script.
GTA Connected supports Lua (language="lua"), JavaScript (language="javascript"), and Squirrel (language="squirrel")

Below is a list of all accepted meta.xml nodes.

    <info author="" type="" version="" description="" />
    <script src="" type="" language="" />
    <dependency src="" />
    <map src="" type="" />
    <file url="" src="" type=""  />