mirror of
https://github.com/ND-Framework/ND_Core.git
synced 2026-08-17 05:56:01 +01:00
Add files via upload
This commit is contained in:
63
ND_ShotSpotter/client.lua
Normal file
63
ND_ShotSpotter/client.lua
Normal file
@@ -0,0 +1,63 @@
|
||||
-- For support join my discord: https://discord.gg/Z9Mxu72zZ6
|
||||
|
||||
local isCiv = false
|
||||
local isLEO = false
|
||||
local activateShotSpotter = false
|
||||
local alreadyShot = false
|
||||
|
||||
RegisterNetEvent("ND:shotSpotterReport")
|
||||
AddEventHandler("ND:shotSpotterReport", function(x, y, z, postal)
|
||||
for i = 1, #config.LEODepartments do
|
||||
if exports["ND_Core"]:getCharacterInfo(6) == config.LEODepartments[i] then
|
||||
isLEO = true
|
||||
end
|
||||
end
|
||||
if isLEO and not isCiv then
|
||||
blip = AddBlipForCoord(x, y, z)
|
||||
SetBlipSprite(blip, 161)
|
||||
SetBlipAsShortRange(blip, true)
|
||||
BeginTextCommandSetBlipName("STRING")
|
||||
local street = GetStreetNameFromHashKey(GetStreetNameAtCoord(x, y, z))
|
||||
if not postal then
|
||||
msg = "Shotspotter detected in " .. street .. "."
|
||||
AddTextComponentString("Shot Spotter: " .. street)
|
||||
else
|
||||
msg = "Shotspotter detected in " .. street .. ", postal: " .. postal .. "."
|
||||
AddTextComponentString("Shot Spotter: " .. street .. ", postal: " .. postal)
|
||||
end
|
||||
TriggerEvent("chat:addMessage", {
|
||||
color = {255, 0, 0},
|
||||
args = {"^*Dispatch: ^0", msg}
|
||||
})
|
||||
EndTextCommandSetBlipName(blip)
|
||||
Citizen.Wait(config.shotSpotterTimer * 1000)
|
||||
RemoveBlip(blip)
|
||||
end
|
||||
end)
|
||||
|
||||
Citizen.CreateThread(function()
|
||||
while true do
|
||||
Citizen.Wait(0)
|
||||
local ped = PlayerPedId()
|
||||
if IsPedShooting(ped) then
|
||||
if exports["ND_Core"]:getCharacterInfo(6) == "CIV" then
|
||||
isCiv = true
|
||||
else
|
||||
isCiv = false
|
||||
end
|
||||
if isCiv and not alreadyShot then
|
||||
Citizen.Wait(config.shotSpotterDelay * 1000)
|
||||
pedCoords = GetEntityCoords(ped)
|
||||
if config.shotSpotterUsePostal then
|
||||
postal = exports["nearest_postal123"]:getPostal()
|
||||
else
|
||||
postal = false
|
||||
end
|
||||
TriggerServerEvent("ND:shotSpotterActive", pedCoords.x, pedCoords.y, pedCoords.z, postal)
|
||||
end
|
||||
alreadyShot = true
|
||||
Citizen.Wait(config.shotSpotterCooldown * 1000)
|
||||
alreadyShot = false
|
||||
end
|
||||
end
|
||||
end)
|
||||
15
ND_ShotSpotter/config.lua
Normal file
15
ND_ShotSpotter/config.lua
Normal file
@@ -0,0 +1,15 @@
|
||||
-- For support join my discord: https://discord.gg/Z9Mxu72zZ6
|
||||
|
||||
config = {
|
||||
shotSpotterDelay = 5, -- delay (in seconds) when cops will receive a notification after there has been a shooting.
|
||||
shotSpotterTimer = 25, -- How long should the shot spotter stay on the map.
|
||||
shotSpotterCooldown = 10, -- Cooldown for the next time a player can trigger it again.
|
||||
shotSpotterUsePostal = false, -- if you're using the nearest postal script turn this to true.
|
||||
|
||||
-- This is the departments that will receive the shot spotter.
|
||||
LEODepartments = {
|
||||
"SAHP",
|
||||
"LSPD",
|
||||
"BCSO"
|
||||
}
|
||||
}
|
||||
40
ND_ShotSpotter/server.lua
Normal file
40
ND_ShotSpotter/server.lua
Normal file
@@ -0,0 +1,40 @@
|
||||
-- For support join my discord: https://discord.gg/Z9Mxu72zZ6
|
||||
|
||||
expectedName = "ND_ShotSpotter" -- This is the resource and is not suggested to be changed.
|
||||
resource = GetCurrentResourceName()
|
||||
|
||||
-- check if resource is renamed
|
||||
if resource ~= expectedName then
|
||||
print("^1[^4" .. expectedName .. "^1] WARNING^0")
|
||||
print("Change the resource name to ^4" .. expectedName .. " ^0or else it won't work!")
|
||||
end
|
||||
|
||||
-- check if resource version is up to date
|
||||
PerformHttpRequest("https://raw.githubusercontent.com/Andyyy7666/ND_Framework/main/ND_ShotSpotter/fxmanifest.lua", function(error, res, head)
|
||||
i, j = string.find(tostring(res), "version")
|
||||
res = string.sub(tostring(res), i, j + 6)
|
||||
res = string.gsub(res, "version ", "")
|
||||
res = string.gsub(res, '"', "")
|
||||
resp = tonumber(res)
|
||||
verFile = GetResourceMetadata(expectedName, "version", 0)
|
||||
|
||||
if verFile then
|
||||
if tonumber(verFile) < resp then
|
||||
print("^1[^4" .. expectedName .. "^1] WARNING^0")
|
||||
print("^4" .. expectedName .. " ^0is outdated. Please update it from ^5https://github.com/Andyyy7666/ND_Framework ^0| Current Version: ^1" .. verFile .. " ^0| New Version: ^2" .. resp .. " ^0|")
|
||||
elseif tonumber(verFile) > tonumber(resp) then
|
||||
print("^1[^4" .. expectedName .. "^1] WARNING^0")
|
||||
print("^4" .. expectedName .. "s ^0version number is higher than we expected. | Current Version: ^3" .. verFile .. " ^0| Expected Version: ^2" .. resp .. " ^0|")
|
||||
else
|
||||
print("^4" .. expectedName .. " ^0is up to date | Current Version: ^2" .. verFile .. " ^0|")
|
||||
end
|
||||
else
|
||||
print("^1[^4" .. expectedName .. "^1] WARNING^0")
|
||||
print("You may not have the latest version of ^4" .. expectedName .. "^0. A newer, improved version may be present at ^5https://github.com/Andyyy7666/ND_Framework^0")
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterNetEvent("ND:shotSpotterActive")
|
||||
AddEventHandler("ND:shotSpotterActive", function(x, y, z, postal)
|
||||
TriggerClientEvent("ND:shotSpotterReport", -1, x, y, z, postal)
|
||||
end)
|
||||
Reference in New Issue
Block a user