Skip to content

Commit

Permalink
dispatch error handling and more faq
Browse files Browse the repository at this point in the history
  • Loading branch information
pushkart2 committed Jul 22, 2022
1 parent 950c9d6 commit a49c866
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 16 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Project Sloth MDT

For all support questions, ask in our Discord support chat. Do not create issues if you need help. Issues are for bug reporting and new features only.
For all support questions, ask in our Discord support chat. Do not create issues if you need help. Issues are for bug reporting and new features only.

https://www.discord.gg/projectsloth

## Dependencies

- [QBCore](https://github.com/qbcore-framework/qb-core)
- [PS-Dispatch](https://github.com/Project-Sloth/ps-dispatch)
- [PS-Dispatch](https://github.com/Project-Sloth/ps-dispatch) [If you intend to use it, make sure this starts before the mdt!]
- [Ox MySQL](https://github.com/overextended/oxmysql)

## FAQ
Expand Down
7 changes: 7 additions & 0 deletions client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ local tabletBone = 60309
local tabletOffset = vector3(0.03, 0.002, -0.0)
local tabletRot = vector3(10.0, 160.0, 0.0)

CreateThread(function()
if GetResourceState('ps-dispatch') == 'started' then
TriggerServerEvent("ps-mdt:dispatchStatus", true)
end
end)


-- Events from qbcore
RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function()
PlayerData = QBCore.Functions.GetPlayerData()
Expand Down
40 changes: 26 additions & 14 deletions server/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ local activeUnits = {}

local impound = {}
local dispatchMessages = {}
local isDispatchRunning = false

local function IsPolice(job)
for k, v in pairs(Config.PoliceJobs) do
Expand All @@ -27,10 +28,10 @@ local function GetActiveData(cid)
return false
end

AddEventHandler("onResourceStart", function(resourceName)
if (resourceName == 'ps-mdt') then
activeUnits = {}
end


RegisterServerEvent("ps-mdt:dispatchStatus", function(bool)
isDispatchRunning = bool
end)

if Config.UseWolfknightRadar == true then
Expand Down Expand Up @@ -105,8 +106,11 @@ RegisterNetEvent('mdt:server:openMDT', function()

local JobType = GetJobType(PlayerData.job.name)
local bulletin = GetBulletins(JobType)

local calls = exports['ps-dispatch']:GetDispatchCalls()
if isDispatchRunning then
local calls = exports['ps-dispatch']:GetDispatchCalls()
else
local calls = {}
end

--TriggerClientEvent('mdt:client:dashboardbulletin', src, bulletin)
TriggerClientEvent('mdt:client:open', src, bulletin, activeUnits, calls, PlayerData.citizenid)
Expand Down Expand Up @@ -1037,8 +1041,10 @@ RegisterNetEvent('mdt:server:setWaypoint', function(callid)
local JobType = GetJobType(Player.PlayerData.job.name)
if JobType == 'police' or JobType == 'ambulance' then
if callid then
local calls = exports['ps-dispatch']:GetDispatchCalls()
TriggerClientEvent('mdt:client:setWaypoint', src, calls[callid])
if isDispatchRunning then
local calls = exports['ps-dispatch']:GetDispatchCalls()
TriggerClientEvent('mdt:client:setWaypoint', src, calls[callid])
end
end
end
end)
Expand Down Expand Up @@ -1088,8 +1094,10 @@ RegisterNetEvent('mdt:server:attachedUnits', function(callid)
local JobType = GetJobType(Player.PlayerData.job.name)
if JobType == 'police' or JobType == 'ambulance' then
if callid then
local calls = exports['ps-dispatch']:GetDispatchCalls()
TriggerClientEvent('mdt:client:attachedUnits', src, calls[callid]['units'], callid)
if isDispatchRunning then
local calls = exports['ps-dispatch']:GetDispatchCalls()
TriggerClientEvent('mdt:client:attachedUnits', src, calls[callid]['units'], callid)
end
end
end
end)
Expand Down Expand Up @@ -1121,8 +1129,10 @@ RegisterNetEvent('mdt:server:setDispatchWaypoint', function(callid, cid)
local JobType = GetJobType(Player.PlayerData.job.name)
if JobType == 'police' or JobType == 'ambulance' then
if callid then
local calls = exports['ps-dispatch']:GetDispatchCalls()
TriggerClientEvent('mdt:client:setWaypoint', src, calls[callid])
if isDispatchRunning then
local calls = exports['ps-dispatch']:GetDispatchCalls()
TriggerClientEvent('mdt:client:setWaypoint', src, calls[callid])
end
end
end

Expand Down Expand Up @@ -1197,8 +1207,10 @@ RegisterNetEvent('mdt:server:getCallResponses', function(callid)
local src = source
local Player = QBCore.Functions.GetPlayer(src)
if IsPolice(Player.PlayerData.job.name) then
local calls = exports['ps-dispatch']:GetDispatchCalls()
TriggerClientEvent('mdt:client:getCallResponses', src, calls[callid]['responses'], callid)
if isDispatchRunning then
local calls = exports['ps-dispatch']:GetDispatchCalls()
TriggerClientEvent('mdt:client:getCallResponses', src, calls[callid]['responses'], callid)
end
end
end)

Expand Down

0 comments on commit a49c866

Please sign in to comment.