-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 3329f26
Showing
6 changed files
with
105 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# FiveM 911 Script | ||
|
||
911 Script for Community CAD | ||
|
||
## Install | ||
|
||
- Download the Latest Version | ||
- Rename the folder to `cc-911` | ||
- Drag Into your `resources` Folder | ||
- Start `cc-911` | ||
|
||
|
||
## Configuration | ||
|
||
The resource includes one config file to get you up and running! | ||
|
||
### `config.lua` | ||
|
||
- `cadURL`: The URL Of Your CAD - Example https://community.communitycad.app | ||
- `api_key`: Your CAD API Key | ||
- `nearestPostalResourceName`: Name of your Neartest Postal Folder Name | ||
|
||
## Dependencies | ||
|
||
- [`nearest-postal`](https://github.com/DevBlocky/nearest-postal): This resource is required to obtain the nearest postal code. Ensure it is installed and running on your server for the postal code feature to function properly. | ||
|
||
## Usage | ||
|
||
`/911 <description of the incident>` in your chat box |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Config = {} | ||
|
||
Config.nearestPostalResourceName = "nearest-postal" -- Your Nearest Postal Name https://github.com/DevBlocky/nearest-postal | ||
|
||
Config.cadURL = "https://community.communitycad.app" -- Your CAD URL No Trailng / at the end! | ||
|
||
Config.api_key = 'API_KEY' -- Your Community CAD API Key |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
fx_version 'cerulean' | ||
game 'gta5' | ||
|
||
author 'Mxrcy' | ||
description 'Community CAD 911 Script' | ||
version 'v1.0.0' | ||
|
||
|
||
shared_script 'config.lua' | ||
|
||
client_script 'client.lua' | ||
|
||
server_script 'server.lua' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
RegisterNetEvent('cc-911:Handle911Call', function(narrative, callLocation, cityName) | ||
local source = source | ||
local data = { | ||
narrative = narrative, | ||
location = callLocation, | ||
city = cityName, | ||
} | ||
|
||
PerformHttpRequest(Config.cadURL .. "/api/v1/fivem/civilian/create_call", function(err, text, headers) | ||
if err == 200 then | ||
print("911 Call processed successfully.") | ||
TriggerClientEvent('cc-911:CallResponse', source, true, "Your 911 call has been received! The authorities are on their way!") | ||
else | ||
print("Error processing 911 call. Error code:", err) | ||
TriggerClientEvent('cc-911:CallResponse', source, false, "There was a problem with your 911 call. Please try again.") | ||
end | ||
end, 'POST', json.encode(data), { | ||
["Content-Type"] = "application/json", | ||
['token'] = Config.api_key | ||
}) | ||
end) |