2025-08-10 17:49:40 +02:00
local QBCore = exports [ ' qb-core ' ] : GetCoreObject ( )
-- Datenbank Setup
CreateThread ( function ( )
MySQL.query ( [ [
CREATE TABLE IF NOT EXISTS infopoint_events (
id INT AUTO_INCREMENT PRIMARY KEY ,
title VARCHAR ( 255 ) NOT NULL ,
description TEXT ,
category VARCHAR ( 100 ) ,
location VARCHAR ( 255 ) ,
event_date DATETIME ,
created_by VARCHAR ( 50 ) ,
created_by_name VARCHAR ( 255 ) ,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ,
active BOOLEAN DEFAULT TRUE
)
] ] )
MySQL.query ( [ [
CREATE TABLE IF NOT EXISTS infopoint_incidents (
id INT AUTO_INCREMENT PRIMARY KEY ,
title VARCHAR ( 255 ) NOT NULL ,
description TEXT ,
category VARCHAR ( 100 ) ,
location VARCHAR ( 255 ) ,
reported_by VARCHAR ( 50 ) ,
reported_by_name VARCHAR ( 255 ) ,
status VARCHAR ( 50 ) DEFAULT ' open ' ,
assigned_to VARCHAR ( 50 ) ,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
)
] ] )
MySQL.query ( [ [
CREATE TABLE IF NOT EXISTS infopoint_job_offers (
id INT AUTO_INCREMENT PRIMARY KEY ,
job_name VARCHAR ( 100 ) ,
title VARCHAR ( 255 ) ,
description TEXT ,
requirements TEXT ,
salary VARCHAR ( 100 ) ,
contact VARCHAR ( 255 ) ,
created_by VARCHAR ( 50 ) ,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ,
active BOOLEAN DEFAULT TRUE
)
] ] )
2025-08-10 18:08:36 +02:00
-- 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
)
] ] )
2025-08-12 19:00:26 +02:00
-- Neue Tabelle für allgemeine Informationen
MySQL.query ( [ [
CREATE TABLE IF NOT EXISTS infopoint_general_info (
id INT AUTO_INCREMENT PRIMARY KEY ,
title VARCHAR ( 255 ) NOT NULL ,
content TEXT ,
category VARCHAR ( 100 ) ,
importance VARCHAR ( 50 ) DEFAULT ' normal ' ,
created_by VARCHAR ( 50 ) ,
created_by_job VARCHAR ( 50 ) ,
created_by_name VARCHAR ( 255 ) ,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ,
expires_at DATETIME NULL ,
active BOOLEAN DEFAULT TRUE
)
] ] )
2025-08-10 18:08:36 +02:00
-- 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 )
2025-08-10 17:49:40 +02:00
end )
-- Events abrufen
QBCore.Functions . CreateCallback ( ' infopoint:getEvents ' , function ( source , cb )
MySQL.query ( ' SELECT * FROM infopoint_events WHERE active = 1 ORDER BY event_date ASC ' , { } , function ( result )
cb ( result )
end )
end )
-- Vorfälle abrufen (nur für berechtigte Jobs)
QBCore.Functions . CreateCallback ( ' infopoint:getIncidents ' , function ( source , cb )
local Player = QBCore.Functions . GetPlayer ( source )
if not Player then return cb ( { } ) end
local job = Player.PlayerData . job.name
2025-08-10 19:55:34 +02:00
if Config.JobPermissions and Config.JobPermissions . jobSpecificInfo and
Config.JobPermissions . jobSpecificInfo [ job ] and
Config.JobPermissions . jobSpecificInfo [ job ] . showIncidents then
2025-08-10 17:49:40 +02:00
MySQL.query ( ' SELECT * FROM infopoint_incidents ORDER BY created_at DESC ' , { } , function ( result )
cb ( result )
end )
else
cb ( { } )
end
end )
-- Job Angebote abrufen
QBCore.Functions . CreateCallback ( ' infopoint:getJobOffers ' , function ( source , cb , jobName )
local query = ' SELECT * FROM infopoint_job_offers WHERE active = 1 '
local params = { }
if jobName then
query = query .. ' AND job_name = ? '
params = { jobName }
end
query = query .. ' ORDER BY created_at DESC '
MySQL.query ( query , params , function ( result )
cb ( result )
end )
end )
-- Lizenz Informationen abrufen
QBCore.Functions . CreateCallback ( ' infopoint:getLicenseInfo ' , function ( source , cb )
2025-08-10 18:08:36 +02:00
MySQL.query ( ' SELECT * FROM infopoint_license_info WHERE active = 1 ORDER BY license_type ASC ' , { } , function ( result )
cb ( result )
end )
end )
2025-08-12 19:00:26 +02:00
-- Allgemeine Informationen abrufen
QBCore.Functions . CreateCallback ( ' infopoint:getGeneralInfo ' , function ( source , cb )
local currentDate = os.date ( ' %Y-%m-%d ' )
MySQL.query ( ' SELECT * FROM infopoint_general_info WHERE active = 1 AND (expires_at IS NULL OR expires_at >= ?) ORDER BY importance DESC, created_at DESC ' , { currentDate } , function ( result )
cb ( result )
end )
end )
2025-08-10 18:08:36 +02:00
-- Prüfen ob Spieler Lizenz-Informationen verwalten kann
QBCore.Functions . CreateCallback ( ' infopoint:canManageLicenses ' , function ( source , cb )
2025-08-10 17:49:40 +02:00
local Player = QBCore.Functions . GetPlayer ( source )
2025-08-10 18:08:36 +02:00
if not Player then return cb ( false ) end
2025-08-10 17:49:40 +02:00
local job = Player.PlayerData . job.name
2025-08-10 18:08:36 +02:00
local canManage = false
2025-08-10 19:55:34 +02:00
-- Sicherheitsprüfung für Config
if Config and Config.JobPermissions and Config.JobPermissions . canManageLicenses then
if type ( Config.JobPermissions . canManageLicenses ) == ' table ' then
for _ , allowedJob in pairs ( Config.JobPermissions . canManageLicenses ) do
if job == allowedJob then
canManage = true
break
end
end
elseif type ( Config.JobPermissions . canManageLicenses ) == ' string ' then
canManage = ( job == Config.JobPermissions . canManageLicenses )
2025-08-10 18:08:36 +02:00
end
2025-08-10 17:49:40 +02:00
end
2025-08-10 18:08:36 +02:00
cb ( canManage )
2025-08-10 17:49:40 +02:00
end )
-- Event erstellen
RegisterNetEvent ( ' infopoint:createEvent ' , function ( eventData )
local src = source
local Player = QBCore.Functions . GetPlayer ( src )
if not Player then return end
local job = Player.PlayerData . job.name
local canCreate = false
2025-08-10 19:55:34 +02:00
-- Sicherheitsprüfung für Config
if Config and Config.JobPermissions and Config.JobPermissions . canCreateEvents then
if type ( Config.JobPermissions . canCreateEvents ) == ' table ' then
for _ , allowedJob in pairs ( Config.JobPermissions . canCreateEvents ) do
if job == allowedJob then
canCreate = true
break
end
end
2025-08-10 17:49:40 +02:00
end
end
if not canCreate then
TriggerClientEvent ( ' QBCore:Notify ' , src , ' Du hast keine Berechtigung Events zu erstellen! ' , ' error ' )
return
end
MySQL.insert ( ' INSERT INTO infopoint_events (title, description, category, location, event_date, created_by, created_by_name) VALUES (?, ?, ?, ?, ?, ?, ?) ' , {
eventData.title ,
eventData.description ,
eventData.category ,
eventData.location ,
eventData.date ,
Player.PlayerData . citizenid ,
Player.PlayerData . charinfo.firstname .. ' ' .. Player.PlayerData . charinfo.lastname
} , function ( insertId )
if insertId then
TriggerClientEvent ( ' QBCore:Notify ' , src , ' Event erfolgreich erstellt! ' , ' success ' )
TriggerClientEvent ( ' infopoint:refreshData ' , - 1 )
end
end )
end )
-- Vorfall melden
RegisterNetEvent ( ' infopoint:reportIncident ' , function ( incidentData )
local src = source
local Player = QBCore.Functions . GetPlayer ( src )
if not Player then return end
MySQL.insert ( ' INSERT INTO infopoint_incidents (title, description, category, location, reported_by, reported_by_name) VALUES (?, ?, ?, ?, ?, ?) ' , {
incidentData.title ,
incidentData.description ,
incidentData.category ,
incidentData.location ,
Player.PlayerData . citizenid ,
Player.PlayerData . charinfo.firstname .. ' ' .. Player.PlayerData . charinfo.lastname
} , function ( insertId )
if insertId then
TriggerClientEvent ( ' QBCore:Notify ' , src , ' Vorfall erfolgreich gemeldet! ' , ' success ' )
-- Benachrichtigung an alle Polizisten senden
local Players = QBCore.Functions . GetQBPlayers ( )
for _ , player in pairs ( Players ) do
if player.PlayerData . job.name == ' police ' and player.PlayerData . job.onduty then
TriggerClientEvent ( ' QBCore:Notify ' , player.PlayerData . source , ' Neuer Vorfall gemeldet: ' .. incidentData.title , ' primary ' )
end
end
end
end )
end )
-- Job Angebot erstellen
RegisterNetEvent ( ' infopoint:createJobOffer ' , function ( jobData )
local src = source
local Player = QBCore.Functions . GetPlayer ( src )
if not Player then return end
local job = Player.PlayerData . job.name
local canCreate = false
2025-08-10 19:55:34 +02:00
-- Sicherheitsprüfung für Config
if Config and Config.JobPermissions and Config.JobPermissions . canCreateEvents then
if type ( Config.JobPermissions . canCreateEvents ) == ' table ' then
for _ , allowedJob in pairs ( Config.JobPermissions . canCreateEvents ) do
if job == allowedJob then
canCreate = true
break
end
end
2025-08-10 17:49:40 +02:00
end
end
if not canCreate then
TriggerClientEvent ( ' QBCore:Notify ' , src , ' Du hast keine Berechtigung Job-Angebote zu erstellen! ' , ' error ' )
return
end
MySQL.insert ( ' INSERT INTO infopoint_job_offers (job_name, title, description, requirements, salary, contact, created_by) VALUES (?, ?, ?, ?, ?, ?, ?) ' , {
job ,
jobData.title ,
jobData.description ,
jobData.requirements ,
jobData.salary ,
jobData.contact ,
Player.PlayerData . citizenid
} , function ( insertId )
if insertId then
TriggerClientEvent ( ' QBCore:Notify ' , src , ' Job-Angebot erfolgreich erstellt! ' , ' success ' )
end
end )
end )
2025-08-10 18:08:36 +02:00
-- 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
2025-08-10 19:55:34 +02:00
-- Sicherheitsprüfung für Config
if Config and Config.JobPermissions and Config.JobPermissions . canManageLicenses then
if type ( Config.JobPermissions . canManageLicenses ) == ' table ' then
for _ , allowedJob in pairs ( Config.JobPermissions . canManageLicenses ) do
if job == allowedJob then
canManage = true
break
end
end
elseif type ( Config.JobPermissions . canManageLicenses ) == ' string ' then
canManage = ( job == Config.JobPermissions . canManageLicenses )
2025-08-10 18:08:36 +02:00
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
2025-08-10 19:55:34 +02:00
-- Sicherheitsprüfung für Config
if Config and Config.JobPermissions and Config.JobPermissions . canManageLicenses then
if type ( Config.JobPermissions . canManageLicenses ) == ' table ' then
for _ , allowedJob in pairs ( Config.JobPermissions . canManageLicenses ) do
if job == allowedJob then
canManage = true
break
end
end
elseif type ( Config.JobPermissions . canManageLicenses ) == ' string ' then
canManage = ( job == Config.JobPermissions . canManageLicenses )
2025-08-10 18:08:36 +02:00
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
2025-08-10 19:55:34 +02:00
-- Sicherheitsprüfung für Config
if Config and Config.JobPermissions and Config.JobPermissions . canManageLicenses then
if type ( Config.JobPermissions . canManageLicenses ) == ' table ' then
for _ , allowedJob in pairs ( Config.JobPermissions . canManageLicenses ) do
if job == allowedJob then
canManage = true
break
end
end
elseif type ( Config.JobPermissions . canManageLicenses ) == ' string ' then
canManage = ( job == Config.JobPermissions . canManageLicenses )
2025-08-10 18:08:36 +02:00
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 )
2025-08-12 19:00:26 +02:00
-- Allgemeine Information erstellen
RegisterNetEvent ( ' infopoint:createGeneralInfo ' , function ( infoData )
local src = source
local Player = QBCore.Functions . GetPlayer ( src )
if not Player then return end
local job = Player.PlayerData . job.name
local canPost = false
-- Sicherheitsprüfung für Config
if Config and Config.JobPermissions and Config.JobPermissions . canPostGeneralInfo then
if type ( Config.JobPermissions . canPostGeneralInfo ) == ' table ' then
for _ , allowedJob in pairs ( Config.JobPermissions . canPostGeneralInfo ) do
if job == allowedJob then
canPost = true
break
end
end
end
end
if not canPost then
TriggerClientEvent ( ' QBCore:Notify ' , src , ' Du hast keine Berechtigung allgemeine Informationen zu veröffentlichen! ' , ' error ' )
return
end
MySQL.insert ( ' INSERT INTO infopoint_general_info (title, content, category, importance, expires_at, created_by, created_by_job, created_by_name) VALUES (?, ?, ?, ?, ?, ?, ?, ?) ' , {
infoData.title ,
infoData.content ,
infoData.category ,
infoData.importance ,
infoData.expires_at ,
Player.PlayerData . citizenid ,
Player.PlayerData . job.name ,
Player.PlayerData . charinfo.firstname .. ' ' .. Player.PlayerData . charinfo.lastname
} , function ( insertId )
if insertId then
TriggerClientEvent ( ' QBCore:Notify ' , src , ' Information erfolgreich veröffentlicht! ' , ' success ' )
TriggerClientEvent ( ' infopoint:refreshData ' , - 1 )
end
end )
end )
-- Allgemeine Information bearbeiten
RegisterNetEvent ( ' infopoint:updateGeneralInfo ' , function ( infoId , infoData )
local src = source
local Player = QBCore.Functions . GetPlayer ( src )
if not Player then return end
-- First check if this player created the info or has permission to post general info
MySQL.query ( ' SELECT created_by FROM infopoint_general_info WHERE id = ? ' , { infoId } , function ( result )
if result [ 1 ] then
local canEdit = false
-- Check if player created this info
if result [ 1 ] . created_by == Player.PlayerData . citizenid then
canEdit = true
end
-- Check if player has permission to post general info (they can also edit)
if not canEdit then
local job = Player.PlayerData . job.name
if Config and Config.JobPermissions and Config.JobPermissions . canPostGeneralInfo then
if type ( Config.JobPermissions . canPostGeneralInfo ) == ' table ' then
for _ , allowedJob in pairs ( Config.JobPermissions . canPostGeneralInfo ) do
if job == allowedJob then
canEdit = true
break
end
end
end
end
end
if not canEdit then
TriggerClientEvent ( ' QBCore:Notify ' , src , ' Du hast keine Berechtigung diese Information zu bearbeiten! ' , ' error ' )
return
end
-- Update the info
MySQL.update ( ' UPDATE infopoint_general_info SET title = ?, content = ?, category = ?, importance = ?, expires_at = ? WHERE id = ? ' , {
infoData.title ,
infoData.content ,
infoData.category ,
infoData.importance ,
infoData.expires_at ,
infoId
} , function ( affectedRows )
if affectedRows > 0 then
TriggerClientEvent ( ' QBCore:Notify ' , src , ' Information erfolgreich aktualisiert! ' , ' success ' )
TriggerClientEvent ( ' infopoint:refreshData ' , - 1 )
else
TriggerClientEvent ( ' QBCore:Notify ' , src , ' Fehler beim Aktualisieren der Information! ' , ' error ' )
end
end )
else
TriggerClientEvent ( ' QBCore:Notify ' , src , ' Information nicht gefunden! ' , ' error ' )
end
end )
end )
-- Allgemeine Information löschen
RegisterNetEvent ( ' infopoint:deleteGeneralInfo ' , function ( infoId )
local src = source
local Player = QBCore.Functions . GetPlayer ( src )
if not Player then return end
-- First check if this player created the info or has permission to post general info
MySQL.query ( ' SELECT created_by FROM infopoint_general_info WHERE id = ? ' , { infoId } , function ( result )
if result [ 1 ] then
local canDelete = false
-- Check if player created this info
if result [ 1 ] . created_by == Player.PlayerData . citizenid then
canDelete = true
end
-- Check if player has permission to post general info (they can also delete)
if not canDelete then
local job = Player.PlayerData . job.name
if Config and Config.JobPermissions and Config.JobPermissions . canPostGeneralInfo then
if type ( Config.JobPermissions . canPostGeneralInfo ) == ' table ' then
for _ , allowedJob in pairs ( Config.JobPermissions . canPostGeneralInfo ) do
if job == allowedJob then
canDelete = true
break
end
end
end
end
end
if not canDelete then
TriggerClientEvent ( ' QBCore:Notify ' , src , ' Du hast keine Berechtigung diese Information zu löschen! ' , ' error ' )
return
end
-- Delete (set inactive) the info
MySQL.update ( ' UPDATE infopoint_general_info SET active = 0 WHERE id = ? ' , { infoId } , function ( affectedRows )
if affectedRows > 0 then
TriggerClientEvent ( ' QBCore:Notify ' , src , ' Information erfolgreich gelöscht! ' , ' success ' )
TriggerClientEvent ( ' infopoint:refreshData ' , - 1 )
else
TriggerClientEvent ( ' QBCore:Notify ' , src , ' Fehler beim Löschen der Information! ' , ' error ' )
end
end )
else
TriggerClientEvent ( ' QBCore:Notify ' , src , ' Information nicht gefunden! ' , ' error ' )
end
end )
end )