forked from Simnation/Main
ed
This commit is contained in:
parent
7932af55cb
commit
91f2af8b8b
2 changed files with 402 additions and 200 deletions
|
@ -1,23 +1,28 @@
|
|||
local QBCore = exports['qb-core']:GetCoreObject()
|
||||
|
||||
-- Lokale Variablen
|
||||
local licenseCache = {}
|
||||
|
||||
-- Hilfsfunktionen
|
||||
local function debugPrint(message)
|
||||
if Config.Debug then
|
||||
print("^2[License-System] " .. message .. "^7")
|
||||
print("^2[License-System Server] " .. message .. "^7")
|
||||
end
|
||||
end
|
||||
|
||||
local function safeCallback(cb, ...)
|
||||
if cb and type(cb) == "function" then
|
||||
cb(...)
|
||||
return true
|
||||
else
|
||||
debugPrint("^1Callback ist keine Funktion!^7")
|
||||
debugPrint("^1FEHLER: Callback ist keine Funktion! Typ: " .. type(cb) .. "^7")
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
local function formatDate(date)
|
||||
if not date then return nil end
|
||||
return os.date("%d.%m.%Y", date)
|
||||
local function formatDate(timestamp)
|
||||
if not timestamp then return nil end
|
||||
return os.date("%d.%m.%Y", timestamp)
|
||||
end
|
||||
|
||||
local function addDaysToDate(days)
|
||||
|
@ -26,13 +31,12 @@ end
|
|||
|
||||
local function isLicenseExpired(expireDate)
|
||||
if not expireDate then return false end
|
||||
return os.time() > expireDate
|
||||
end
|
||||
|
||||
local function getDaysUntilExpiry(expireDate)
|
||||
if not expireDate then return nil end
|
||||
local diff = expireDate - os.time()
|
||||
return math.ceil(diff / (24 * 60 * 60))
|
||||
local expireTime = os.time({
|
||||
year = tonumber(string.sub(expireDate, 7, 10)),
|
||||
month = tonumber(string.sub(expireDate, 4, 5)),
|
||||
day = tonumber(string.sub(expireDate, 1, 2))
|
||||
})
|
||||
return os.time() > expireTime
|
||||
end
|
||||
|
||||
-- Spieler-Daten abrufen
|
||||
|
@ -43,6 +47,8 @@ local function getPlayerData(source)
|
|||
return {
|
||||
citizenid = Player.PlayerData.citizenid,
|
||||
name = Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname,
|
||||
firstname = Player.PlayerData.charinfo.firstname,
|
||||
lastname = Player.PlayerData.charinfo.lastname,
|
||||
birthday = Player.PlayerData.charinfo.birthdate,
|
||||
gender = Player.PlayerData.charinfo.gender,
|
||||
job = Player.PlayerData.job.name,
|
||||
|
@ -95,7 +101,10 @@ end
|
|||
-- Lizenz erstellen
|
||||
local function createLicense(citizenid, licenseType, issuedBy, classes)
|
||||
local licenseConfig = Config.LicenseTypes[licenseType]
|
||||
if not licenseConfig then return false end
|
||||
if not licenseConfig then
|
||||
debugPrint("^1Lizenz-Konfiguration nicht gefunden: " .. licenseType .. "^7")
|
||||
return false
|
||||
end
|
||||
|
||||
local issueDate = os.time()
|
||||
local expireDate = nil
|
||||
|
@ -110,11 +119,13 @@ local function createLicense(citizenid, licenseType, issuedBy, classes)
|
|||
issue_date = formatDate(issueDate),
|
||||
expire_date = expireDate and formatDate(expireDate) or nil,
|
||||
issued_by = issuedBy,
|
||||
is_active = true,
|
||||
is_active = 1,
|
||||
classes = classes and json.encode(classes) or '[]',
|
||||
created_at = issueDate
|
||||
}
|
||||
|
||||
debugPrint("Erstelle Lizenz: " .. licenseType .. " für " .. citizenid)
|
||||
|
||||
MySQL.Async.insert('INSERT INTO player_licenses (citizenid, license_type, issue_date, expire_date, issued_by, is_active, classes, created_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?)', {
|
||||
licenseData.citizenid,
|
||||
licenseData.license_type,
|
||||
|
@ -126,35 +137,59 @@ local function createLicense(citizenid, licenseType, issuedBy, classes)
|
|||
licenseData.created_at
|
||||
}, function(insertId)
|
||||
if insertId then
|
||||
debugPrint("Lizenz erstellt: " .. licenseType .. " für " .. citizenid)
|
||||
return true
|
||||
debugPrint("Lizenz erfolgreich erstellt mit ID: " .. insertId)
|
||||
-- Cache aktualisieren
|
||||
if not licenseCache[citizenid] then
|
||||
licenseCache[citizenid] = {}
|
||||
end
|
||||
licenseCache[citizenid][licenseType] = licenseData
|
||||
else
|
||||
debugPrint("^1Fehler beim Erstellen der Lizenz!^7")
|
||||
return false
|
||||
debugPrint("^1Fehler beim Erstellen der Lizenz in der Datenbank!^7")
|
||||
end
|
||||
end)
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
-- Aussteller-Name abrufen
|
||||
local function getIssuerName(citizenid, callback)
|
||||
if not citizenid then
|
||||
callback('System')
|
||||
return
|
||||
end
|
||||
|
||||
MySQL.Async.fetchScalar('SELECT CONCAT(JSON_UNQUOTE(JSON_EXTRACT(charinfo, "$.firstname")), " ", JSON_UNQUOTE(JSON_EXTRACT(charinfo, "$.lastname"))) FROM players WHERE citizenid = ?', {
|
||||
citizenid
|
||||
}, function(issuerName)
|
||||
callback(issuerName or 'Unbekannt')
|
||||
end)
|
||||
end
|
||||
|
||||
-- Callbacks
|
||||
QBCore.Functions.CreateCallback('license-system:server:getLicense', function(source, cb, targetId)
|
||||
debugPrint("getLicense aufgerufen für Spieler: " .. tostring(targetId))
|
||||
debugPrint("getLicense Callback - Source: " .. source .. ", Target: " .. tostring(targetId))
|
||||
|
||||
if not cb or type(cb) ~= "function" then
|
||||
debugPrint("^1FEHLER: Ungültiger Callback in getLicense!^7")
|
||||
return
|
||||
end
|
||||
|
||||
local TargetPlayer = QBCore.Functions.GetPlayer(targetId)
|
||||
if not TargetPlayer then
|
||||
debugPrint("^1Ziel-Spieler nicht gefunden!^7")
|
||||
debugPrint("^1Ziel-Spieler nicht gefunden: " .. tostring(targetId) .. "^7")
|
||||
safeCallback(cb, nil)
|
||||
return
|
||||
end
|
||||
|
||||
local citizenid = TargetPlayer.PlayerData.citizenid
|
||||
debugPrint("Suche Lizenz für CitizenID: " .. citizenid)
|
||||
|
||||
MySQL.Async.fetchAll('SELECT * FROM player_licenses WHERE citizenid = ? AND is_active = TRUE ORDER BY created_at DESC LIMIT 1', {
|
||||
MySQL.Async.fetchAll('SELECT * FROM player_licenses WHERE citizenid = ? AND is_active = 1 ORDER BY created_at DESC LIMIT 1', {
|
||||
citizenid
|
||||
}, function(result)
|
||||
if result and result[1] then
|
||||
local license = result[1]
|
||||
debugPrint("Lizenz gefunden: " .. license.license_type)
|
||||
|
||||
-- Spieler-Daten hinzufügen
|
||||
license.name = TargetPlayer.PlayerData.charinfo.firstname .. ' ' .. TargetPlayer.PlayerData.charinfo.lastname
|
||||
|
@ -162,61 +197,52 @@ QBCore.Functions.CreateCallback('license-system:server:getLicense', function(sou
|
|||
license.gender = TargetPlayer.PlayerData.charinfo.gender
|
||||
|
||||
-- Aussteller-Name abrufen
|
||||
if license.issued_by then
|
||||
MySQL.Async.fetchScalar('SELECT CONCAT(JSON_UNQUOTE(JSON_EXTRACT(charinfo, "$.firstname")), " ", JSON_UNQUOTE(JSON_EXTRACT(charinfo, "$.lastname"))) FROM players WHERE citizenid = ?', {
|
||||
license.issued_by
|
||||
}, function(issuerName)
|
||||
license.issued_by_name = issuerName or 'Unbekannt'
|
||||
|
||||
local licenseData = {
|
||||
license = license,
|
||||
config = Config.LicenseTypes[license.license_type] or {
|
||||
label = license.license_type,
|
||||
icon = 'fas fa-id-card'
|
||||
}
|
||||
}
|
||||
|
||||
debugPrint("Lizenz gefunden: " .. license.license_type)
|
||||
safeCallback(cb, licenseData)
|
||||
end)
|
||||
else
|
||||
license.issued_by_name = 'System'
|
||||
getIssuerName(license.issued_by, function(issuerName)
|
||||
license.issued_by_name = issuerName
|
||||
|
||||
local licenseData = {
|
||||
license = license,
|
||||
config = Config.LicenseTypes[license.license_type] or {
|
||||
label = license.license_type,
|
||||
icon = 'fas fa-id-card'
|
||||
icon = 'fas fa-id-card',
|
||||
color = '#667eea'
|
||||
}
|
||||
}
|
||||
|
||||
debugPrint("Lizenz gefunden: " .. license.license_type)
|
||||
safeCallback(cb, licenseData)
|
||||
end
|
||||
end)
|
||||
else
|
||||
debugPrint("Keine Lizenz gefunden für: " .. citizenid)
|
||||
debugPrint("Keine aktive Lizenz gefunden für: " .. citizenid)
|
||||
safeCallback(cb, nil)
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
||||
QBCore.Functions.CreateCallback('license-system:server:getMyLicense', function(source, cb, licenseType)
|
||||
debugPrint("getMyLicense aufgerufen für Typ: " .. tostring(licenseType))
|
||||
debugPrint("getMyLicense Callback - Source: " .. source .. ", Typ: " .. tostring(licenseType))
|
||||
|
||||
if not cb or type(cb) ~= "function" then
|
||||
debugPrint("^1FEHLER: Ungültiger Callback in getMyLicense!^7")
|
||||
return
|
||||
end
|
||||
|
||||
local Player = QBCore.Functions.GetPlayer(source)
|
||||
if not Player then
|
||||
debugPrint("^1Spieler nicht gefunden: " .. source .. "^7")
|
||||
safeCallback(cb, nil)
|
||||
return
|
||||
end
|
||||
|
||||
local citizenid = Player.PlayerData.citizenid
|
||||
debugPrint("Suche eigene Lizenz - CitizenID: " .. citizenid .. ", Typ: " .. licenseType)
|
||||
|
||||
MySQL.Async.fetchAll('SELECT * FROM player_licenses WHERE citizenid = ? AND license_type = ? AND is_active = TRUE ORDER BY created_at DESC LIMIT 1', {
|
||||
MySQL.Async.fetchAll('SELECT * FROM player_licenses WHERE citizenid = ? AND license_type = ? AND is_active = 1 ORDER BY created_at DESC LIMIT 1', {
|
||||
citizenid,
|
||||
licenseType
|
||||
}, function(result)
|
||||
if result and result[1] then
|
||||
local license = result[1]
|
||||
debugPrint("Eigene Lizenz gefunden: " .. license.license_type)
|
||||
|
||||
-- Spieler-Daten hinzufügen
|
||||
license.name = Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname
|
||||
|
@ -224,65 +250,59 @@ QBCore.Functions.CreateCallback('license-system:server:getMyLicense', function(s
|
|||
license.gender = Player.PlayerData.charinfo.gender
|
||||
|
||||
-- Aussteller-Name abrufen
|
||||
if license.issued_by then
|
||||
MySQL.Async.fetchScalar('SELECT CONCAT(JSON_UNQUOTE(JSON_EXTRACT(charinfo, "$.firstname")), " ", JSON_UNQUOTE(JSON_EXTRACT(charinfo, "$.lastname"))) FROM players WHERE citizenid = ?', {
|
||||
license.issued_by
|
||||
}, function(issuerName)
|
||||
license.issued_by_name = issuerName or 'Unbekannt'
|
||||
|
||||
local licenseData = {
|
||||
license = license,
|
||||
config = Config.LicenseTypes[license.license_type] or {
|
||||
label = license.license_type,
|
||||
icon = 'fas fa-id-card'
|
||||
}
|
||||
}
|
||||
|
||||
safeCallback(cb, licenseData)
|
||||
end)
|
||||
else
|
||||
license.issued_by_name = 'System'
|
||||
getIssuerName(license.issued_by, function(issuerName)
|
||||
license.issued_by_name = issuerName
|
||||
|
||||
local licenseData = {
|
||||
license = license,
|
||||
config = Config.LicenseTypes[license.license_type] or {
|
||||
label = license.license_type,
|
||||
icon = 'fas fa-id-card'
|
||||
icon = 'fas fa-id-card',
|
||||
color = '#667eea'
|
||||
}
|
||||
}
|
||||
|
||||
safeCallback(cb, licenseData)
|
||||
end
|
||||
end)
|
||||
else
|
||||
debugPrint("Keine Lizenz vom Typ " .. licenseType .. " gefunden")
|
||||
debugPrint("Keine eigene Lizenz vom Typ " .. licenseType .. " gefunden")
|
||||
safeCallback(cb, nil)
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
||||
QBCore.Functions.CreateCallback('license-system:server:getPlayerLicenses', function(source, cb, targetId)
|
||||
debugPrint("getPlayerLicenses aufgerufen für Spieler: " .. tostring(targetId))
|
||||
debugPrint("getPlayerLicenses Callback - Source: " .. source .. ", Target: " .. tostring(targetId))
|
||||
|
||||
if not cb or type(cb) ~= "function" then
|
||||
debugPrint("^1FEHLER: Ungültiger Callback in getPlayerLicenses!^7")
|
||||
return
|
||||
end
|
||||
|
||||
local TargetPlayer = QBCore.Functions.GetPlayer(targetId)
|
||||
if not TargetPlayer then
|
||||
debugPrint("^1Ziel-Spieler nicht gefunden: " .. tostring(targetId) .. "^7")
|
||||
safeCallback(cb, {})
|
||||
return
|
||||
end
|
||||
|
||||
local citizenid = TargetPlayer.PlayerData.citizenid
|
||||
debugPrint("Suche alle Lizenzen für CitizenID: " .. citizenid)
|
||||
|
||||
MySQL.Async.fetchAll('SELECT * FROM player_licenses WHERE citizenid = ? ORDER BY created_at DESC', {
|
||||
citizenid
|
||||
}, function(result)
|
||||
if result then
|
||||
debugPrint("Gefundene Lizenzen: " .. #result)
|
||||
|
||||
-- Spieler-Daten zu jeder Lizenz hinzufügen
|
||||
for i, license in ipairs(result) do
|
||||
license.name = TargetPlayer.PlayerData.charinfo.firstname .. ' ' .. TargetPlayer.PlayerData.charinfo.lastname
|
||||
license.birthday = TargetPlayer.PlayerData.charinfo.birthdate
|
||||
license.gender = TargetPlayer.PlayerData.charinfo.gender
|
||||
license.issued_by_name = 'System' -- Wird später durch echten Namen ersetzt
|
||||
end
|
||||
|
||||
debugPrint("Gefundene Lizenzen: " .. #result)
|
||||
safeCallback(cb, result)
|
||||
else
|
||||
debugPrint("Keine Lizenzen gefunden")
|
||||
|
@ -292,13 +312,24 @@ QBCore.Functions.CreateCallback('license-system:server:getPlayerLicenses', funct
|
|||
end)
|
||||
|
||||
QBCore.Functions.CreateCallback('license-system:server:canIssueLicense', function(source, cb, licenseType)
|
||||
debugPrint("canIssueLicense Callback - Source: " .. source .. ", Typ: " .. tostring(licenseType))
|
||||
|
||||
if not cb or type(cb) ~= "function" then
|
||||
debugPrint("^1FEHLER: Ungültiger Callback in canIssueLicense!^7")
|
||||
return
|
||||
end
|
||||
|
||||
local hasAuth = hasPermission(source, licenseType)
|
||||
debugPrint("Berechtigung für Lizenz " .. licenseType .. ": " .. tostring(hasAuth))
|
||||
|
||||
safeCallback(cb, hasAuth)
|
||||
end)
|
||||
|
||||
-- Events
|
||||
RegisterNetEvent('license-system:server:issueLicense', function(targetId, licenseType, classes)
|
||||
local src = source
|
||||
debugPrint("Event: issueLicense - Von: " .. src .. ", Für: " .. targetId .. ", Typ: " .. licenseType)
|
||||
|
||||
local Player = QBCore.Functions.GetPlayer(src)
|
||||
local TargetPlayer = QBCore.Functions.GetPlayer(targetId)
|
||||
|
||||
|
@ -335,13 +366,16 @@ RegisterNetEvent('license-system:server:issueLicense', function(targetId, licens
|
|||
|
||||
-- Geld abziehen
|
||||
TargetPlayer.Functions.RemoveMoney('cash', licenseConfig.price, 'license-fee')
|
||||
debugPrint("Geld abgezogen: " .. licenseConfig.price .. "$ von " .. TargetPlayer.PlayerData.charinfo.firstname)
|
||||
end
|
||||
|
||||
-- Alte Lizenz deaktivieren
|
||||
MySQL.Async.execute('UPDATE player_licenses SET is_active = FALSE WHERE citizenid = ? AND license_type = ?', {
|
||||
MySQL.Async.execute('UPDATE player_licenses SET is_active = 0 WHERE citizenid = ? AND license_type = ?', {
|
||||
TargetPlayer.PlayerData.citizenid,
|
||||
licenseType
|
||||
})
|
||||
}, function(affectedRows)
|
||||
debugPrint("Alte Lizenzen deaktiviert: " .. affectedRows)
|
||||
end)
|
||||
|
||||
-- Neue Lizenz erstellen
|
||||
local success = createLicense(TargetPlayer.PlayerData.citizenid, licenseType, Player.PlayerData.citizenid, classes)
|
||||
|
@ -359,6 +393,8 @@ end)
|
|||
|
||||
RegisterNetEvent('license-system:server:revokeLicense', function(targetId, licenseType)
|
||||
local src = source
|
||||
debugPrint("Event: revokeLicense - Von: " .. src .. ", Für: " .. targetId .. ", Typ: " .. licenseType)
|
||||
|
||||
local Player = QBCore.Functions.GetPlayer(src)
|
||||
local TargetPlayer = QBCore.Functions.GetPlayer(targetId)
|
||||
|
||||
|
@ -374,16 +410,20 @@ RegisterNetEvent('license-system:server:revokeLicense', function(targetId, licen
|
|||
end
|
||||
|
||||
-- Lizenz deaktivieren
|
||||
MySQL.Async.execute('UPDATE player_licenses SET is_active = FALSE WHERE citizenid = ? AND license_type = ? AND is_active = TRUE', {
|
||||
MySQL.Async.execute('UPDATE player_licenses SET is_active = 0 WHERE citizenid = ? AND license_type = ? AND is_active = 1', {
|
||||
TargetPlayer.PlayerData.citizenid,
|
||||
licenseType
|
||||
}, function(affectedRows)
|
||||
if affectedRows > 0 then
|
||||
TriggerClientEvent('QBCore:Notify', src, Config.Notifications.license_revoked.message, Config.Notifications.license_revoked.type)
|
||||
TriggerClientEvent('QBCore:Notify', targetId, 'Deine ' .. (Config.LicenseTypes[licenseType]?.label or licenseType) .. ' wurde entzogen!', 'error')
|
||||
TriggerClientEvent('QBCore:Notify', targetId, 'Deine ' .. (Config.LicenseTypes[licenseType] and Config.LicenseTypes[licenseType].label or licenseType) .. ' wurde entzogen!', 'error')
|
||||
|
||||
-- Log erstellen
|
||||
debugPrint(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' hat ' .. TargetPlayer.PlayerData.charinfo.firstname .. ' ' .. TargetPlayer.PlayerData.charinfo.lastname .. ' die ' .. (Config.LicenseTypes[licenseType]?.label or licenseType) .. ' entzogen')
|
||||
-- Cache aktualisieren
|
||||
if licenseCache[TargetPlayer.PlayerData.citizenid] then
|
||||
licenseCache[TargetPlayer.PlayerData.citizenid][licenseType] = nil
|
||||
end
|
||||
|
||||
debugPrint(Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' hat ' .. TargetPlayer.PlayerData.charinfo.firstname .. ' ' .. TargetPlayer.PlayerData.charinfo.lastname .. ' die ' .. (Config.LicenseTypes[licenseType] and Config.LicenseTypes[licenseType].label or licenseType) .. ' entzogen')
|
||||
else
|
||||
TriggerClientEvent('QBCore:Notify', src, 'Keine aktive Lizenz gefunden!', 'error')
|
||||
end
|
||||
|
@ -392,12 +432,13 @@ end)
|
|||
|
||||
RegisterNetEvent('license-system:server:savePhoto', function(citizenid, photoData)
|
||||
local src = source
|
||||
local Player = QBCore.Functions.GetPlayer(src)
|
||||
debugPrint("Event: savePhoto für CitizenID: " .. citizenid)
|
||||
|
||||
local Player = QBCore.Functions.GetPlayer(src)
|
||||
if not Player then return end
|
||||
|
||||
-- Foto in der Datenbank speichern
|
||||
MySQL.Async.execute('UPDATE player_licenses SET photo_url = ? WHERE citizenid = ? AND is_active = TRUE', {
|
||||
MySQL.Async.execute('UPDATE player_licenses SET photo_url = ? WHERE citizenid = ? AND is_active = 1', {
|
||||
photoData,
|
||||
citizenid
|
||||
}, function(affectedRows)
|
||||
|
@ -420,6 +461,8 @@ QBCore.Commands.Add('givelicense', 'Lizenz an Spieler vergeben', {
|
|||
local licenseType = args[2]
|
||||
local classes = args[3] and {args[3]} or nil
|
||||
|
||||
debugPrint("Admin-Command: givelicense - ID: " .. tostring(targetId) .. ", Typ: " .. tostring(licenseType))
|
||||
|
||||
if not targetId or not licenseType then
|
||||
TriggerClientEvent('QBCore:Notify', source, 'Verwendung: /givelicense [id] [typ] [klassen]', 'error')
|
||||
return
|
||||
|
@ -440,6 +483,8 @@ QBCore.Commands.Add('revokelicense', 'Lizenz entziehen', {
|
|||
local targetId = tonumber(args[1])
|
||||
local licenseType = args[2]
|
||||
|
||||
debugPrint("Admin-Command: revokelicense - ID: " .. tostring(targetId) .. ", Typ: " .. tostring(licenseType))
|
||||
|
||||
if not targetId or not licenseType then
|
||||
TriggerClientEvent('QBCore:Notify', source, 'Verwendung: /revokelicense [id] [typ]', 'error')
|
||||
return
|
||||
|
@ -456,7 +501,7 @@ if Config.Database.auto_cleanup then
|
|||
|
||||
local cutoffDate = os.time() - (Config.Database.cleanup_days * 24 * 60 * 60)
|
||||
|
||||
MySQL.Async.execute('DELETE FROM player_licenses WHERE is_active = FALSE AND created_at < ?', {
|
||||
MySQL.Async.execute('DELETE FROM player_licenses WHERE is_active = 0 AND created_at < ?', {
|
||||
cutoffDate
|
||||
}, function(affectedRows)
|
||||
if affectedRows > 0 then
|
||||
|
@ -472,18 +517,12 @@ CreateThread(function()
|
|||
while true do
|
||||
Wait(60 * 60 * 1000) -- Jede Stunde
|
||||
|
||||
MySQL.Async.fetchAll('SELECT * FROM player_licenses WHERE is_active = TRUE AND expire_date IS NOT NULL', {}, function(result)
|
||||
MySQL.Async.fetchAll('SELECT * FROM player_licenses WHERE is_active = 1 AND expire_date IS NOT NULL', {}, function(result)
|
||||
if result then
|
||||
for _, license in ipairs(result) do
|
||||
local expireTime = os.time({
|
||||
year = tonumber(string.sub(license.expire_date, 7, 10)),
|
||||
month = tonumber(string.sub(license.expire_date, 4, 5)),
|
||||
day = tonumber(string.sub(license.expire_date, 1, 2))
|
||||
})
|
||||
|
||||
if isLicenseExpired(expireTime) then
|
||||
if isLicenseExpired(license.expire_date) then
|
||||
-- Lizenz als abgelaufen markieren
|
||||
MySQL.Async.execute('UPDATE player_licenses SET is_active = FALSE WHERE id = ?', {
|
||||
MySQL.Async.execute('UPDATE player_licenses SET is_active = 0 WHERE id = ?', {
|
||||
license.id
|
||||
})
|
||||
|
||||
|
@ -509,7 +548,7 @@ AddEventHandler('onResourceStart', function(resourceName)
|
|||
issue_date VARCHAR(20) NOT NULL,
|
||||
expire_date VARCHAR(20) NULL,
|
||||
issued_by VARCHAR(50) NULL,
|
||||
is_active BOOLEAN DEFAULT TRUE,
|
||||
is_active TINYINT(1) DEFAULT 1,
|
||||
classes TEXT NULL,
|
||||
photo_url TEXT NULL,
|
||||
notes TEXT NULL,
|
||||
|
@ -519,12 +558,20 @@ AddEventHandler('onResourceStart', function(resourceName)
|
|||
INDEX idx_license_type (license_type),
|
||||
INDEX idx_active (is_active)
|
||||
)
|
||||
]])
|
||||
]], {}, function(success)
|
||||
if success then
|
||||
debugPrint("Datenbank-Tabelle erfolgreich erstellt/überprüft")
|
||||
else
|
||||
debugPrint("^1Fehler beim Erstellen der Datenbank-Tabelle!^7")
|
||||
end
|
||||
end)
|
||||
end
|
||||
end)
|
||||
|
||||
AddEventHandler('onResourceStop', function(resourceName)
|
||||
if GetCurrentResourceName() == resourceName then
|
||||
debugPrint("License-System Server gestoppt")
|
||||
-- Cache leeren
|
||||
licenseCache = {}
|
||||
end
|
||||
end)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue