Database Setup

Guide for setting up database tables for Tworst Scripts.


Automatic Setup

circle-check

When you start your server with a Tworst Script for the first time, the script will:

  1. Check if the required tables exist

  2. Create any missing tables automatically

  3. Set up the correct table structure

You should see a message in your server console confirming the tables were created.


Prerequisites

Before the automatic setup can work, make sure you have one of these database resources running:

Database Resource
Config Value
Notes

oxmysql

'oxmysql'

Recommended

mysql-async

'mysql-async'

Legacy support

ghmattimysql

'ghmattimysql'

Legacy support

Set your database resource in config/config.lua:

circle-exclamation

Manual Setup (Optional)

In rare cases where automatic table creation fails, you can manually import the SQL tables.

When to Use Manual Setup

  • Automatic creation failed due to permission issues

  • You prefer to review the table structure before creation

  • You're migrating from another script

How to Import Manually

Each Tworst Script includes an insert.sql file in the root folder:

Method 1: HeidiSQL

  1. Connect to your database

  2. Select your database from the left panel

  3. Go to File → Run SQL file

  4. Select the insert.sql file from the script folder

  5. Click Execute

Method 2: phpMyAdmin

  1. Login to phpMyAdmin

  2. Select your database from the left panel

  3. Go to the Import tab

  4. Click Choose File and select the insert.sql file

  5. Click Go

Method 3: Command Line

circle-exclamation

Table Naming Convention

All Tworst Scripts use a consistent naming convention for database tables:

Examples:

Script
Table Name

Scrapyard Job

tw_scrapyard_players

Gardener Job

tw_gardener_players

Transport Job

tw_transport_players

This naming convention helps you:

  • Easily identify which tables belong to which script

  • Avoid conflicts with other resources

  • Manage your database more efficiently


Common Issues

Error
Cause
Solution

Table already exists

Previous installation

Safe to ignore, or drop existing table if you want fresh data

Access denied

Database permissions

Check your database user has CREATE TABLE permissions

Unknown database

Database doesn't exist

Create the database first in your MySQL client

Connection failed

Wrong credentials

Verify database credentials in your server.cfg

Checking Database Connection

Make sure your server.cfg has the correct database connection string:


Resetting Data

If you want to reset all data for a script:

triangle-exclamation
  1. Stop your server

  2. Open your database management tool

  3. Find the tables starting with tw_[scriptname]_

  4. Drop (delete) those tables

  5. Start your server - tables will be recreated automatically


Need Help?

circle-info

Having database issues? Join our Discord serverarrow-up-right and open a support ticket with:

  • Your database resource (oxmysql, mysql-async, etc.)

  • The error message from server console

  • Your Config.SQL setting

Last updated