1
0
Fork 0
forked from Simnation/Main
Main/resources/[tools]/nordi_license/client/main.lua

751 lines
24 KiB
Lua
Raw Normal View History

2025-08-04 06:14:47 +02:00
local QBCore = exports['qb-core']:GetCoreObject()
2025-08-04 07:40:06 +02:00
-- Lokale Variablen
local isMenuOpen = false
local currentTarget = nil
2025-08-04 06:14:47 +02:00
local nearbyPlayers = {}
2025-08-04 08:12:36 +02:00
local isLicenseShowing = false
2025-08-04 06:14:47 +02:00
2025-08-04 07:40:06 +02:00
-- Hilfsfunktionen
local function debugPrint(message)
if Config.Debug then
print("^3[License-System Client] " .. message .. "^7")
end
end
2025-08-04 06:14:47 +02:00
2025-08-04 07:40:06 +02:00
local function safeCallback(cb, ...)
if cb and type(cb) == "function" then
cb(...)
2025-08-04 08:12:36 +02:00
return true
2025-08-04 07:40:06 +02:00
else
2025-08-04 08:12:36 +02:00
debugPrint("^1FEHLER: Callback ist keine Funktion! Typ: " .. type(cb) .. "^7")
return false
2025-08-04 07:40:06 +02:00
end
end
2025-08-04 06:14:47 +02:00
2025-08-04 07:40:06 +02:00
local function showNotification(message, type)
QBCore.Functions.Notify(message, type or 'primary')
end
2025-08-04 06:14:47 +02:00
2025-08-04 07:40:06 +02:00
-- Nearby Players abrufen
local function getNearbyPlayers(radius)
radius = radius or 5.0
local players = {}
2025-08-04 06:14:47 +02:00
local playerPed = PlayerPedId()
local playerCoords = GetEntityCoords(playerPed)
2025-08-04 07:40:06 +02:00
for _, playerId in ipairs(GetActivePlayers()) do
local targetPed = GetPlayerPed(playerId)
if targetPed ~= playerPed then
local targetCoords = GetEntityCoords(targetPed)
local distance = #(playerCoords - targetCoords)
if distance <= radius then
local serverId = GetPlayerServerId(playerId)
local playerName = GetPlayerName(playerId)
2025-08-04 06:14:47 +02:00
2025-08-04 07:40:06 +02:00
table.insert(players, {
id = serverId,
name = playerName,
distance = math.floor(distance * 100) / 100,
ped = targetPed
})
2025-08-04 06:14:47 +02:00
end
end
end
2025-08-04 07:40:06 +02:00
-- Nach Entfernung sortieren
table.sort(players, function(a, b)
return a.distance < b.distance
end)
2025-08-04 08:12:36 +02:00
debugPrint("Gefundene Spieler in der Nähe: " .. #players)
2025-08-04 07:40:06 +02:00
return players
2025-08-04 06:14:47 +02:00
end
2025-08-04 07:40:06 +02:00
-- Berechtigung prüfen
local function hasPermission()
local PlayerData = QBCore.Functions.GetPlayerData()
if not PlayerData or not PlayerData.job then return false end
2025-08-04 06:14:47 +02:00
2025-08-04 08:12:36 +02:00
local hasAuth = Config.AuthorizedJobs[PlayerData.job.name] or false
debugPrint("Berechtigung für Job " .. PlayerData.job.name .. ": " .. tostring(hasAuth))
return hasAuth
2025-08-04 07:40:06 +02:00
end
2025-08-04 06:14:47 +02:00
2025-08-04 07:40:06 +02:00
-- Lizenz anzeigen
local function showLicense(licenseData)
if not licenseData then
showNotification(Config.Notifications.license_not_found.message, Config.Notifications.license_not_found.type)
return
2025-08-04 06:14:47 +02:00
end
2025-08-04 07:40:06 +02:00
debugPrint("Zeige Lizenz: " .. licenseData.license.license_type)
SendNUIMessage({
action = 'showLicense',
data = licenseData
2025-08-04 06:14:47 +02:00
})
2025-08-04 07:40:06 +02:00
SetNuiFocus(true, true)
2025-08-04 08:12:36 +02:00
isLicenseShowing = true
2025-08-04 06:14:47 +02:00
end
2025-08-04 07:40:06 +02:00
-- Lizenz schließen
local function closeLicense()
SendNUIMessage({
action = 'hideLicense'
})
2025-08-04 06:14:47 +02:00
2025-08-04 07:40:06 +02:00
SetNuiFocus(false, false)
2025-08-04 08:12:36 +02:00
isLicenseShowing = false
2025-08-04 07:40:06 +02:00
debugPrint("Lizenz geschlossen")
end
2025-08-04 06:14:47 +02:00
2025-08-04 08:12:36 +02:00
-- Spieler-Lizenz anzeigen
local function showPlayerLicense(targetId)
debugPrint("Rufe Server-Callback auf für Spieler: " .. tostring(targetId))
QBCore.Functions.TriggerCallback('license-system:server:getLicense', function(licenseData)
debugPrint("Callback-Antwort erhalten für Spieler-Lizenz")
if licenseData then
debugPrint("Lizenz-Daten erhalten: " .. licenseData.license.license_type)
showLicense(licenseData)
else
debugPrint("Keine Lizenz-Daten erhalten")
showNotification(Config.Notifications.license_not_found.message, Config.Notifications.license_not_found.type)
end
end, targetId)
end
-- Eigene Lizenz anzeigen
local function showMyLicense(licenseType)
debugPrint("Rufe Server-Callback auf für eigene Lizenz: " .. tostring(licenseType))
QBCore.Functions.TriggerCallback('license-system:server:getMyLicense', function(licenseData)
debugPrint("Eigene Lizenz Callback-Antwort erhalten")
if licenseData then
debugPrint("Eigene Lizenz-Daten erhalten: " .. licenseData.license.license_type)
showLicense(licenseData)
else
debugPrint("Keine eigene Lizenz gefunden")
local config = Config.LicenseTypes[licenseType]
local licenseName = config and config.label or licenseType
showNotification('Du hast keine ' .. licenseName .. '!', 'error')
end
end, licenseType)
end
2025-08-04 07:40:06 +02:00
-- Spieler-Lizenz-Menü
local function openPlayerLicenseMenu(targetId, targetName)
2025-08-04 08:12:36 +02:00
debugPrint("Öffne Lizenz-Menü für Spieler: " .. targetName .. " (ID: " .. targetId .. ")")
2025-08-04 07:40:06 +02:00
QBCore.Functions.TriggerCallback('license-system:server:getPlayerLicenses', function(licenses)
2025-08-04 08:12:36 +02:00
debugPrint("Spieler-Lizenzen Callback-Antwort erhalten, Anzahl: " .. (licenses and #licenses or 0))
2025-08-04 07:40:06 +02:00
local menuOptions = {}
if licenses and #licenses > 0 then
for _, license in ipairs(licenses) do
local licenseConfig = Config.LicenseTypes[license.license_type] or {
label = license.license_type,
2025-08-04 08:12:36 +02:00
icon = 'fas fa-id-card',
color = '#667eea'
2025-08-04 07:40:06 +02:00
}
2025-08-04 08:12:36 +02:00
local statusIcon = license.is_active == 1 and '' or ''
local statusText = license.is_active == 1 and 'Gültig' or 'Ungültig'
2025-08-04 07:40:06 +02:00
local expireText = license.expire_date or 'Unbegrenzt'
table.insert(menuOptions, {
2025-08-04 08:12:36 +02:00
title = licenseConfig.label .. ' ' .. statusIcon,
2025-08-04 07:40:06 +02:00
description = 'Status: ' .. statusText .. ' | Gültig bis: ' .. expireText,
2025-08-04 06:14:47 +02:00
icon = licenseConfig.icon,
onSelect = function()
2025-08-04 07:40:06 +02:00
local licenseData = {
license = license,
config = licenseConfig
}
showLicense(licenseData)
end,
metadata = {
{label = 'Status', value = statusText},
{label = 'Ausgestellt', value = license.issue_date or 'Unbekannt'},
{label = 'Gültig bis', value = expireText},
{label = 'Aussteller', value = license.issued_by_name or 'System'}
}
2025-08-04 06:14:47 +02:00
})
end
2025-08-04 07:40:06 +02:00
else
table.insert(menuOptions, {
title = 'Keine Lizenzen gefunden',
description = 'Dieser Spieler hat keine Lizenzen',
icon = 'fas fa-exclamation-triangle',
disabled = true
})
2025-08-04 08:12:36 +02:00
end
-- Aktionen hinzufügen
table.insert(menuOptions, {
title = '─────────────────',
disabled = true
})
table.insert(menuOptions, {
title = 'Neue Lizenz ausstellen',
description = 'Eine neue Lizenz für diesen Spieler ausstellen',
icon = 'fas fa-plus',
onSelect = function()
openIssueLicenseMenu(targetId, targetName)
end
})
if licenses and #licenses > 0 then
2025-08-04 07:40:06 +02:00
table.insert(menuOptions, {
2025-08-04 08:12:36 +02:00
title = 'Lizenz entziehen',
description = 'Eine bestehende Lizenz entziehen',
icon = 'fas fa-minus',
2025-08-04 07:40:06 +02:00
onSelect = function()
2025-08-04 08:12:36 +02:00
openRevokeLicenseMenu(targetId, targetName, licenses)
2025-08-04 07:40:06 +02:00
end
})
2025-08-04 06:14:47 +02:00
end
2025-08-04 07:40:06 +02:00
table.insert(menuOptions, {
title = '← Zurück',
icon = 'fas fa-arrow-left',
onSelect = function()
openLicenseMenu()
end
})
lib.registerContext({
id = 'player_licenses',
title = 'Lizenzen: ' .. targetName,
options = menuOptions
})
lib.showContext('player_licenses')
end, targetId)
end
2025-08-04 06:14:47 +02:00
2025-08-04 07:40:06 +02:00
-- Lizenz ausstellen Menü
local function openIssueLicenseMenu(targetId, targetName)
2025-08-04 08:12:36 +02:00
debugPrint("Öffne Lizenz-Ausstellungs-Menü für: " .. targetName)
2025-08-04 07:40:06 +02:00
local menuOptions = {}
for licenseType, config in pairs(Config.LicenseTypes) do
2025-08-04 08:12:36 +02:00
local priceText = config.price and (config.price .. ' $') or 'Kostenlos'
local validityText = config.validity_days and (config.validity_days .. ' Tage') or 'Unbegrenzt'
2025-08-04 07:40:06 +02:00
table.insert(menuOptions, {
title = config.label,
description = config.description or 'Keine Beschreibung verfügbar',
icon = config.icon,
onSelect = function()
if licenseType == 'drivers_license' and config.classes then
openDriversLicenseClassMenu(targetId, targetName, licenseType)
else
confirmIssueLicense(targetId, targetName, licenseType, nil)
end
end,
metadata = {
2025-08-04 08:12:36 +02:00
{label = 'Preis', value = priceText},
{label = 'Gültigkeitsdauer', value = validityText}
2025-08-04 07:40:06 +02:00
}
2025-08-04 06:14:47 +02:00
})
end
2025-08-04 07:40:06 +02:00
table.insert(menuOptions, {
title = '← Zurück',
icon = 'fas fa-arrow-left',
onSelect = function()
openPlayerLicenseMenu(targetId, targetName)
end
})
2025-08-04 06:14:47 +02:00
lib.registerContext({
2025-08-04 07:40:06 +02:00
id = 'issue_license',
title = 'Lizenz ausstellen: ' .. targetName,
options = menuOptions
2025-08-04 06:14:47 +02:00
})
2025-08-04 07:40:06 +02:00
lib.showContext('issue_license')
2025-08-04 06:14:47 +02:00
end
2025-08-04 07:40:06 +02:00
-- Führerschein-Klassen Menü
local function openDriversLicenseClassMenu(targetId, targetName, licenseType)
local config = Config.LicenseTypes[licenseType]
local selectedClasses = {}
2025-08-04 06:14:47 +02:00
2025-08-04 07:40:06 +02:00
local function updateMenu()
local menuOptions = {}
2025-08-04 08:12:36 +02:00
if config.classes then
for _, class in ipairs(config.classes) do
local isSelected = false
for _, selected in ipairs(selectedClasses) do
if selected == class then
isSelected = true
break
end
2025-08-04 07:40:06 +02:00
end
2025-08-04 08:12:36 +02:00
local classDescriptions = {
['A'] = 'Motorräder',
['A1'] = 'Leichte Motorräder (bis 125ccm)',
['A2'] = 'Mittlere Motorräder (bis 35kW)',
['B'] = 'PKW (bis 3,5t)',
['BE'] = 'PKW mit Anhänger',
['C'] = 'LKW (über 3,5t)',
['CE'] = 'LKW mit Anhänger',
['D'] = 'Bus (über 8 Personen)',
['DE'] = 'Bus mit Anhänger'
}
table.insert(menuOptions, {
title = 'Klasse ' .. class .. (isSelected and '' or ''),
description = classDescriptions[class] or 'Keine Beschreibung',
icon = isSelected and 'fas fa-check-square' or 'far fa-square',
onSelect = function()
if isSelected then
-- Klasse entfernen
for i, selected in ipairs(selectedClasses) do
if selected == class then
table.remove(selectedClasses, i)
break
end
2025-08-04 07:40:06 +02:00
end
2025-08-04 08:12:36 +02:00
else
-- Klasse hinzufügen
table.insert(selectedClasses, class)
2025-08-04 07:40:06 +02:00
end
2025-08-04 08:12:36 +02:00
updateMenu()
2025-08-04 07:40:06 +02:00
end
2025-08-04 08:12:36 +02:00
})
end
2025-08-04 07:40:06 +02:00
end
table.insert(menuOptions, {
title = '─────────────────',
disabled = true
})
table.insert(menuOptions, {
title = 'Bestätigen (' .. #selectedClasses .. ' Klassen)',
description = 'Führerschein mit ausgewählten Klassen ausstellen',
icon = 'fas fa-check',
disabled = #selectedClasses == 0,
2025-08-04 06:14:47 +02:00
onSelect = function()
2025-08-04 07:40:06 +02:00
confirmIssueLicense(targetId, targetName, licenseType, selectedClasses)
2025-08-04 06:14:47 +02:00
end
})
2025-08-04 07:40:06 +02:00
table.insert(menuOptions, {
title = '← Zurück',
icon = 'fas fa-arrow-left',
onSelect = function()
openIssueLicenseMenu(targetId, targetName)
end
})
lib.registerContext({
id = 'drivers_license_classes',
title = 'Führerschein-Klassen: ' .. targetName,
options = menuOptions
})
lib.showContext('drivers_license_classes')
2025-08-04 06:14:47 +02:00
end
2025-08-04 07:40:06 +02:00
updateMenu()
end
2025-08-04 06:14:47 +02:00
2025-08-04 07:40:06 +02:00
-- Lizenz-Ausstellung bestätigen
local function confirmIssueLicense(targetId, targetName, licenseType, classes)
local config = Config.LicenseTypes[licenseType]
local classText = classes and table.concat(classes, ', ') or 'Keine'
2025-08-04 08:12:36 +02:00
local priceText = config.price and (config.price .. ' $') or 'Kostenlos'
debugPrint("Bestätige Lizenz-Ausstellung: " .. licenseType .. " für " .. targetName)
2025-08-04 07:40:06 +02:00
2025-08-04 06:14:47 +02:00
lib.registerContext({
2025-08-04 07:40:06 +02:00
id = 'confirm_issue_license',
title = 'Lizenz ausstellen bestätigen',
options = {
{
title = 'Spieler: ' .. targetName,
2025-08-04 08:12:36 +02:00
disabled = true,
icon = 'fas fa-user'
2025-08-04 07:40:06 +02:00
},
{
title = 'Lizenztyp: ' .. config.label,
2025-08-04 08:12:36 +02:00
disabled = true,
icon = config.icon
2025-08-04 07:40:06 +02:00
},
{
title = 'Klassen: ' .. classText,
2025-08-04 08:12:36 +02:00
disabled = true,
icon = 'fas fa-list'
2025-08-04 07:40:06 +02:00
},
{
2025-08-04 08:12:36 +02:00
title = 'Kosten: ' .. priceText,
disabled = true,
icon = 'fas fa-dollar-sign'
2025-08-04 07:40:06 +02:00
},
{
title = '─────────────────',
disabled = true
},
{
title = '✅ Bestätigen',
description = 'Lizenz jetzt ausstellen',
icon = 'fas fa-check',
onSelect = function()
2025-08-04 08:12:36 +02:00
debugPrint("Sende Lizenz-Ausstellung an Server...")
2025-08-04 07:40:06 +02:00
TriggerServerEvent('license-system:server:issueLicense', targetId, licenseType, classes)
lib.hideContext()
end
},
{
title = '❌ Abbrechen',
description = 'Vorgang abbrechen',
icon = 'fas fa-times',
onSelect = function()
openIssueLicenseMenu(targetId, targetName)
end
}
}
2025-08-04 06:14:47 +02:00
})
2025-08-04 07:40:06 +02:00
lib.showContext('confirm_issue_license')
2025-08-04 06:14:47 +02:00
end
2025-08-04 07:40:06 +02:00
-- Lizenz entziehen Menü
local function openRevokeLicenseMenu(targetId, targetName, licenses)
2025-08-04 08:12:36 +02:00
debugPrint("Öffne Lizenz-Entziehungs-Menü für: " .. targetName)
2025-08-04 07:40:06 +02:00
local menuOptions = {}
2025-08-04 06:14:47 +02:00
2025-08-04 07:40:06 +02:00
for _, license in ipairs(licenses) do
2025-08-04 08:12:36 +02:00
if license.is_active == 1 then
2025-08-04 07:40:06 +02:00
local config = Config.LicenseTypes[license.license_type] or {
label = license.license_type,
icon = 'fas fa-id-card'
}
table.insert(menuOptions, {
title = config.label,
description = 'Diese Lizenz entziehen',
icon = config.icon,
2025-08-04 06:14:47 +02:00
onSelect = function()
2025-08-04 07:40:06 +02:00
lib.registerContext({
id = 'confirm_revoke_license',
title = 'Lizenz entziehen bestätigen',
options = {
{
title = 'Spieler: ' .. targetName,
2025-08-04 08:12:36 +02:00
disabled = true,
icon = 'fas fa-user'
2025-08-04 07:40:06 +02:00
},
{
title = 'Lizenztyp: ' .. config.label,
2025-08-04 08:12:36 +02:00
disabled = true,
icon = config.icon
2025-08-04 07:40:06 +02:00
},
{
title = '─────────────────',
disabled = true
},
{
title = '✅ Bestätigen',
description = 'Lizenz jetzt entziehen',
icon = 'fas fa-check',
onSelect = function()
2025-08-04 08:12:36 +02:00
debugPrint("Sende Lizenz-Entziehung an Server...")
2025-08-04 07:40:06 +02:00
TriggerServerEvent('license-system:server:revokeLicense', targetId, license.license_type)
lib.hideContext()
end
},
{
title = '❌ Abbrechen',
description = 'Vorgang abbrechen',
icon = 'fas fa-times',
onSelect = function()
openRevokeLicenseMenu(targetId, targetName, licenses)
end
}
}
})
lib.showContext('confirm_revoke_license')
2025-08-04 06:14:47 +02:00
end
})
end
end
2025-08-04 07:40:06 +02:00
if #menuOptions == 0 then
table.insert(menuOptions, {
title = 'Keine aktiven Lizenzen',
description = 'Dieser Spieler hat keine aktiven Lizenzen',
icon = 'fas fa-exclamation-triangle',
disabled = true
})
end
table.insert(menuOptions, {
title = '← Zurück',
icon = 'fas fa-arrow-left',
onSelect = function()
openPlayerLicenseMenu(targetId, targetName)
end
})
2025-08-04 06:14:47 +02:00
lib.registerContext({
2025-08-04 07:40:06 +02:00
id = 'revoke_license',
title = 'Lizenz entziehen: ' .. targetName,
options = menuOptions
2025-08-04 06:14:47 +02:00
})
2025-08-04 07:40:06 +02:00
lib.showContext('revoke_license')
2025-08-04 06:14:47 +02:00
end
2025-08-04 07:40:06 +02:00
-- Hauptmenü für Lizenz-System
local function openLicenseMenu()
2025-08-04 08:12:36 +02:00
debugPrint("Öffne Hauptmenü für Lizenz-System")
2025-08-04 07:40:06 +02:00
if not hasPermission() then
showNotification(Config.Notifications.no_permission.message, Config.Notifications.no_permission.type)
return
end
2025-08-04 06:14:47 +02:00
2025-08-04 07:40:06 +02:00
nearbyPlayers = getNearbyPlayers(5.0)
2025-08-04 06:14:47 +02:00
if #nearbyPlayers == 0 then
2025-08-04 07:40:06 +02:00
showNotification(Config.Notifications.no_players_nearby.message, Config.Notifications.no_players_nearby.type)
2025-08-04 06:14:47 +02:00
return
end
2025-08-04 07:40:06 +02:00
local menuOptions = {}
2025-08-04 06:14:47 +02:00
for _, player in ipairs(nearbyPlayers) do
2025-08-04 07:40:06 +02:00
table.insert(menuOptions, {
2025-08-04 06:14:47 +02:00
title = player.name,
2025-08-04 07:40:06 +02:00
description = 'Entfernung: ' .. player.distance .. 'm',
2025-08-04 06:14:47 +02:00
icon = 'fas fa-user',
onSelect = function()
2025-08-04 07:40:06 +02:00
openPlayerLicenseMenu(player.id, player.name)
2025-08-04 06:14:47 +02:00
end
})
end
2025-08-04 07:40:06 +02:00
2025-08-04 06:14:47 +02:00
lib.registerContext({
2025-08-04 07:40:06 +02:00
id = 'license_nearby_players',
title = 'Spieler in der Nähe (' .. #nearbyPlayers .. ')',
options = menuOptions
2025-08-04 06:14:47 +02:00
})
2025-08-04 07:40:06 +02:00
lib.showContext('license_nearby_players')
2025-08-04 06:14:47 +02:00
end
2025-08-04 07:40:06 +02:00
-- Eigene Lizenzen anzeigen
local function showMyLicenses()
2025-08-04 08:12:36 +02:00
debugPrint("Öffne Menü für eigene Lizenzen")
2025-08-04 07:40:06 +02:00
local menuOptions = {}
for licenseType, config in pairs(Config.LicenseTypes) do
table.insert(menuOptions, {
title = config.label,
description = 'Deine ' .. config.label .. ' anzeigen',
icon = config.icon,
onSelect = function()
2025-08-04 08:12:36 +02:00
showMyLicense(licenseType)
2025-08-04 07:40:06 +02:00
end
2025-08-04 06:14:47 +02:00
})
end
2025-08-04 07:40:06 +02:00
lib.registerContext({
id = 'my_licenses',
title = 'Meine Lizenzen',
options = menuOptions
})
lib.showContext('my_licenses')
2025-08-04 06:14:47 +02:00
end
2025-08-04 07:40:06 +02:00
-- Events
RegisterNetEvent('license-system:client:showLicense', function(targetId)
2025-08-04 08:12:36 +02:00
debugPrint("Event erhalten: showLicense für ID " .. tostring(targetId))
showPlayerLicense(targetId)
2025-08-04 07:40:06 +02:00
end)
2025-08-04 06:14:47 +02:00
2025-08-04 07:40:06 +02:00
RegisterNetEvent('license-system:client:showMyLicense', function(licenseType)
2025-08-04 08:12:36 +02:00
debugPrint("Event erhalten: showMyLicense für Typ " .. tostring(licenseType))
showMyLicense(licenseType)
2025-08-04 07:40:06 +02:00
end)
RegisterNetEvent('license-system:client:openCamera', function()
2025-08-04 08:12:36 +02:00
debugPrint("Event erhalten: openCamera")
2025-08-04 06:14:47 +02:00
SendNUIMessage({
2025-08-04 07:40:06 +02:00
action = 'openCamera'
2025-08-04 06:14:47 +02:00
})
2025-08-04 07:40:06 +02:00
end)
2025-08-04 06:14:47 +02:00
2025-08-04 08:12:36 +02:00
RegisterNetEvent('license-system:client:refreshMenu', function()
debugPrint("Event erhalten: refreshMenu")
if lib.getOpenContextMenu() then
lib.hideContext()
Wait(100)
openLicenseMenu()
end
end)
2025-08-04 06:14:47 +02:00
-- NUI Callbacks
RegisterNUICallback('closeLicense', function(data, cb)
2025-08-04 08:12:36 +02:00
debugPrint("NUI Callback: closeLicense")
2025-08-04 07:40:06 +02:00
closeLicense()
2025-08-04 08:12:36 +02:00
if cb and type(cb) == "function" then
cb('ok')
end
2025-08-04 06:14:47 +02:00
end)
2025-08-04 07:40:06 +02:00
RegisterNUICallback('savePhoto', function(data, cb)
2025-08-04 08:12:36 +02:00
debugPrint("NUI Callback: savePhoto")
2025-08-04 07:40:06 +02:00
if data.photo and data.citizenid then
TriggerServerEvent('license-system:server:savePhoto', data.citizenid, data.photo)
2025-08-04 08:12:36 +02:00
if cb and type(cb) == "function" then
cb('ok')
end
2025-08-04 07:40:06 +02:00
else
2025-08-04 08:12:36 +02:00
debugPrint("^1Fehler: Foto-Daten unvollständig^7")
if cb and type(cb) == "function" then
cb('error')
end
end
end)
RegisterNUICallback('takePicture', function(data, cb)
debugPrint("NUI Callback: takePicture")
-- Hier könnte eine Kamera-Funktion implementiert werden
if cb and type(cb) == "function" then
cb('ok')
2025-08-04 07:40:06 +02:00
end
end)
-- Commands
RegisterCommand(Config.Commands.license.name, function()
2025-08-04 08:12:36 +02:00
debugPrint("Command ausgeführt: " .. Config.Commands.license.name)
2025-08-04 07:40:06 +02:00
openLicenseMenu()
end, Config.Commands.license.restricted)
RegisterCommand(Config.Commands.mylicense.name, function()
2025-08-04 08:12:36 +02:00
debugPrint("Command ausgeführt: " .. Config.Commands.mylicense.name)
2025-08-04 07:40:06 +02:00
showMyLicenses()
end, Config.Commands.mylicense.restricted)
2025-08-04 08:12:36 +02:00
-- Zusätzliche Commands für schnellen Zugriff
RegisterCommand('ausweis', function()
debugPrint("Command ausgeführt: ausweis")
showMyLicense('id_card')
end, false)
RegisterCommand('führerschein', function()
debugPrint("Command ausgeführt: führerschein")
showMyLicense('drivers_license')
end, false)
RegisterCommand('waffenschein', function()
debugPrint("Command ausgeführt: waffenschein")
showMyLicense('weapon_license')
end, false)
RegisterCommand('pass', function()
debugPrint("Command ausgeführt: pass")
showMyLicense('passport')
end, false)
2025-08-04 07:40:06 +02:00
-- Keybinds
if Config.Keybinds.open_license_menu then
RegisterKeyMapping(Config.Commands.license.name, Config.Keybinds.open_license_menu.description, 'keyboard', Config.Keybinds.open_license_menu.key)
2025-08-04 06:14:47 +02:00
end
2025-08-04 06:51:25 +02:00
2025-08-04 07:40:06 +02:00
if Config.Keybinds.show_my_licenses then
RegisterKeyMapping(Config.Commands.mylicense.name, Config.Keybinds.show_my_licenses.description, 'keyboard', Config.Keybinds.show_my_licenses.key)
end
2025-08-04 08:12:36 +02:00
-- ESC-Taste zum Schließen der Lizenz
CreateThread(function()
while true do
Wait(0)
if isLicenseShowing then
if IsControlJustPressed(0, 322) then -- ESC-Taste
closeLicense()
end
else
Wait(500)
end
end
end)
-- Cleanup und Initialisierung
2025-08-04 07:40:06 +02:00
AddEventHandler('onResourceStop', function(resourceName)
if GetCurrentResourceName() == resourceName then
2025-08-04 08:12:36 +02:00
if isLicenseShowing then
2025-08-04 07:40:06 +02:00
closeLicense()
2025-08-04 06:51:25 +02:00
end
2025-08-04 08:12:36 +02:00
if lib.getOpenContextMenu() then
lib.hideContext()
end
2025-08-04 07:40:06 +02:00
debugPrint("License-System Client gestoppt")
2025-08-04 06:51:25 +02:00
end
end)
2025-08-04 08:12:36 +02:00
AddEventHandler('onResourceStart', function(resourceName)
if GetCurrentResourceName() == resourceName then
debugPrint("License-System Client gestartet")
-- Warten bis QBCore geladen ist
while not QBCore do
Wait(100)
end
debugPrint("QBCore erfolgreich geladen")
end
end)
-- Player laden Event
RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function()
debugPrint("Spieler geladen - License-System bereit")
end)
-- Job Update Event
RegisterNetEvent('QBCore:Client:OnJobUpdate', function(JobInfo)
debugPrint("Job aktualisiert: " .. JobInfo.name)
end)
2025-08-04 07:40:06 +02:00
-- Initialisierung
CreateThread(function()
2025-08-04 08:12:36 +02:00
debugPrint("License-System Client Thread gestartet")
-- Warten bis Spieler gespawnt ist
while not NetworkIsPlayerActive(PlayerId()) do
Wait(100)
end
debugPrint("Spieler ist aktiv - System bereit")
2025-08-04 07:40:06 +02:00
end)
2025-08-04 08:12:36 +02:00