Database Setup
Guide for setting up database tables for Tworst Scripts.
Automatic Setup
Good News! All Tworst Scripts automatically create the required database tables when the script starts for the first time. In most cases, you don't need to do anything manually!
When you start your server with a Tworst Script for the first time, the script will:
Check if the required tables exist
Create any missing tables automatically
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:
oxmysql
'oxmysql'
Recommended
mysql-async
'mysql-async'
Legacy support
ghmattimysql
'ghmattimysql'
Legacy support
Set your database resource in config/config.lua:
Make sure your database resource starts before any Tworst Scripts in your server.cfg.
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
Connect to your database
Select your database from the left panel
Go to File → Run SQL file
Select the
insert.sqlfile from the script folderClick Execute
Method 2: phpMyAdmin
Login to phpMyAdmin
Select your database from the left panel
Go to the Import tab
Click Choose File and select the
insert.sqlfileClick Go
Method 3: Command Line
Always backup your database before manually importing tables, especially on production servers.
Table Naming Convention
All Tworst Scripts use a consistent naming convention for database tables:
Examples:
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
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:
Warning: This will delete all player progress and data for that script!
Stop your server
Open your database management tool
Find the tables starting with
tw_[scriptname]_Drop (delete) those tables
Start your server - tables will be recreated automatically
Need Help?
Having database issues? Join our Discord server and open a support ticket with:
Your database resource (oxmysql, mysql-async, etc.)
The error message from server console
Your
Config.SQLsetting
Last updated

