Files
ND_Core/ND_ShotSpotter/source/server.lua

39 lines
1.7 KiB
Lua
Raw Normal View History

2022-07-08 23:16:36 +02:00
-- For support join my discord: https://discord.gg/Z9Mxu72zZ6
NDCore = exports["ND_Core"]:GetCoreObject()
2022-09-23 20:16:45 +02:00
NDCore.Functions.VersionChecker("ND_ShotSpotter", GetCurrentResourceName(), "https://github.com/ND-Framework/ND_Framework", "https://raw.githubusercontent.com/ND-Framework/ND_Framework/main/ND_ShotSpotter/fxmanifest.lua")
2022-09-01 04:11:48 -04:00
RegisterNetEvent("ND_ShotSpotter:Trigger", function(street, pedCoords, postal, zoneName)
2022-07-08 23:16:36 +02:00
if server_config.useDiscordLogging then
local embed = {
{
title = "ShotSpotter Alert",
description = "Gunshots detected on " .. zoneName .. ", " .. street .. "." ,
fields = {
{
name = "Location:",
value = zoneName .. ", **" .. street .. "**"
}
},
footer = {
icon_url = "https://i.imgur.com/notBtrZ.png",
text = "Created by Andyyy#7666"
},
thumbnail = {
url = "https://i.imgur.com/BTbxJZu.png"
},
color = 16722976
}
}
if postal then
embed[1].description = "Gunshots detected on " .. zoneName .. ", " .. street .. " (" .. postal .. ")."
embed[1].fields[2] = {
name = "Postal:",
value = postal
}
end
PerformHttpRequest(server_config.discordWebhook, function(err, text, headers) end, 'POST', json.encode({username = "ND Shotspotter", embeds = embed}), {["Content-Type"] = "application/json"})
end
TriggerClientEvent("ND_ShotSpotter:Report", -1, street, pedCoords, postal)
2022-09-23 20:16:45 +02:00
end)