Update client.lua

This commit is contained in:
Andyyy7666
2021-12-31 02:49:20 +01:00
committed by GitHub
parent 0ff92d87d2
commit 8ca2948550

View File

@@ -4,34 +4,92 @@ local isCiv = false
local isLEO = false local isLEO = false
local activateShotSpotter = false local activateShotSpotter = false
local alreadyShot = false local alreadyShot = false
local setRoute = false
RegisterNetEvent("ND:shotSpotterReport") -- Suppressors hash
AddEventHandler("ND:shotSpotterReport", function(x, y, z, postal) local suppresors = {
for i = 1, #config.LEODepartments do "0x65EA7EBB", -- Pistol.
if exports["ND_Core"]:getCharacterInfo(6) == config.LEODepartments[i] then "0x837445AA", -- Carbine Rifle, Advanced Rifle, Bullpup Rifle, Assault Shotgun, Marksman Rifle.
isLEO = true "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 end
if isLEO and not isCiv then end)
blip = AddBlipForCoord(x, y, z)
SetBlipSprite(blip, 161) RegisterNetEvent("ND:shotSpotterReport")
SetBlipAsShortRange(blip, true) AddEventHandler("ND:shotSpotterReport", function(pedCoords, postal)
BeginTextCommandSetBlipName("STRING") if #(GetEntityCoords(PlayerPedId()) - pedCoords) > 10.0 then -- player must be 10.0 away from the shotspotter for it to trigger.
local street = GetStreetNameFromHashKey(GetStreetNameAtCoord(x, y, z)) if isLEO and not isCiv then
if not postal then notify("~w~Press ~g~G ~w~to respond to the latest shot spotter.")
msg = "Shotspotter detected in " .. street .. "." blip = AddBlipForCoord(pedCoords.x, pedCoords.y, pedCoords.z)
AddTextComponentString("Shot Spotter: " .. street) setRoute = true
else SetBlipSprite(blip, 161)
msg = "Shotspotter detected in " .. street .. ", postal: " .. postal .. "." SetBlipAsShortRange(blip, true)
AddTextComponentString("Shot Spotter: " .. street .. ", postal: " .. postal) BeginTextCommandSetBlipName("STRING")
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)
else
msg = "Shotspotter detected in " .. street .. ", postal: " .. postal .. "."
AddTextComponentString("Shot Spotter: " .. street .. ", postal: " .. postal)
end
TriggerEvent("chat:addMessage", {
color = {255, 0, 0},
args = {"^*Dispatch ", msg}
})
EndTextCommandSetBlipName(blip)
Citizen.Wait(config.shotSpotterTimer * 1000)
RemoveBlip(blip)
setRoute = false
end end
TriggerEvent("chat:addMessage", { end
color = {255, 0, 0}, end)
args = {"^*Dispatch: ^0", msg}
}) RegisterNetEvent("ND:returnDept")
EndTextCommandSetBlipName(blip) AddEventHandler("ND:returnDept", function(playerDept)
Citizen.Wait(config.shotSpotterTimer * 1000) if playerDept == "CIV" then
RemoveBlip(blip) 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
end) end)
@@ -40,24 +98,69 @@ Citizen.CreateThread(function()
Citizen.Wait(0) Citizen.Wait(0)
local ped = PlayerPedId() local ped = PlayerPedId()
if IsPedShooting(ped) then if IsPedShooting(ped) then
if exports["ND_Core"]:getCharacterInfo(6) == "CIV" then if config.useRealisticShotSpotter then
isCiv = true local detected = false
else for k, v in pairs(config.realisticShotSpotterLocations) do
isCiv = false if #(GetEntityCoords(ped) - vector3(v.x, v.y, v.z)) < 450.0 then
end detected = true
if isCiv and not alreadyShot then end
Citizen.Wait(config.shotSpotterDelay * 1000) end
pedCoords = GetEntityCoords(ped) if detected then
if config.shotSpotterUsePostal then local selectedWeapon = GetSelectedPedWeapon(ped)
postal = exports["nearest_postal123"]:getPostal() local hasBlackListedWeapon = false
else local hasSuppressor = false
postal = 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
TriggerServerEvent("ND:shotSpotterActive", pedCoords.x, pedCoords.y, pedCoords.z, postal)
end end
alreadyShot = true
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