263 lines
8.0 KiB
Lua
263 lines
8.0 KiB
Lua
--[[
|
|
Imperial Export for FiveM
|
|
DO NOT EDIT THIS FILE UNLESS YOU KNOW WHAT YOUR DOING!
|
|
]]--
|
|
|
|
local callTimer = 0
|
|
local blips = {}
|
|
local isPanic = false
|
|
|
|
Citizen.CreateThread(function()
|
|
while true do
|
|
Citizen.Wait(1000)
|
|
if callTimer > 0 then
|
|
callTimer = callTimer - 1
|
|
end
|
|
end
|
|
end)
|
|
|
|
if Config.Allow911Command then
|
|
TriggerEvent('chat:addSuggestion', '/911', 'Call Emergency Services', {
|
|
{ name = "Information", help = "Description of your call." }
|
|
})
|
|
|
|
RegisterCommand('911', function(source, args)
|
|
local message = table.concat(args, " ")
|
|
local playerPed = PlayerPedId()
|
|
local coords = GetEntityCoords(playerPed)
|
|
local streetHash, crossStreetHash = GetStreetNameAtCoord(coords.x, coords.y, coords.z)
|
|
|
|
local name = exports["ImperialCAD"]:GetStoredName()
|
|
|
|
if name == nil or name == "" then
|
|
name = GetPlayerName(PlayerId())
|
|
end
|
|
|
|
if message == nil or message == "" then
|
|
Notify("You need to include the ~o~call information ~w~first before calling ~r~Emergency Services.")
|
|
return
|
|
end
|
|
|
|
if callTimer > 0 then
|
|
Notify("You must wait ~o~" .. callTimer .. " seconds ~w~before calling ~r~emergency services ~w~again.")
|
|
return
|
|
end
|
|
|
|
local callData = {
|
|
name = name,
|
|
street = GetStreetNameFromHashKey(streetHash),
|
|
crossStreet = GetStreetNameFromHashKey(crossStreetHash) or "N/A",
|
|
postal = GetImperialPostal(),
|
|
city = GetImperialCity(),
|
|
county = GetImperialCounty(),
|
|
info = message,
|
|
coords = coords
|
|
}
|
|
|
|
TriggerServerEvent('ImperialCAD:New911', callData)
|
|
|
|
end, false)
|
|
|
|
TriggerEvent('chat:addSuggestion', '/a911', 'Call Emergency Services but Anonymously', {
|
|
{ name = "Information", help = "Description of your call." }
|
|
})
|
|
|
|
RegisterCommand('a911', function(source, args)
|
|
local message = table.concat(args, " ")
|
|
local playerPed = PlayerPedId()
|
|
local coords = GetEntityCoords(playerPed)
|
|
local streetHash, crossStreetHash = GetStreetNameAtCoord(coords.x, coords.y, coords.z)
|
|
|
|
if message == nil or message == "" then
|
|
Notify("You need to include the ~o~call information ~w~first before calling ~r~Emergency Services.")
|
|
return
|
|
end
|
|
|
|
if callTimer > 0 then
|
|
Notify("You must wait ~o~" .. callTimer .. " seconds ~w~before calling ~r~emergency services ~w~again.")
|
|
return
|
|
end
|
|
|
|
local callData = {
|
|
name = "Anonymous Caller",
|
|
street = GetStreetNameFromHashKey(streetHash),
|
|
crossStreet = GetStreetNameFromHashKey(crossStreetHash) or "N/A",
|
|
postal = GetImperialPostal(),
|
|
city = GetImperialCity(),
|
|
county = GetImperialCounty(),
|
|
info = message,
|
|
coords = coords
|
|
}
|
|
|
|
TriggerServerEvent('ImperialCAD:New911', callData)
|
|
|
|
end, false)
|
|
|
|
end
|
|
|
|
if Config.PlateThroughChat then
|
|
|
|
TriggerEvent('chat:addSuggestion', '/rplate', 'Run vehicle plate', {
|
|
{ name = "plate", help = "the plate to search" }
|
|
})
|
|
|
|
RegisterCommand('rplate', function(source, args, rawCommand)
|
|
local plate = table.concat(args, " ")
|
|
|
|
if plate == nil or plate == "" then
|
|
print('plate not in command')
|
|
TriggerEvent('ox_lib:alertDialog', {
|
|
header = "No Last Idea",
|
|
content = "There is no last idea stored.",
|
|
centered = true,
|
|
cancel = false,
|
|
size = 'md'
|
|
})
|
|
return
|
|
end
|
|
|
|
local callData = {
|
|
plate = plate
|
|
}
|
|
|
|
if Config.debug then
|
|
print("[Rplate] Sending a plate check to the server side.")
|
|
end
|
|
|
|
TriggerServerEvent('ImperialCAD:CheckPlate', callData)
|
|
print("[Rplate] Sent a plate check to the server side.")
|
|
end, false)
|
|
end
|
|
|
|
RegisterCommand('panic', function()
|
|
|
|
local playerPed = PlayerPedId()
|
|
local coords = GetEntityCoords(playerPed)
|
|
local streetHash, crossStreetHash = GetStreetNameAtCoord(coords.x, coords.y, coords.z)
|
|
|
|
local callData = {
|
|
postal = GetImperialPostal(),
|
|
street = GetStreetNameFromHashKey(streetHash)
|
|
}
|
|
|
|
if isPanic then
|
|
isPanic = false
|
|
|
|
print("[Imperial-Panic] Clearing panic, Panic was true")
|
|
|
|
TriggerServerEvent('ImperialCAD:ClearPanic', callData)
|
|
else
|
|
isPanic = true
|
|
|
|
print("[Imperial-Panic] Triggering panic, Panic was false")
|
|
|
|
TriggerServerEvent('ImperialCAD:Panic', callData)
|
|
end
|
|
end, false)
|
|
|
|
if Config.TsThroughChat then
|
|
|
|
TriggerEvent('chat:addSuggestion', '/ts', 'Create a traffic stop in ImperialCAD', {
|
|
{ name = "Information", help = "Description of your traffic stop." }
|
|
})
|
|
|
|
RegisterCommand('ts', function(source, args, rawCommand)
|
|
local message = table.concat(args, " ")
|
|
local playerPed = PlayerPedId()
|
|
local coords = GetEntityCoords(playerPed)
|
|
local streetHash, crossStreetHash = GetStreetNameAtCoord(coords.x, coords.y, coords.z)
|
|
|
|
|
|
if message == "" then
|
|
message = "Traffic Stop Initiated"
|
|
end
|
|
|
|
local callData = {
|
|
street = GetStreetNameFromHashKey(streetHash),
|
|
cross_street = GetStreetNameFromHashKey(crossStreetHash),
|
|
postal = GetImperialPostal(),
|
|
city = GetImperialCity(),
|
|
county = GetImperialCounty(),
|
|
info = message
|
|
}
|
|
|
|
TriggerServerEvent('ImperialCAD:TrafficStop', callData)
|
|
end, false)
|
|
end
|
|
|
|
if Config.AttachThroughChat then
|
|
TriggerEvent('chat:addSuggestion', '/attach', 'Attach to a ImperialCAD call', {
|
|
{ name = "callnum", help = "Call number to attach" }
|
|
})
|
|
|
|
RegisterCommand('attach', function(source, args, rawCommand)
|
|
local message = args[1]
|
|
|
|
local callData = {
|
|
callnum = message
|
|
}
|
|
|
|
TriggerServerEvent('ImperialCAD:AttachCall', callData)
|
|
end, false)
|
|
end
|
|
|
|
RegisterNetEvent("ImperialCAD:Client:Notify")
|
|
AddEventHandler("ImperialCAD:Client:Notify", function(messages)
|
|
Notify(messages)
|
|
end)
|
|
|
|
function Notify(message)
|
|
local fullMessage = "[IMPERIAL] " .. message
|
|
BeginTextCommandThefeedPost("STRING");
|
|
AddTextComponentSubstringPlayerName(fullMessage);
|
|
EndTextCommandThefeedPostMessagetext("CHAR_CALL911", "CHAR_CALL911", true, 1, "Imperial911", "Emergency Services");
|
|
end
|
|
|
|
RegisterNetEvent("Imperial:911BlipForOnduty")
|
|
AddEventHandler("Imperial:911BlipForOnduty", function(coords)
|
|
local name = GetPlayerName(PlayerId())
|
|
local blipId = math.random(100000, 999999)
|
|
local offsetX = math.random(-50, 50)
|
|
local offsetY = math.random(-50, 50)
|
|
|
|
local newX = coords.x + offsetX
|
|
local newY = coords.y + offsetY
|
|
|
|
local radiusBlip = AddBlipForRadius(newX, newY, coords.z, 500.0)
|
|
SetBlipHighDetail(radiusBlip, true)
|
|
SetBlipColour(radiusBlip, 1)
|
|
SetBlipAlpha(radiusBlip, 128)
|
|
SetBlipSprite(radiusBlip, 3)
|
|
|
|
local coordBlip = AddBlipForCoord(newX, newY, coords.z)
|
|
SetBlipSprite(coordBlip, 2)
|
|
SetBlipDisplay(coordBlip, 2)
|
|
SetBlipScale(coordBlip, 0.8)
|
|
SetBlipColour(coordBlip, 1)
|
|
SetBlipAsShortRange(coordBlip, true)
|
|
|
|
BeginTextCommandSetBlipName("STRING")
|
|
AddTextComponentString("911 - " .. name )
|
|
EndTextCommandSetBlipName(coordBlip)
|
|
|
|
blips[blipId] = {radiusBlip = radiusBlip, coordBlip = coordBlip, x = newX, y = newY, z = coords.z}
|
|
|
|
Citizen.CreateThread(function()
|
|
Citizen.Wait(Config.callBlipDuration * 60000)
|
|
if blips[blipId] then
|
|
if blips[blipId].radiusBlip then RemoveBlip(blips[blipId].radiusBlip) end
|
|
if blips[blipId].coordBlip then RemoveBlip(blips[blipId].coordBlip) end
|
|
blips[blipId] = nil
|
|
if Config.debug then print("Blip ID " .. blipId .. " has been automatically removed after 5 minutes.") end
|
|
end
|
|
end)
|
|
end)
|
|
|
|
lib.callback.register('ImperialCAD:getNearestStreets', function(coords)
|
|
local streetHash, crossStreetHash = GetStreetNameAtCoord(coords.x, coords.y, coords.z)
|
|
local street = GetStreetNameFromHashKey(streetHash)
|
|
local crossStreet = GetStreetNameFromHashKey(crossStreetHash)
|
|
local response = {street = street, crossStreet = crossStreet}
|
|
return response
|
|
end)
|