1
0
Fork 0
forked from Simnation/Main

Update billing_server.lua

This commit is contained in:
Nordi98 2025-08-05 15:24:24 +02:00
parent a9c685ddf4
commit 693bd8b898

View file

@ -316,6 +316,20 @@ end
-- Create the necessary database tables if they don't exist -- Create the necessary database tables if they don't exist
MySQL.ready(function() MySQL.ready(function()
-- First check if the billing_accounts table exists
local tableExists = MySQL.query.await("SHOW TABLES LIKE 'billing_accounts'")
if #tableExists > 0 then
-- Table exists, check if the declined column exists
local columnExists = MySQL.query.await("SHOW COLUMNS FROM billing_accounts LIKE 'declined'")
if #columnExists == 0 then
-- Add the declined column if it doesn't exist
MySQL.query.await("ALTER TABLE billing_accounts ADD COLUMN declined TINYINT DEFAULT 0")
print("^2[nordi_billing] Added 'declined' column to billing_accounts table^7")
end
else
-- Create the table with all required columns
MySQL.query.await([[ MySQL.query.await([[
CREATE TABLE IF NOT EXISTS billing_accounts ( CREATE TABLE IF NOT EXISTS billing_accounts (
id INT AUTO_INCREMENT PRIMARY KEY, id INT AUTO_INCREMENT PRIMARY KEY,
@ -331,7 +345,10 @@ MySQL.ready(function()
paid_at DATETIME paid_at DATETIME
) )
]]) ]])
print("^2[nordi_billing] Created billing_accounts table^7")
end
-- Create offline_payments table if it doesn't exist
MySQL.query.await([[ MySQL.query.await([[
CREATE TABLE IF NOT EXISTS offline_payments ( CREATE TABLE IF NOT EXISTS offline_payments (
id INT AUTO_INCREMENT PRIMARY KEY, id INT AUTO_INCREMENT PRIMARY KEY,
@ -342,7 +359,10 @@ MySQL.ready(function()
processed TINYINT DEFAULT 0 processed TINYINT DEFAULT 0
) )
]]) ]])
end) print("^2[nordi_billing] Database tables initialized^7")
end) -- Added closing parenthesis here
-- Handle offline payments when a player logs in -- Handle offline payments when a player logs in
RegisterNetEvent('QBCore:Server:PlayerLoaded', function() RegisterNetEvent('QBCore:Server:PlayerLoaded', function()