dispatch.lua
-- ============================================================
-- EXIT FRAGMENTATION β Dispatch Bridge (shared/dispatch.lua)
-- Desteklenen: ps-dispatch | cd_dispatch | linden_outrun |
-- qs-dispatch | qb-dispatch | standalone (alert)
-- ============================================================
-- SADECE CLIENT tarafΔ±nda Γ§alΔ±ΕΔ±r.
-- Dispatch Γ§aΔrΔ±sΔ± server tarafΔ±ndan TriggerClientEvent ile gelir.
if IsDuplicityVersion() then return end -- Sunucu tarafΔ±nda yΓΌkleme
-- βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
-- Aktif dispatch sistemini al (ΓΆnbellek)
-- βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
local _dispatchType = nil
local function GetDispatchSystem()
if _dispatchType then return _dispatchType end
-- Config'den oku
local cfgType = Config and Config.DispatchSystem and Config.DispatchSystem.type or 'auto'
if cfgType ~= 'auto' then
_dispatchType = cfgType
return _dispatchType
end
-- Otomatik algΔ±lama (ΓΆncelik sΔ±rasΔ±yla)
if GetResourceState('ps-dispatch') == 'started' then
_dispatchType = 'ps'
elseif GetResourceState('cd_dispatch') == 'started' then
_dispatchType = 'cd'
elseif GetResourceState('linden_outrun') == 'started' then
_dispatchType = 'linden'
elseif GetResourceState('qs-dispatch') == 'started' then
_dispatchType = 'qs'
elseif GetResourceState('qb-dispatch') == 'started' then
_dispatchType = 'qb'
else
_dispatchType = 'standalone'
end
return _dispatchType
end
-- βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
-- Ana Dispatch Fonksiyonu
-- coords : vector3 β Olay koordinatlarΔ±
-- options : tablo β Ek seΓ§enekler (model, plate, tier...)
-- βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
function ExitDispatch(coords, options)
if not (Config and Config.DispatchEnabled) then return end
-- EΔer options bir sayΔ± gelirse (veh handle), tabloya Γ§evirip plaka/model Γ§ekelim
if type(options) == "number" then
local veh = options
options = {
plate = GetVehicleNumberPlateText(veh),
model = GetDisplayNameFromVehicleModel(GetEntityModel(veh))
}
end
options = options or {}
local system = GetDispatchSystem()
local code = Config.DispatchSystem and Config.DispatchSystem.code or "10-35"
local label = _L("dispatch_vehicle_theft") or (Config.DispatchSystem and Config.DispatchSystem.label) or "AraΓ§ HΔ±rsΔ±zlΔ±ΔΔ±"
local blipId = Config.DispatchSystem and Config.DispatchSystem.blipId or 225
local blipClr = Config.DispatchSystem and Config.DispatchSystem.blipColor or 1
local cooldown = Config.DispatchSystem and Config.DispatchSystem.cooldown or 0
-- Clean & Professional Formatting for Premium HUDs
local tierStr = options.tier and string.upper(tostring(options.tier)) or "D"
local callInfo = string.format("ARAC HIRSIZLIGI (%s SINIFI)", tierStr)
if options.model then
callInfo = callInfo .. string.format(" | MODEL: %s", options.model:upper())
end
if options.plate then
callInfo = callInfo .. string.format(" | PLAKA: %s", options.plate:upper())
end
if options.street then
callInfo = callInfo .. string.format(" | BOLGE: %s", options.street:upper())
end
-- βββ ps-dispatch βββββββββββββββββββββββββββββββββββββββββββ
if system == 'ps' then
local ok = pcall(function()
exports['ps-dispatch']:VehicleStolen({
coords = coords,
description = callInfo:gsub("\n", " | "), -- Better for single line HUDs
radius = 0,
sprite = blipId,
color = blipClr,
scale = 1.0,
length = 3,
sound = "Lose_1st",
sound2 = "GTAO_FM_Events_Soundset",
offset = false,
jobs = { "police", "sheriff" },
vehicle = options.model or nil,
})
end)
-- ONLY fallback if the primary export failed
if not ok then
pcall(function()
exports['ps-dispatch']:CustomAlert({
coords = coords,
message = label,
dispatchCode = code,
description = callInfo,
radius = 0,
sprite = blipId,
color = blipClr,
scale = 1.0,
length = 3,
})
end)
-- If even CustomAlert fails, then hit the server
TriggerServerEvent('police:server:policeAlert', callInfo)
end
elseif system == 'qb' then
local ok = pcall(function()
TriggerServerEvent('qb-dispatch:server:createDispatch', {
type = code,
message = label,
coords = coords,
jobs = { 'police' },
blip = {
sprite = blipId,
color = blipClr,
scale = 1.0,
},
})
end)
if not ok then
TriggerServerEvent('police:server:policeAlert', callInfo)
end
elseif system == 'qs' then
local ok = pcall(function()
exports['qs-dispatch']:createDispatch('police', {
message = callInfo,
coords = coords,
sprite = blipId,
color = blipClr,
scale = 1.0,
flashes = true,
})
end)
if not ok then
TriggerServerEvent('police:server:policeAlert', callInfo)
end
else
-- Standalone fallback
TriggerServerEvent('police:server:policeAlert', callInfo)
TriggerServerEvent('qb-police:server:policeAlert', callInfo)
end
end
-- βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
-- Config.SendDispatch'Δ± override et
-- βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
if Config then
Config.SendDispatch = function(coords, vehicle)
ExitDispatch(coords, vehicle)
end
end