STG ScriptsDocumentation
Tennis

Configuration

Every option in STG Tennis shared/config.lua, from courts and match rules to training levels, rackets, outfits and notifications.

All settings live in stg-tennis/shared/config.lua. The file stays editable in the escrow version. Restart the resource after a change.

Language

Config.Language = 'en'

Available: en, de, fr, es, pt, it, nl, pl, sv, no, fi, cs, ar, he, jp, ko, zh. To change a text, edit the matching file in stg-tennis/locales/.

Courts

The script ships with 10 courts. Each entry describes one court:

Config.Courts = {
    { id = 1, label = 'Rockford Villa', center = vector3(-773.0, 153.465, 66.52), heading = 0.0, width = 7.98, length = 11.89, z = 66.5 },
    -- ...
}

Prop

Type

Adding a court

Stand in the middle of the court at the net, facing along the net.

Copy your coordinates and heading, for example with /coords or your admin menu.

Add a new line to Config.Courts with a new id, using those values for center, heading and z. Start with the default width and length and adjust if the lines do not match the painted court.

Match rules

Config.Match = {
    gamesPerSet = 4,
    setChoices = { 1, 3, 5 },
    defaultSets = 1,
}

Prop

Type

Breaks

Config.BreakDuration = 120

Length of a break in seconds. Players are offered a break after odd games and at the end of every set. One side asking is enough to start it, and both sides can end it early.

Training

Config.Training = {
    levels = {
        order = { 'easy', 'normal', 'hard' },
        easy   = { delay = 950, spread = 2.4, miss = 0.20 },
        normal = { delay = 720, spread = 3.6, miss = 0.09 },
        hard   = { delay = 540, spread = 5.0, miss = 0.03 },
    },
    modes = { 'rally', 'serve', 'return' },
    target = 40,
}

Each difficulty level has three values:

ValueMeaning
delayMilliseconds before the ball comes back. Lower is faster.
spreadHow far off target the return can land, in metres. Higher is harder to reach.
missChance the system misses its own shot, from 0 to 1.
  • modes: remove a mode from the list to hide it from the menu. rally plays full points, serve practises serves only, return feeds the ball to the player.
  • target: the session ends when one side reaches this score.

Timing assist

Config.TimingAssist = true

Lights up the swing keys on the controls card when it is time to hit. Set to false for a harder game.

Rackets

Config.Rackets = {
    { model = 'prop_tennis_rack_01b', image = 'img/racket_blue.png' },
    { model = 'prop_tennis_rack_01',  image = 'img/racket_pink.png' },
}

Rackets players can pick before a match. The first one is the default. image is relative to the web/ folder.

Outfit

Config.Outfit = {
    enabled = true,
    male = { components = { ... }, props = { ... } },
    female = { components = { ... }, props = { ... } },
}

When enabled is true, players are offered a tennis outfit before playing and get their own clothes back when they leave the court.

Each component is [componentId] = { drawable, texture }. Set a prop to -1 to remove it, the default removes the hat.

Outfits only work on freemode characters (mp_m_freemode_01 and mp_f_freemode_01). Drawable ids depend on the clothing packs your server streams, so check them in your clothing menu before changing them.

Controls card

Config.ControlsCard = {
    enabled = true,
    defaultOpen = true,
}
  • enabled: show the swing keys card on the right of the screen.
  • defaultOpen: whether the card starts open. Players can always toggle it with H.

Debug

Config.Debug = false

Prints every point to the server console. Leave it off on a live server.

Notifications

Config.Functions = {
    Notify = function(type, message)
        lib.notify({ type = type, description = message })
    end,

    Announce = function(message)
        -- score lines, sent to chat when the chat resource is running
    end,
}
  • Notify: replace the body to use your own notification system.
  • Announce: score lines like "15-0". They go to chat when the chat resource is running, otherwise they are shown with Notify.

Still having trouble?

Open a ticket on our Discord. Our team answers around 15 hours a day.

Get help on Discord

On this page