1
0
Fork 0
forked from Simnation/Main
This commit is contained in:
Nordi98 2025-08-05 09:48:15 +02:00
parent 115d458f52
commit 68f35420ea
3 changed files with 144 additions and 23 deletions

View file

@ -1,27 +1,109 @@
local QBCore = exports['qb-core']:GetCoreObject() local QBCore = exports['qb-core']:GetCoreObject()
local activeTrackings = {}
local trackingBlips = {}
local inTrackingZone = false
local currentLocation = nil
-- Tracking Menu öffnen -- Command to open tracking menu (if enabled in config)
RegisterCommand('tracking', function() if Config.EnableCommand then
local PlayerData = QBCore.Functions.GetPlayerData() RegisterCommand(Config.Command, function()
local job = PlayerData.job.name local PlayerData = QBCore.Functions.GetPlayerData()
local job = PlayerData.job.name
-- Überprüfe ob Job berechtigt ist
local allowedJobs = {'police', 'ambulance', 'mechanic'} -- Füge hier weitere Jobs hinzu -- Überprüfe ob Job berechtigt ist
local hasPermission = false local allowedJobs = {'police', 'ambulance', 'mechanic'} -- Füge hier weitere Jobs hinzu
local hasPermission = false
for _, allowedJob in pairs(allowedJobs) do
if job == allowedJob then for _, allowedJob in pairs(allowedJobs) do
hasPermission = true if job == allowedJob then
break hasPermission = true
break
end
end end
if not hasPermission then
QBCore.Functions.Notify('Du hast keine Berechtigung für das Tracking-System!', 'error')
return
end
OpenTrackingMenu()
end)
end
-- Check if player is near a tracking location
CreateThread(function()
while true do
local playerPed = PlayerPedId()
local playerCoords = GetEntityCoords(playerPed)
local sleep = 1000
local isInZone = false
local currentLocationData = nil
for _, location in pairs(Config.TrackingLocations) do
local distance = #(playerCoords - location.coords)
if distance < location.radius then
sleep = 0
isInZone = true
currentLocationData = location
break
end
end
if isInZone and not inTrackingZone then
inTrackingZone = true
currentLocation = currentLocationData
-- Check if player has the required job for this location
local PlayerData = QBCore.Functions.GetPlayerData()
local hasRequiredJob = false
for _, jobName in pairs(currentLocation.job) do
if PlayerData.job.name == jobName then
hasRequiredJob = true
break
end
end
if hasRequiredJob then
-- Show DrawText UI
exports['qb-core']:DrawText(currentLocation.label, 'left')
end
elseif not isInZone and inTrackingZone then
inTrackingZone = false
currentLocation = nil
exports['qb-core']:HideText()
end
Wait(sleep)
end end
end)
if not hasPermission then
QBCore.Functions.Notify('Du hast keine Berechtigung für das Tracking-System!', 'error') -- Key press detection for tracking locations
return CreateThread(function()
while true do
local sleep = 1000
if inTrackingZone and currentLocation then
sleep = 0
-- Check if player has the required job for this location
local PlayerData = QBCore.Functions.GetPlayerData()
local hasRequiredJob = false
for _, jobName in pairs(currentLocation.job) do
if PlayerData.job.name == jobName then
hasRequiredJob = true
break
end
end
if hasRequiredJob and IsControlJustPressed(0, Config.InteractKey) then
exports['qb-core']:HideText()
OpenTrackingMenu()
end
end
Wait(sleep)
end end
OpenTrackingMenu()
end) end)
function OpenTrackingMenu() function OpenTrackingMenu()
@ -86,9 +168,6 @@ function TrackVehicle()
end, plate) end, plate)
end end
local activeTrackings = {}
local trackingBlips = {}
function StartTracking(plate, vehicleData) function StartTracking(plate, vehicleData)
if activeTrackings[plate] then if activeTrackings[plate] then
QBCore.Functions.Notify('Fahrzeug wird bereits getrackt!', 'error') QBCore.Functions.Notify('Fahrzeug wird bereits getrackt!', 'error')
@ -225,5 +304,10 @@ AddEventHandler('onResourceStop', function(resourceName)
for plate, blip in pairs(trackingBlips) do for plate, blip in pairs(trackingBlips) do
RemoveBlip(blip) RemoveBlip(blip)
end end
-- Hide DrawText if active when resource stops
if inTrackingZone then
exports['qb-core']:HideText()
end
end end
end) end)

View file

@ -0,0 +1,36 @@
Config = {}
-- Locations where the tracking system can be accessed
Config.TrackingLocations = {
{
coords = vector3(440.84, -981.14, 30.69), -- LSPD Mission Row
radius = 2.0,
job = {"police"}, -- Only police can access at this location
label = "Polizei Tracking System"
},
{
coords = vector3(309.21, -592.82, 43.28), -- Pillbox Hospital
radius = 2.0,
job = {"ambulance"}, -- Only ambulance can access at this location
label = "Krankenhaus Tracking System"
},
{
coords = vector3(-347.41, -133.08, 39.01), -- LS Customs
radius = 2.0,
job = {"mechanic"}, -- Only mechanics can access at this location
label = "Mechaniker Tracking System"
},
{
coords = vector3(106.11, -1304.49, 28.77), -- Vanilla Unicorn (example for multiple jobs)
radius = 2.0,
job = {"police", "ambulance"}, -- Multiple jobs can access here
label = "VU Tracking System"
}
}
-- Command to open tracking menu (can be disabled by setting to false)
Config.EnableCommand = true
Config.Command = "tracking"
-- Key to press at tracking locations (default is E)
Config.InteractKey = 38 -- E key

View file

@ -7,7 +7,8 @@ version '1.0.0'
shared_scripts { shared_scripts {
'@ox_lib/init.lua', '@ox_lib/init.lua',
'@qb-core/shared/locale.lua' '@qb-core/shared/locale.lua',
'config.lua'
} }
client_scripts { client_scripts {