mirror of
https://github.com/ND-Framework/ND_Core.git
synced 2026-08-17 05:56:01 +01:00
Update client.lua
This commit is contained in:
@@ -4,20 +4,51 @@ local isCiv = false
|
||||
local isLEO = false
|
||||
local activateShotSpotter = false
|
||||
local alreadyShot = false
|
||||
local setRoute = false
|
||||
|
||||
-- Suppressors hash
|
||||
local suppresors = {
|
||||
"0x65EA7EBB", -- Pistol.
|
||||
"0x837445AA", -- Carbine Rifle, Advanced Rifle, Bullpup Rifle, Assault Shotgun, Marksman Rifle.
|
||||
"0xA73D4664", -- .50 Pistol, Micro SMG, Assault SMG, Assault Rifle, Special Carbine, Bullpup Shotgun, Heavy Shotgun, Sniper Rifle.
|
||||
"0xC304849A", -- Combat Pistol, AP Pistol, Heavy Pistol, Vintage Pistol, SMG.
|
||||
"0xE608B35E" -- Pump Shotgun.
|
||||
}
|
||||
|
||||
function notify(message)
|
||||
BeginTextCommandThefeedPost("STRING")
|
||||
AddTextComponentSubstringPlayerName(message)
|
||||
EndTextCommandThefeedPostTicker(0,1)
|
||||
end
|
||||
|
||||
Citizen.CreateThread(function()
|
||||
while true do
|
||||
Citizen.Wait(0)
|
||||
if setRoute then
|
||||
if IsControlJustPressed(0, 113) then
|
||||
if setRoute then
|
||||
SetBlipRoute(blip, true)
|
||||
SetBlipRouteColour(blip, 1)
|
||||
else
|
||||
setRoute = false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
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
|
||||
AddEventHandler("ND:shotSpotterReport", function(pedCoords, postal)
|
||||
if #(GetEntityCoords(PlayerPedId()) - pedCoords) > 10.0 then -- player must be 10.0 away from the shotspotter for it to trigger.
|
||||
if isLEO and not isCiv then
|
||||
blip = AddBlipForCoord(x, y, z)
|
||||
notify("~w~Press ~g~G ~w~to respond to the latest shot spotter.")
|
||||
blip = AddBlipForCoord(pedCoords.x, pedCoords.y, pedCoords.z)
|
||||
setRoute = true
|
||||
SetBlipSprite(blip, 161)
|
||||
SetBlipAsShortRange(blip, true)
|
||||
BeginTextCommandSetBlipName("STRING")
|
||||
local street = GetStreetNameFromHashKey(GetStreetNameAtCoord(x, y, z))
|
||||
SetBlipColour(blip, 1)
|
||||
local street = GetStreetNameFromHashKey(GetStreetNameAtCoord(pedCoords.x, pedCoords.y, pedCoords.z))
|
||||
if not postal then
|
||||
msg = "Shotspotter detected in " .. street .. "."
|
||||
AddTextComponentString("Shot Spotter: " .. street)
|
||||
@@ -27,11 +58,38 @@ AddEventHandler("ND:shotSpotterReport", function(x, y, z, postal)
|
||||
end
|
||||
TriggerEvent("chat:addMessage", {
|
||||
color = {255, 0, 0},
|
||||
args = {"^*Dispatch: ^0", msg}
|
||||
args = {"^*Dispatch ", msg}
|
||||
})
|
||||
EndTextCommandSetBlipName(blip)
|
||||
Citizen.Wait(config.shotSpotterTimer * 1000)
|
||||
RemoveBlip(blip)
|
||||
setRoute = false
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterNetEvent("ND:returnDept")
|
||||
AddEventHandler("ND:returnDept", function(playerDept)
|
||||
if playerDept == "CIV" then
|
||||
isCiv = true
|
||||
isLEO = false
|
||||
else
|
||||
for k, v in pairs(config.LEODepartments) do
|
||||
if playerDept == v then
|
||||
isLEO = true
|
||||
isCiv = false
|
||||
end
|
||||
end
|
||||
end
|
||||
if isCiv and not isLEO then
|
||||
Citizen.Wait(config.shotSpotterDelay * 1000)
|
||||
pedCoords = GetEntityCoords(PlayerPedId())
|
||||
if config.shotSpotterUsePostal then
|
||||
postal = exports["nearest_postal123"]:getPostal()
|
||||
else
|
||||
postal = false
|
||||
end
|
||||
TriggerServerEvent("ND:shotSpotterActive", pedCoords, postal)
|
||||
end
|
||||
end)
|
||||
|
||||
@@ -40,24 +98,69 @@ Citizen.CreateThread(function()
|
||||
Citizen.Wait(0)
|
||||
local ped = PlayerPedId()
|
||||
if IsPedShooting(ped) then
|
||||
if exports["ND_Core"]:getCharacterInfo(6) == "CIV" then
|
||||
isCiv = true
|
||||
else
|
||||
isCiv = false
|
||||
if config.useRealisticShotSpotter then
|
||||
local detected = false
|
||||
for k, v in pairs(config.realisticShotSpotterLocations) do
|
||||
if #(GetEntityCoords(ped) - vector3(v.x, v.y, v.z)) < 450.0 then
|
||||
detected = true
|
||||
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)
|
||||
if detected then
|
||||
local selectedWeapon = GetSelectedPedWeapon(ped)
|
||||
local hasBlackListedWeapon = false
|
||||
local hasSuppressor = false
|
||||
for k, v in pairs(config.weaponBlackList) do
|
||||
if GetHashKey(v) == selectedWeapon then
|
||||
hasBlackListedWeapon = true
|
||||
end
|
||||
end
|
||||
if not hasBlackListedWeapon then
|
||||
for k, v in pairs(suppresors) do
|
||||
if HasPedGotWeaponComponent(ped, selectedWeapon, tonumber(v)) then
|
||||
hasSuppressor = true
|
||||
end
|
||||
end
|
||||
if not hasSuppressor and not alreadyShot then
|
||||
alreadyShot = true
|
||||
TriggerServerEvent("ND:getDept")
|
||||
Citizen.Wait(config.shotSpotterCooldown * 1000)
|
||||
alreadyShot = false
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
local selectedWeapon = GetSelectedPedWeapon(ped)
|
||||
local hasBlackListedWeapon = false
|
||||
local hasSuppressor = false
|
||||
for k, v in pairs(config.weaponBlackList) do
|
||||
if GetHashKey(v) == selectedWeapon then
|
||||
hasBlackListedWeapon = true
|
||||
end
|
||||
end
|
||||
if not hasBlackListedWeapon then
|
||||
for k, v in pairs(suppresors) do
|
||||
if HasPedGotWeaponComponent(ped, selectedWeapon, tonumber(v)) then
|
||||
hasSuppressor = true
|
||||
end
|
||||
end
|
||||
if not hasSuppressor and not alreadyShot then
|
||||
alreadyShot = true
|
||||
TriggerServerEvent("ND:getDept")
|
||||
Citizen.Wait(config.shotSpotterCooldown * 1000)
|
||||
alreadyShot = false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
if config.testing then
|
||||
Citizen.CreateThread(function()
|
||||
Citizen.Wait(1000)
|
||||
for k, v in pairs(config.realisticShotSpotterLocations) do
|
||||
k = AddBlipForRadius(v.x, v.y, v.z, 450.0)
|
||||
SetBlipAlpha(k, 100)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user