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

948 lines
32 KiB
Lua
Raw Permalink Normal View History

2025-08-10 17:49:40 +02:00
local QBCore = exports['qb-core']:GetCoreObject()
local nearInfoPoint = false
local currentInfoPoint = nil
-- Blips erstellen
CreateThread(function()
for _, point in pairs(Config.InfoPoints) do
if point.blip.display then
local blip = AddBlipForCoord(point.coords.x, point.coords.y, point.coords.z)
SetBlipSprite(blip, point.blip.sprite)
SetBlipColour(blip, point.blip.color)
SetBlipScale(blip, point.blip.scale)
SetBlipAsShortRange(blip, true)
BeginTextCommandSetBlipName("STRING")
AddTextComponentString(point.name .. " - Infopoint")
EndTextCommandSetBlipName(blip)
end
end
end)
-- Hauptschleife für Nähe-Erkennung
CreateThread(function()
while true do
local sleep = 1000
local playerPed = PlayerPedId()
local playerCoords = GetEntityCoords(playerPed)
nearInfoPoint = false
currentInfoPoint = nil
for _, point in pairs(Config.InfoPoints) do
local distance = #(playerCoords - point.coords)
if distance < 2.0 then
nearInfoPoint = true
currentInfoPoint = point
sleep = 0
-- Draw Text anzeigen
lib.showTextUI('[E] - Infopoint öffnen\n' .. point.name, {
position = "top-center",
icon = 'info-circle'
})
-- E-Taste abfragen
if IsControlJustPressed(0, 38) then -- E
openInfoPointMenu()
end
break
end
end
if not nearInfoPoint then
lib.hideTextUI()
end
Wait(sleep)
end
end)
-- Infopoint Menü öffnen
function openInfoPointMenu()
local PlayerData = QBCore.Functions.GetPlayerData()
local job = PlayerData.job.name
local jobPermissions = Config.JobPermissions.jobSpecificInfo[job] or {}
local menuOptions = {
{
title = 'Events anzeigen',
description = 'Aktuelle Events und Veranstaltungen',
icon = 'calendar',
onSelect = function()
showEvents()
end
2025-08-12 19:00:26 +02:00
},
{
title = 'Allgemeine Informationen',
description = 'Wichtige Bekanntmachungen und Hinweise',
icon = 'bullhorn',
onSelect = function()
showGeneralInfo()
end
2025-08-10 17:49:40 +02:00
}
}
-- Event erstellen (nur für berechtigte Jobs)
local canCreateEvents = false
for _, allowedJob in pairs(Config.JobPermissions.canCreateEvents) do
if job == allowedJob then
canCreateEvents = true
break
end
end
if canCreateEvents then
table.insert(menuOptions, {
title = 'Event erstellen',
description = 'Neues Event oder Veranstaltung erstellen',
icon = 'plus',
onSelect = function()
createEventDialog()
end
})
table.insert(menuOptions, {
title = 'Job-Angebot erstellen',
description = 'Neues Job-Angebot veröffentlichen',
icon = 'briefcase',
onSelect = function()
createJobOfferDialog()
end
})
end
2025-08-12 19:00:26 +02:00
-- Option to post general information (only for authorized jobs)
local canPostInfo = false
for _, allowedJob in pairs(Config.JobPermissions.canPostGeneralInfo) do
if job == allowedJob then
canPostInfo = true
break
end
end
if canPostInfo then
table.insert(menuOptions, {
title = 'Information veröffentlichen',
description = 'Neue allgemeine Information erstellen',
icon = 'pen',
onSelect = function()
createGeneralInfoDialog()
end
})
end
2025-08-10 17:49:40 +02:00
-- Vorfall melden (für alle oder spezifische Jobs)
if Config.JobPermissions.canReportIncidents == 'all' or
(type(Config.JobPermissions.canReportIncidents) == 'table' and
table.contains(Config.JobPermissions.canReportIncidents, job)) then
table.insert(menuOptions, {
title = 'Vorfall melden',
description = 'Einen Vorfall an die Behörden melden',
icon = 'exclamation-triangle',
onSelect = function()
reportIncidentDialog()
end
})
end
-- Job-spezifische Optionen
if jobPermissions.showIncidents then
table.insert(menuOptions, {
title = 'Vorfälle anzeigen',
description = 'Gemeldete Vorfälle einsehen',
icon = 'list',
onSelect = function()
showIncidents()
end
})
end
if jobPermissions.showJobOffers then
table.insert(menuOptions, {
title = 'Job-Angebote',
description = 'Verfügbare Job-Angebote anzeigen',
icon = 'briefcase',
onSelect = function()
showJobOffers()
end
})
end
if jobPermissions.showLicenseInfo then
table.insert(menuOptions, {
title = 'Lizenz Informationen',
2025-08-10 18:08:36 +02:00
description = jobPermissions.canManageLicenses and 'Lizenz-Informationen anzeigen und verwalten' or 'Informationen zu verfügbaren Lizenzen',
2025-08-10 17:49:40 +02:00
icon = 'id-card',
onSelect = function()
showLicenseInfo()
end
})
end
lib.registerContext({
id = 'infopoint_main',
title = currentInfoPoint.name .. ' - Infopoint',
options = menuOptions
})
lib.showContext('infopoint_main')
end
-- Events anzeigen
function showEvents()
QBCore.Functions.TriggerCallback('infopoint:getEvents', function(events)
local eventOptions = {}
if #events == 0 then
table.insert(eventOptions, {
title = 'Keine Events verfügbar',
description = 'Derzeit sind keine Events geplant',
icon = 'info'
})
else
for _, event in pairs(events) do
2025-08-12 19:24:05 +02:00
local eventDate = formatDate(event.event_date)
2025-08-10 17:49:40 +02:00
table.insert(eventOptions, {
title = event.title,
description = 'Datum: ' .. eventDate .. '\nOrt: ' .. (event.location or 'Nicht angegeben') .. '\nErstellt von: ' .. event.created_by_name,
icon = 'calendar',
onSelect = function()
showEventDetails(event)
end
})
end
end
table.insert(eventOptions, {
title = '← Zurück',
icon = 'arrow-left',
onSelect = function()
openInfoPointMenu()
end
})
lib.registerContext({
id = 'infopoint_events',
title = 'Events & Veranstaltungen',
options = eventOptions
})
lib.showContext('infopoint_events')
end)
end
-- Event Details anzeigen
function showEventDetails(event)
2025-08-12 19:24:05 +02:00
local eventDate = formatDate(event.event_date)
2025-08-10 17:49:40 +02:00
lib.alertDialog({
header = event.title,
content = 'Kategorie: ' .. (event.category or 'Keine') .. '\n\n' ..
'Datum: ' .. eventDate .. '\n\n' ..
'Ort: ' .. (event.location or 'Nicht angegeben') .. '\n\n' ..
'Beschreibung:\n' .. (event.description or 'Keine Beschreibung verfügbar') .. '\n\n' ..
'Erstellt von: ' .. event.created_by_name,
centered = true,
cancel = true
})
end
-- Event erstellen Dialog
function createEventDialog()
2025-08-10 18:08:36 +02:00
local categoryOptions = {}
for _, category in pairs(Config.EventCategories) do
table.insert(categoryOptions, {value = category, label = category})
end
2025-08-10 17:49:40 +02:00
local input = lib.inputDialog('Event erstellen', {
{type = 'input', label = 'Titel', required = true, max = 100},
{type = 'textarea', label = 'Beschreibung', max = 500},
2025-08-10 18:08:36 +02:00
{type = 'select', label = 'Kategorie', options = categoryOptions, required = true},
2025-08-10 17:49:40 +02:00
{type = 'input', label = 'Ort', max = 100},
{type = 'date', label = 'Datum', required = true},
{type = 'time', label = 'Uhrzeit', required = true}
})
if input then
local eventData = {
title = input[1],
description = input[2],
category = input[3],
location = input[4],
date = input[5] .. ' ' .. input[6] .. ':00'
}
TriggerServerEvent('infopoint:createEvent', eventData)
end
end
-- Vorfälle anzeigen
function showIncidents()
QBCore.Functions.TriggerCallback('infopoint:getIncidents', function(incidents)
local incidentOptions = {}
if #incidents == 0 then
table.insert(incidentOptions, {
title = 'Keine Vorfälle',
description = 'Derzeit sind keine Vorfälle gemeldet',
icon = 'info'
})
else
for _, incident in pairs(incidents) do
local statusColor = incident.status == 'open' and '🔴' or '🟢'
2025-08-12 19:24:05 +02:00
local createdDate = formatDate(incident.created_at)
2025-08-10 17:49:40 +02:00
table.insert(incidentOptions, {
title = statusColor .. ' ' .. incident.title,
description = 'Gemeldet: ' .. createdDate .. '\nOrt: ' .. (incident.location or 'Nicht angegeben') .. '\nStatus: ' .. incident.status,
icon = 'exclamation-triangle',
onSelect = function()
showIncidentDetails(incident)
end
})
end
end
table.insert(incidentOptions, {
title = '← Zurück',
icon = 'arrow-left',
onSelect = function()
openInfoPointMenu()
end
})
lib.registerContext({
id = 'infopoint_incidents',
title = 'Gemeldete Vorfälle',
options = incidentOptions
})
lib.showContext('infopoint_incidents')
end)
end
-- Vorfall Details anzeigen
function showIncidentDetails(incident)
2025-08-12 19:24:05 +02:00
local createdDate = formatDate(incident.created_at)
2025-08-10 17:49:40 +02:00
lib.alertDialog({
header = incident.title,
content = 'Kategorie: ' .. (incident.category or 'Keine') .. '\n\n' ..
'Gemeldet am: ' .. createdDate .. '\n\n' ..
'Ort: ' .. (incident.location or 'Nicht angegeben') .. '\n\n' ..
'Status: ' .. incident.status .. '\n\n' ..
'Beschreibung:\n' .. (incident.description or 'Keine Beschreibung verfügbar') .. '\n\n' ..
'Gemeldet von: ' .. incident.reported_by_name,
centered = true,
cancel = true
})
end
-- Vorfall melden Dialog
function reportIncidentDialog()
2025-08-10 18:08:36 +02:00
local categoryOptions = {}
for _, category in pairs(Config.IncidentCategories) do
table.insert(categoryOptions, {value = category, label = category})
end
2025-08-10 17:49:40 +02:00
local input = lib.inputDialog('Vorfall melden', {
{type = 'input', label = 'Titel', required = true, max = 100},
{type = 'textarea', label = 'Beschreibung', required = true, max = 500},
2025-08-10 18:08:36 +02:00
{type = 'select', label = 'Kategorie', options = categoryOptions, required = true},
2025-08-10 17:49:40 +02:00
{type = 'input', label = 'Ort', max = 100}
})
if input then
local incidentData = {
title = input[1],
description = input[2],
category = input[3],
location = input[4]
}
TriggerServerEvent('infopoint:reportIncident', incidentData)
end
end
-- Job-Angebote anzeigen
function showJobOffers()
local PlayerData = QBCore.Functions.GetPlayerData()
local job = PlayerData.job.name
QBCore.Functions.TriggerCallback('infopoint:getJobOffers', function(offers)
local offerOptions = {}
if #offers == 0 then
table.insert(offerOptions, {
title = 'Keine Job-Angebote',
description = 'Derzeit sind keine Job-Angebote verfügbar',
icon = 'info'
})
else
for _, offer in pairs(offers) do
table.insert(offerOptions, {
title = offer.title,
description = 'Job: ' .. offer.job_name .. '\nGehalt: ' .. (offer.salary or 'Verhandelbar') .. '\nKontakt: ' .. (offer.contact or 'Nicht angegeben'),
icon = 'briefcase',
onSelect = function()
showJobOfferDetails(offer)
end
})
end
end
table.insert(offerOptions, {
title = '← Zurück',
icon = 'arrow-left',
onSelect = function()
openInfoPointMenu()
end
})
lib.registerContext({
id = 'infopoint_job_offers',
title = 'Job-Angebote',
options = offerOptions
})
lib.showContext('infopoint_job_offers')
2025-08-10 18:08:36 +02:00
end, job)
2025-08-10 17:49:40 +02:00
end
-- Job-Angebot Details anzeigen
function showJobOfferDetails(offer)
2025-08-12 19:24:05 +02:00
local createdDate = formatDate(offer.created_at)
2025-08-10 18:08:36 +02:00
2025-08-10 17:49:40 +02:00
lib.alertDialog({
header = offer.title,
content = 'Job: ' .. offer.job_name .. '\n\n' ..
'Gehalt: ' .. (offer.salary or 'Verhandelbar') .. '\n\n' ..
'Kontakt: ' .. (offer.contact or 'Nicht angegeben') .. '\n\n' ..
2025-08-10 18:08:36 +02:00
'Erstellt am: ' .. createdDate .. '\n\n' ..
2025-08-10 17:49:40 +02:00
'Anforderungen:\n' .. (offer.requirements or 'Keine besonderen Anforderungen') .. '\n\n' ..
'Beschreibung:\n' .. (offer.description or 'Keine Beschreibung verfügbar'),
centered = true,
cancel = true
})
end
-- Job-Angebot erstellen Dialog
function createJobOfferDialog()
local input = lib.inputDialog('Job-Angebot erstellen', {
{type = 'input', label = 'Titel', required = true, max = 100},
{type = 'textarea', label = 'Beschreibung', max = 500},
{type = 'textarea', label = 'Anforderungen', max = 300},
2025-08-10 18:08:36 +02:00
{type = 'input', label = 'Gehalt', placeholder = 'z.B. $2500/Woche', max = 50},
{type = 'input', label = 'Kontakt', placeholder = 'Telefonnummer oder Name', max = 100}
2025-08-10 17:49:40 +02:00
})
if input then
local jobData = {
title = input[1],
description = input[2],
requirements = input[3],
salary = input[4],
contact = input[5]
}
TriggerServerEvent('infopoint:createJobOffer', jobData)
end
end
-- Lizenz Informationen anzeigen
function showLicenseInfo()
QBCore.Functions.TriggerCallback('infopoint:getLicenseInfo', function(licenses)
2025-08-10 18:08:36 +02:00
QBCore.Functions.TriggerCallback('infopoint:canManageLicenses', function(canManage)
local licenseOptions = {}
if #licenses == 0 then
table.insert(licenseOptions, {
title = 'Keine Lizenz-Informationen verfügbar',
description = 'Derzeit sind keine Lizenz-Informationen hinterlegt',
icon = 'info'
})
else
for _, license in pairs(licenses) do
table.insert(licenseOptions, {
title = license.license_type,
description = 'Preis: ' .. (license.price or 'Nicht angegeben') .. '\nBearbeitungszeit: ' .. (license.processing_time or 'Nicht angegeben'),
icon = 'id-card',
onSelect = function()
showLicenseDetails(license, canManage)
end
})
end
end
-- Management-Optionen für berechtigte Jobs
if canManage then
table.insert(licenseOptions, {
title = ' Neue Lizenz-Information hinzufügen',
description = 'Neue Lizenz-Information erstellen',
icon = 'plus',
onSelect = function()
createLicenseInfoDialog()
end
})
end
2025-08-10 17:49:40 +02:00
table.insert(licenseOptions, {
2025-08-10 18:08:36 +02:00
title = '← Zurück',
icon = 'arrow-left',
onSelect = function()
openInfoPointMenu()
end
2025-08-10 17:49:40 +02:00
})
2025-08-10 18:08:36 +02:00
lib.registerContext({
id = 'infopoint_licenses',
title = 'Lizenz Informationen',
options = licenseOptions
})
lib.showContext('infopoint_licenses')
end)
end)
end
-- Lizenz Details anzeigen
function showLicenseDetails(license, canManage)
local menuOptions = {
{
title = 'Details anzeigen',
description = 'Vollständige Informationen anzeigen',
icon = 'info',
onSelect = function()
lib.alertDialog({
header = license.license_type,
content = 'Preis: ' .. (license.price or 'Nicht angegeben') .. '\n\n' ..
'Bearbeitungszeit: ' .. (license.processing_time or 'Nicht angegeben') .. '\n\n' ..
'Gültigkeitsdauer: ' .. (license.valid_duration or 'Nicht angegeben') .. '\n\n' ..
'Anforderungen:\n' .. (license.requirements or 'Keine Anforderungen angegeben') .. '\n\n' ..
'Beschreibung:\n' .. (license.description or 'Keine Beschreibung verfügbar'),
centered = true,
cancel = true
2025-08-10 17:49:40 +02:00
})
end
2025-08-10 18:08:36 +02:00
}
}
if canManage then
table.insert(menuOptions, {
title = '✏️ Bearbeiten',
description = 'Lizenz-Information bearbeiten',
icon = 'edit',
2025-08-10 17:49:40 +02:00
onSelect = function()
2025-08-10 18:08:36 +02:00
editLicenseInfoDialog(license)
2025-08-10 17:49:40 +02:00
end
})
2025-08-10 18:08:36 +02:00
table.insert(menuOptions, {
title = '🗑️ Löschen',
description = 'Lizenz-Information löschen',
icon = 'trash',
onSelect = function()
lib.alertDialog({
header = 'Lizenz-Information löschen',
content = 'Bist du sicher, dass du die Lizenz-Information für "' .. license.license_type .. '" löschen möchtest?',
centered = true,
cancel = true,
labels = {
cancel = 'Abbrechen',
confirm = 'Löschen'
}
}, function(confirmed)
if confirmed then
TriggerServerEvent('infopoint:deleteLicenseInfo', license.id)
Wait(500)
showLicenseInfo() -- Zurück zur Übersicht
end
end)
end
2025-08-10 17:49:40 +02:00
})
2025-08-10 18:08:36 +02:00
end
table.insert(menuOptions, {
title = '← Zurück',
icon = 'arrow-left',
onSelect = function()
showLicenseInfo()
end
})
lib.registerContext({
id = 'license_details',
title = license.license_type,
options = menuOptions
})
lib.showContext('license_details')
end
-- Lizenz-Information erstellen Dialog
function createLicenseInfoDialog()
local licenseTypeOptions = {}
for _, licenseType in pairs(Config.DefaultLicenseTypes) do
table.insert(licenseTypeOptions, {value = licenseType, label = licenseType})
end
table.insert(licenseTypeOptions, {value = 'custom', label = 'Benutzerdefiniert'})
local input = lib.inputDialog('Lizenz-Information erstellen', {
{type = 'select', label = 'Lizenz-Typ', options = licenseTypeOptions, required = true},
{type = 'input', label = 'Benutzerdefinierter Typ (falls ausgewählt)', max = 100},
{type = 'input', label = 'Preis', placeholder = 'z.B. $500', max = 50},
{type = 'textarea', label = 'Anforderungen', max = 500},
{type = 'textarea', label = 'Beschreibung', max = 500},
{type = 'input', label = 'Bearbeitungszeit', placeholder = 'z.B. 1-2 Werktage', max = 100},
{type = 'input', label = 'Gültigkeitsdauer', placeholder = 'z.B. 5 Jahre', max = 100}
})
if input then
local licenseType = input[1] == 'custom' and input[2] or input[1]
2025-08-10 17:49:40 +02:00
2025-08-10 18:08:36 +02:00
if not licenseType or licenseType == '' then
QBCore.Functions.Notify('Bitte gib einen Lizenz-Typ an!', 'error')
return
end
local licenseData = {
license_type = licenseType,
price = input[3],
requirements = input[4],
description = input[5],
processing_time = input[6],
valid_duration = input[7]
}
TriggerServerEvent('infopoint:createLicenseInfo', licenseData)
Wait(500)
showLicenseInfo() -- Zurück zur Übersicht
end
end
-- Lizenz-Information bearbeiten Dialog
function editLicenseInfoDialog(license)
local licenseTypeOptions = {}
for _, licenseType in pairs(Config.DefaultLicenseTypes) do
table.insert(licenseTypeOptions, {value = licenseType, label = licenseType})
end
table.insert(licenseTypeOptions, {value = 'custom', label = 'Benutzerdefiniert'})
local input = lib.inputDialog('Lizenz-Information bearbeiten', {
{type = 'select', label = 'Lizenz-Typ', options = licenseTypeOptions, required = true, default = license.license_type},
{type = 'input', label = 'Benutzerdefinierter Typ (falls ausgewählt)', max = 100},
{type = 'input', label = 'Preis', placeholder = 'z.B. $500', max = 50, default = license.price},
{type = 'textarea', label = 'Anforderungen', max = 500, default = license.requirements},
{type = 'textarea', label = 'Beschreibung', max = 500, default = license.description},
{type = 'input', label = 'Bearbeitungszeit', placeholder = 'z.B. 1-2 Werktage', max = 100, default = license.processing_time},
{type = 'input', label = 'Gültigkeitsdauer', placeholder = 'z.B. 5 Jahre', max = 100, default = license.valid_duration}
})
if input then
local licenseType = input[1] == 'custom' and input[2] or input[1]
if not licenseType or licenseType == '' then
QBCore.Functions.Notify('Bitte gib einen Lizenz-Typ an!', 'error')
return
end
local licenseData = {
license_type = licenseType,
price = input[3],
requirements = input[4],
description = input[5],
processing_time = input[6],
valid_duration = input[7]
}
TriggerServerEvent('infopoint:updateLicenseInfo', license.id, licenseData)
Wait(500)
showLicenseInfo() -- Zurück zur Übersicht
end
2025-08-10 17:49:40 +02:00
end
2025-08-12 19:00:26 +02:00
-- Show general information
function showGeneralInfo()
QBCore.Functions.TriggerCallback('infopoint:getGeneralInfo', function(infoList)
local infoOptions = {}
if #infoList == 0 then
table.insert(infoOptions, {
title = 'Keine Informationen verfügbar',
description = 'Derzeit sind keine allgemeinen Informationen vorhanden',
icon = 'info'
})
else
for _, info in pairs(infoList) do
local importanceIcon = '📄'
if info.importance == 'high' then
importanceIcon = '🔴'
elseif info.importance == 'medium' then
importanceIcon = '🟠'
end
2025-08-12 19:24:05 +02:00
local createdDate = formatDateOnly(info.created_at)
2025-08-12 19:00:26 +02:00
table.insert(infoOptions, {
title = importanceIcon .. ' ' .. info.title,
description = 'Kategorie: ' .. info.category .. ' | Erstellt: ' .. createdDate,
icon = 'bullhorn',
onSelect = function()
showGeneralInfoDetails(info)
end
})
end
end
table.insert(infoOptions, {
title = '← Zurück',
icon = 'arrow-left',
onSelect = function()
openInfoPointMenu()
end
})
lib.registerContext({
id = 'infopoint_general_info',
title = 'Allgemeine Informationen',
options = infoOptions
})
lib.showContext('infopoint_general_info')
end)
end
-- Show general information details
function showGeneralInfoDetails(info)
local PlayerData = QBCore.Functions.GetPlayerData()
local canManage = false
-- Check if player can manage this info (created by them or has management rights)
if PlayerData.citizenid == info.created_by then
canManage = true
end
-- Check if player has permission to post general info (they can also manage)
local job = PlayerData.job.name
for _, allowedJob in pairs(Config.JobPermissions.canPostGeneralInfo) do
if job == allowedJob then
canManage = true
break
end
end
-- If they can manage, show management options
if canManage then
local options = {
{
title = 'Information anzeigen',
description = 'Details der Information anzeigen',
icon = 'eye',
onSelect = function()
showInfoContent(info)
end
},
{
title = '✏️ Bearbeiten',
description = 'Information bearbeiten',
icon = 'edit',
onSelect = function()
editGeneralInfoDialog(info)
end
},
{
title = '🗑️ Löschen',
description = 'Information löschen',
icon = 'trash',
onSelect = function()
deleteGeneralInfo(info.id)
end
},
{
title = '← Zurück',
icon = 'arrow-left',
onSelect = function()
showGeneralInfo()
end
}
}
lib.registerContext({
id = 'general_info_management',
title = info.title,
options = options
})
lib.showContext('general_info_management')
return
end
-- If they can't manage, just show the content
showInfoContent(info)
end
-- Function to show just the content
function showInfoContent(info)
2025-08-12 19:24:05 +02:00
local createdDate = formatDateOnly(info.created_at)
2025-08-12 19:00:26 +02:00
local expiryInfo = ''
if info.expires_at then
2025-08-12 19:24:05 +02:00
local expiryDate = formatDateOnly(info.expires_at)
2025-08-12 19:00:26 +02:00
expiryInfo = 'Gültig bis: ' .. expiryDate .. '\n\n'
end
local importanceText = 'Normal'
if info.importance == 'high' then
importanceText = 'Hoch'
elseif info.importance == 'medium' then
importanceText = 'Mittel'
end
lib.alertDialog({
header = info.title,
content = 'Kategorie: ' .. info.category .. '\n\n' ..
'Wichtigkeit: ' .. importanceText .. '\n\n' ..
'Erstellt am: ' .. createdDate .. '\n\n' ..
expiryInfo ..
'Inhalt:\n' .. info.content .. '\n\n' ..
'Veröffentlicht von: ' .. info.created_by_name .. ' (' .. info.created_by_job .. ')',
centered = true,
cancel = true
})
end
-- Create general information dialog
function createGeneralInfoDialog()
local categoryOptions = {}
for _, category in pairs(Config.GeneralInfoCategories) do
table.insert(categoryOptions, {value = category, label = category})
end
local importanceOptions = {
{value = 'normal', label = 'Normal'},
{value = 'medium', label = 'Mittel'},
{value = 'high', label = 'Hoch'}
}
local input = lib.inputDialog('Information veröffentlichen', {
{type = 'input', label = 'Titel', required = true, max = 100},
{type = 'textarea', label = 'Inhalt', required = true, max = 1000},
{type = 'select', label = 'Kategorie', options = categoryOptions, required = true},
{type = 'select', label = 'Wichtigkeit', options = importanceOptions, default = 'normal'},
{type = 'date', label = 'Gültig bis (optional)'}
})
if input then
local infoData = {
title = input[1],
content = input[2],
category = input[3],
importance = input[4],
expires_at = input[5] ~= '' and input[5] or nil
}
TriggerServerEvent('infopoint:createGeneralInfo', infoData)
end
end
-- Function to edit general info
function editGeneralInfoDialog(info)
local categoryOptions = {}
for _, category in pairs(Config.GeneralInfoCategories) do
table.insert(categoryOptions, {value = category, label = category})
end
local importanceOptions = {
{value = 'normal', label = 'Normal'},
{value = 'medium', label = 'Mittel'},
{value = 'high', label = 'Hoch'}
}
local expiryDate = nil
if info.expires_at then
expiryDate = string.sub(info.expires_at, 1, 10)
end
local input = lib.inputDialog('Information bearbeiten', {
{type = 'input', label = 'Titel', required = true, max = 100, default = info.title},
{type = 'textarea', label = 'Inhalt', required = true, max = 1000, default = info.content},
{type = 'select', label = 'Kategorie', options = categoryOptions, required = true, default = info.category},
{type = 'select', label = 'Wichtigkeit', options = importanceOptions, default = info.importance},
{type = 'date', label = 'Gültig bis (optional)', default = expiryDate}
})
if input then
local infoData = {
title = input[1],
content = input[2],
category = input[3],
importance = input[4],
expires_at = input[5] ~= '' and input[5] or nil
}
TriggerServerEvent('infopoint:updateGeneralInfo', info.id, infoData)
end
end
-- Function to delete general info
function deleteGeneralInfo(infoId)
lib.alertDialog({
header = 'Information löschen',
content = 'Bist du sicher, dass du diese Information löschen möchtest?',
centered = true,
cancel = true,
labels = {
cancel = 'Abbrechen',
confirm = 'Löschen'
}
}, function(confirmed)
if confirmed then
TriggerServerEvent('infopoint:deleteGeneralInfo', infoId)
Wait(500)
showGeneralInfo() -- Back to overview
end
end)
end
2025-08-12 19:24:05 +02:00
-- Helper function for date formatting without using os.time
function formatDate(dateString)
if not dateString then return 'Kein Datum' end
local year = tonumber(string.sub(dateString, 1, 4))
local month = tonumber(string.sub(dateString, 6, 7))
local day = tonumber(string.sub(dateString, 9, 10))
local hour = tonumber(string.sub(dateString, 12, 13)) or 0
local min = tonumber(string.sub(dateString, 15, 16)) or 0
return string.format('%02d.%02d.%04d %02d:%02d', day, month, year, hour, min)
end
-- Helper function for date formatting without time
function formatDateOnly(dateString)
if not dateString then return 'Kein Datum' end
local year = tonumber(string.sub(dateString, 1, 4))
local month = tonumber(string.sub(dateString, 6, 7))
local day = tonumber(string.sub(dateString, 9, 10))
return string.format('%02d.%02d.%04d', day, month, year)
end
2025-08-10 17:49:40 +02:00
-- Hilfsfunktion für table.contains
function table.contains(table, element)
for _, value in pairs(table) do
if value == element then
return true
end
end
return false
end
2025-08-10 18:08:36 +02:00
-- Event für Daten-Refresh
2025-08-10 17:49:40 +02:00
RegisterNetEvent('infopoint:refreshData', function()
2025-08-10 18:08:36 +02:00
-- Hier könnten wir bei Bedarf Daten neu laden
2025-08-10 17:49:40 +02:00
end)
2025-08-10 18:08:36 +02:00