forked from Simnation/Main
ed
This commit is contained in:
parent
115d458f52
commit
68f35420ea
3 changed files with 144 additions and 23 deletions
|
@ -1,7 +1,12 @@
|
||||||
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
|
||||||
|
RegisterCommand(Config.Command, function()
|
||||||
local PlayerData = QBCore.Functions.GetPlayerData()
|
local PlayerData = QBCore.Functions.GetPlayerData()
|
||||||
local job = PlayerData.job.name
|
local job = PlayerData.job.name
|
||||||
|
|
||||||
|
@ -23,6 +28,83 @@ RegisterCommand('tracking', function()
|
||||||
|
|
||||||
OpenTrackingMenu()
|
OpenTrackingMenu()
|
||||||
end)
|
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)
|
||||||
|
|
||||||
|
-- Key press detection for tracking locations
|
||||||
|
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)
|
||||||
|
|
||||||
function OpenTrackingMenu()
|
function OpenTrackingMenu()
|
||||||
local options = {
|
local options = {
|
||||||
|
@ -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)
|
||||||
|
|
36
resources/[carscripts]/nordi_tracking/config.lua
Normal file
36
resources/[carscripts]/nordi_tracking/config.lua
Normal 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
|
|
@ -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 {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue