ServersYour serverFor creatorsForumFAQDocumentationSecurity
Download the launcher
  1. Documentation
  2. Getting started

Guide

Getting started

Your first resource in five minutes: a folder, meta.xml, one server script and one client script.

What is a resource

Everything that happens on a server is done by resources. A resource is a folder in resources/ with a meta.xml file that tells the server which scripts and files belong to it. A game mode, an admin panel, a speedometer or a race are separate resources that you turn on and off without restarting the server.

The folder layout, meta.xml and function names are the ones you know from other San Andreas servers.

Create a folder

In the server folder open resources/ and create a folder called welcome in it. The folder name is the resource name you will use in the console.

resources/
  welcome/
    meta.xml
    server.lua
    client.lua

Write meta.xml

meta.xml lists the resource's scripts. The type attribute decides where a script runs: server stays on the server, client is sent to every player.

<meta>
    <info name="Welcome" author="You" version="1.0" type="script" />
    <script src="server.lua" type="server" />
    <script src="client.lua" type="client" />
</meta>

Add the scripts

The server script reacts to a player joining: it puts them in the world and writes in chat. The client script draws text on the player's screen every frame.

addEventHandler("onPlayerJoin", root, function()
    -- source is the player who just joined
    spawnPlayer(source, 2495.3, -1687.0, 13.5)
    outputChatBox("Welcome to Grove Street, " .. getPlayerName(source) .. "!", source, 255, 122, 34)
end)

Start it

Type in the server console:

start welcome

Join the server from the launcher. After changing a script you do not need to shut the server down, restart welcome is enough. The command reloads the resource on the server and for every player.

Error in a script? The server prints the file, line number and a description in the console. A bad argument in a function call does not stop the script, it just returns false with a warning. More in Conventions.

What next