💾 Database Setup
The donator store requires database tables to store player coins, purchases, and redemption codes.
Running the SQL File
Using HeidiSQL / MySQL Workbench
- Open your database management tool
- Connect to your FiveM database
- Open the file
sql/setup.sqlfrom the resource folder - Execute the SQL script
Using phpMyAdmin
- Log into phpMyAdmin
- Select your FiveM database
- Go to the "Import" tab
- Choose the
sql/setup.sqlfile - Click "Go" to execute
Using Command Line
mysql -u username -p database_name < sql/setup.sqlTables Created
The SQL script creates the following tables:
donator
Stores player coin balances.
| Column | Type | Description |
|---|---|---|
| id | INT | Primary key |
| license | VARCHAR(100) | Player license identifier |
| coins | INT | Current coin balance |
| total_spent | INT | Total coins spent |
| total_purchased | INT | Total coins purchased |
| created_at | TIMESTAMP | Account creation date |
| updated_at | TIMESTAMP | Last update time |
donator_pending
Stores pending Tebex redemption codes.
| Column | Type | Description |
|---|---|---|
| id | INT | Primary key |
| transactionId | VARCHAR(100) | Tebex transaction ID |
| package | VARCHAR(100) | Package name purchased |
| redeemed | TINYINT | Whether code was redeemed |
| redeemed_by | VARCHAR(100) | Who redeemed the code |
| created_at | TIMESTAMP | Purchase date |
| redeemed_at | TIMESTAMP | Redemption date |
donator_purchases
Logs all in-game purchases for analytics.
| Column | Type | Description |
|---|---|---|
| id | INT | Primary key |
| license | VARCHAR(100) | Player license |
| item_id | VARCHAR(100) | Item purchased |
| item_type | VARCHAR(20) | Type (vehicle/item/bundle) |
| item_name | VARCHAR(100) | Display name |
| cost | INT | Coins spent |
| purchased_at | TIMESTAMP | Purchase time |
donator_transactions
Audit log for all coin changes.
| Column | Type | Description |
|---|---|---|
| id | INT | Primary key |
| license | VARCHAR(100) | Player license |
| type | ENUM | Transaction type |
| amount | INT | Amount changed |
| balance_before | INT | Balance before change |
| balance_after | INT | Balance after change |
| reason | VARCHAR(255) | Reason for change |
| admin_source | VARCHAR(100) | Admin who made change |
| created_at | TIMESTAMP | Transaction time |
Verify Installation
To verify the tables were created, run this query:
SHOW TABLES LIKE 'donator%';You should see:
- donator
- donator_pending
- donator_purchases
- donator_transactions
✅ Done! Your database is now ready. Proceed to Configuration.
Troubleshooting
"Table already exists" error
This is fine! The script uses CREATE TABLE IF NOT EXISTS, so it won't overwrite existing data.
"Access denied" error
Make sure your database user has permission to create tables.
oxmysql connection issues
Verify your server.cfg has the correct connection string:
set mysql_connection_string "mysql://user:password@localhost/database?charset=utf8mb4"