1
0
Fork 0
forked from Simnation/Main
This commit is contained in:
Nordi98 2025-08-10 18:08:36 +02:00
parent db8f07a192
commit 4078440633
2 changed files with 426 additions and 44 deletions

View file

@ -46,6 +46,84 @@ CreateThread(function()
active BOOLEAN DEFAULT TRUE
)
]])
-- Neue Tabelle für Lizenz-Informationen
MySQL.query([[
CREATE TABLE IF NOT EXISTS infopoint_license_info (
id INT AUTO_INCREMENT PRIMARY KEY,
license_type VARCHAR(100) NOT NULL,
price VARCHAR(50),
requirements TEXT,
description TEXT,
processing_time VARCHAR(100),
valid_duration VARCHAR(100),
created_by VARCHAR(50),
updated_by VARCHAR(50),
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
active BOOLEAN DEFAULT TRUE
)
]])
-- Standard Lizenz-Informationen einfügen falls nicht vorhanden
MySQL.query('SELECT COUNT(*) as count FROM infopoint_license_info', {}, function(result)
if result[1].count == 0 then
local defaultLicenses = {
{
license_type = 'Führerschein',
price = '$500',
requirements = 'Mindestalter 18 Jahre, Theorieprüfung bestehen, Praktische Prüfung bestehen',
description = 'Berechtigt zum Führen von PKW und leichten Nutzfahrzeugen',
processing_time = '1-2 Werktage',
valid_duration = 'Unbegrenzt'
},
{
license_type = 'Waffenschein',
price = '$2000',
requirements = 'Saubere Akte, Psychologisches Gutachten, Waffenprüfung bestehen, Mindestalter 21 Jahre',
description = 'Berechtigt zum Führen von Schusswaffen',
processing_time = '2-4 Wochen',
valid_duration = '5 Jahre'
},
{
license_type = 'Pilotenschein',
price = '$10000',
requirements = 'Flugstunden nachweisen, Medizinische Untersuchung, Theorieprüfung, Praktische Prüfung',
description = 'Berechtigt zum Führen von Luftfahrzeugen',
processing_time = '4-8 Wochen',
valid_duration = '2 Jahre'
},
{
license_type = 'Motorradführerschein',
price = '$750',
requirements = 'Mindestalter 18 Jahre, Theorieprüfung bestehen, Praktische Prüfung bestehen',
description = 'Berechtigt zum Führen von Motorrädern',
processing_time = '1-2 Werktage',
valid_duration = 'Unbegrenzt'
},
{
license_type = 'Bootslizenz',
price = '$1500',
requirements = 'Mindestalter 16 Jahre, Theorieprüfung bestehen, Praktische Prüfung bestehen',
description = 'Berechtigt zum Führen von Wasserfahrzeugen',
processing_time = '3-5 Werktage',
valid_duration = '10 Jahre'
}
}
for _, license in pairs(defaultLicenses) do
MySQL.insert('INSERT INTO infopoint_license_info (license_type, price, requirements, description, processing_time, valid_duration, created_by) VALUES (?, ?, ?, ?, ?, ?, ?)', {
license.license_type,
license.price,
license.requirements,
license.description,
license.processing_time,
license.valid_duration,
'system'
})
end
end
end)
end)
-- Events abrufen
@ -89,21 +167,27 @@ end)
-- Lizenz Informationen abrufen
QBCore.Functions.CreateCallback('infopoint:getLicenseInfo', function(source, cb)
MySQL.query('SELECT * FROM infopoint_license_info WHERE active = 1 ORDER BY license_type ASC', {}, function(result)
cb(result)
end)
end)
-- Prüfen ob Spieler Lizenz-Informationen verwalten kann
QBCore.Functions.CreateCallback('infopoint:canManageLicenses', function(source, cb)
local Player = QBCore.Functions.GetPlayer(source)
if not Player then return cb({}) end
if not Player then return cb(false) end
local job = Player.PlayerData.job.name
if job == 'police' then
-- Hier könntest du Lizenz-Informationen aus der Datenbank abrufen
local licenseInfo = {
{type = 'Führerschein', price = '$500', requirements = 'Theorieprüfung bestehen'},
{type = 'Waffenschein', price = '$2000', requirements = 'Saubere Akte, Prüfung'},
{type = 'Pilotenschein', price = '$10000', requirements = 'Flugstunden nachweisen'}
}
cb(licenseInfo)
else
cb({})
local canManage = false
for _, allowedJob in pairs(Config.JobPermissions.canManageLicenses) do
if job == allowedJob then
canManage = true
break
end
end
cb(canManage)
end)
-- Event erstellen
@ -206,3 +290,108 @@ RegisterNetEvent('infopoint:createJobOffer', function(jobData)
end
end)
end)
-- Lizenz-Information erstellen
RegisterNetEvent('infopoint:createLicenseInfo', function(licenseData)
local src = source
local Player = QBCore.Functions.GetPlayer(src)
if not Player then return end
local job = Player.PlayerData.job.name
local canManage = false
for _, allowedJob in pairs(Config.JobPermissions.canManageLicenses) do
if job == allowedJob then
canManage = true
break
end
end
if not canManage then
TriggerClientEvent('QBCore:Notify', src, 'Du hast keine Berechtigung Lizenz-Informationen zu verwalten!', 'error')
return
end
MySQL.insert('INSERT INTO infopoint_license_info (license_type, price, requirements, description, processing_time, valid_duration, created_by) VALUES (?, ?, ?, ?, ?, ?, ?)', {
licenseData.license_type,
licenseData.price,
licenseData.requirements,
licenseData.description,
licenseData.processing_time,
licenseData.valid_duration,
Player.PlayerData.citizenid
}, function(insertId)
if insertId then
TriggerClientEvent('QBCore:Notify', src, 'Lizenz-Information erfolgreich erstellt!', 'success')
end
end)
end)
-- Lizenz-Information bearbeiten
RegisterNetEvent('infopoint:updateLicenseInfo', function(licenseId, licenseData)
local src = source
local Player = QBCore.Functions.GetPlayer(src)
if not Player then return end
local job = Player.PlayerData.job.name
local canManage = false
for _, allowedJob in pairs(Config.JobPermissions.canManageLicenses) do
if job == allowedJob then
canManage = true
break
end
end
if not canManage then
TriggerClientEvent('QBCore:Notify', src, 'Du hast keine Berechtigung Lizenz-Informationen zu verwalten!', 'error')
return
end
MySQL.update('UPDATE infopoint_license_info SET license_type = ?, price = ?, requirements = ?, description = ?, processing_time = ?, valid_duration = ?, updated_by = ? WHERE id = ?', {
licenseData.license_type,
licenseData.price,
licenseData.requirements,
licenseData.description,
licenseData.processing_time,
licenseData.valid_duration,
Player.PlayerData.citizenid,
licenseId
}, function(affectedRows)
if affectedRows > 0 then
TriggerClientEvent('QBCore:Notify', src, 'Lizenz-Information erfolgreich aktualisiert!', 'success')
else
TriggerClientEvent('QBCore:Notify', src, 'Fehler beim Aktualisieren der Lizenz-Information!', 'error')
end
end)
end)
-- Lizenz-Information löschen
RegisterNetEvent('infopoint:deleteLicenseInfo', function(licenseId)
local src = source
local Player = QBCore.Functions.GetPlayer(src)
if not Player then return end
local job = Player.PlayerData.job.name
local canManage = false
for _, allowedJob in pairs(Config.JobPermissions.canManageLicenses) do
if job == allowedJob then
canManage = true
break
end
end
if not canManage then
TriggerClientEvent('QBCore:Notify', src, 'Du hast keine Berechtigung Lizenz-Informationen zu verwalten!', 'error')
return
end
MySQL.update('UPDATE infopoint_license_info SET active = 0 WHERE id = ?', {licenseId}, function(affectedRows)
if affectedRows > 0 then
TriggerClientEvent('QBCore:Notify', src, 'Lizenz-Information erfolgreich gelöscht!', 'success')
else
TriggerClientEvent('QBCore:Notify', src, 'Fehler beim Löschen der Lizenz-Information!', 'error')
end
end)
end)