-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.lua
More file actions
61 lines (47 loc) · 2 KB
/
Copy pathclient.lua
File metadata and controls
61 lines (47 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
RegisterCommand('911', function(_, args)
local narrative = table.concat(args, " ") or 'None'
local x, y, z = table.unpack(GetEntityCoords(PlayerPedId(), true))
local streetHash = GetStreetNameAtCoord(x, y, z)
local streetName = GetStreetNameFromHashKey(streetHash)
local zoneName = GetNameOfZone(x, y, z)
local cityName = GetLabelText(zoneName)
local postal = ""
if exports['nearest-postal'] and type(exports['nearest-postal'].getPostal) == "function" then
postal = exports['nearest-postal']:getPostal() or ""
end
local callLocation = "Unknown Location"
if postal ~= "" and streetName ~= "" then
callLocation = postal .. "- " .. streetName
elseif streetName ~= "" then
callLocation = streetName
end
TriggerServerEvent('cc-911:Handle911Call', narrative, callLocation, cityName)
end, false)
TriggerEvent('chat:addSuggestion', '/911', 'Report an incident to emergency services.', {
{ name="description", help="Describe the incident." }
})
RegisterNetEvent('cc-911:CallResponse', function(success, message)
TriggerEvent('chat:addMessage', {
args = {"911 Dispatch", message}
})
end)
RegisterCommand('attach', function(source, args, rawCommand)
local callId = args[1]
if callId == nil then
TriggerEvent('chat:addMessage', { args = { '^1SYSTEM', 'Please provide a call ID.' } })
print("Attach command received, but no call ID provided.")
return
end
print("Attach command received with call ID:", callId)
TriggerServerEvent('cc-911:attachToCall', callId)
end, false)
RegisterCommand('detach', function(source, args, rawCommand)
local callId = args[1]
if callId == nil then
TriggerEvent('chat:addMessage', { args = { '^1SYSTEM', 'Please provide a call ID.' } })
print("Detach command received, but no call ID provided.")
return
end
print("Detach command received with call ID:", callId)
TriggerServerEvent('cc-911:detachFromCall', callId)
end, false)