[FREE] ShotSpotter - Gunshot Detection System

How to modify the script so only police job can see the police alerts? Not the police cars but just people who are the police job? i tried some stuff but im not the best and i don’t know how to do that could someone help?

-- Notify player
RegisterNetEvent('gunshotNotify', function(alert)
		Wait(Config.NotifyTime)
        if xPlayer.job.name == 'police' then
			PlaySoundFrontend(-1, "TIMER_STOP", "HUD_MINI_GAME_SOUNDSET", 1)
            Notify(alert)
        end
end)

-- Show blip on map
RegisterNetEvent('gunshotLocation', function(gx, gy, gz)
		Wait(Config.NotifyTime)
        if xPlayer.job.name == 'police' then 
            local gunshotBlip = AddBlipForRadius(gx, gy, gz, Config.BlipRadius)
            SetBlipSprite(gunshotBlip, 161)
            SetBlipColour(gunshotBlip, Config.BlipColor)
            SetBlipAsShortRange(gunshotBlip, 0)
            Wait(Config.BlipTime)
            SetBlipSprite(gunshotBlip, 2)						
        end
end)

I tried this but it doesn’t work sadly

Is this a standalone? I feel that this is a esx base.

I just read the code and its fully standalone.

add esx before xPlayer.job.name == ‘police’ these like this
ESX.xPlayer.job.name == ‘police’ Or without .

Does this script have a radius to notify the police? I’ll shoot and drive a few blocks and never get notified. But I get notified if I shoot and remain relatively close to the area.

how to change so that everyone even outside the car and even a normal citizen can get a notification ?

In the client lua, lines 10 and 19, remove these 2 checks:

if IsPedInAnyPoliceVehicle(PlayerPedId()) then

And also at lines 13 and 26 remove the end

This way every player on the server will get notified.

Thank you and i have another question why the notification is so slow to respond to gunshot ? how to make the notification get respond fast ?

By default it has a delay of 30 seconds because in real life I’d assume the system takes some time to detect the gunshots and send alerts.

However if you wish, you can change this in the config.lua, by changing the Config.NotifyTime variable.

Nice, Thank you so much.

1 Like

@Species8472 Practically @lama-development is saying any vehicle that is under the vehicle class emergency, within the vehicles.meta, since FiveM doesn’t really use flags, anymore, its more now of classes, So instead of Flag_emergency_service, it uses classes, hence the initial (VC - Vehicle Class).

So in this case it would be VC_Emergency, or if you need a service vehicle such as DOT for example, it would be VC_Service.

if you control F and search for VC you should find it there.

Hi! is there anyway to make so that players that have the police job can receive the notifications even tho they are not in any vehicle?

No, since the script is standalone. You would need to edit a bunch of code in order to do that

1 Like

Thank you anyway is spectacular like that

1 Like

There is a PR under your resource that does exactly that :wink:

Take a look at my fork for an option added for QBCore support.

Link: GitHub - ExtrmHighC/ShotSpotter: Receive gunshot alerts triggered by other players.

You’re right, I didn’t see that. That’s awesome.

Would it be possible to exclude certain areas such as Sandy Shores and Harmony because realistically a ShotSpotter is not going to be out that far of major cities. I would say Los Santos and Paleto would be two very good examples of places where there should be Shotspotters.

Not possible on this unless you add a bunch of code. This other script from Andy has what you’re looking for but it’s for his ND_Framework. You could see how he has done it.

[ND Core] [FREE] Realistic Shot Spotter Script - FiveM Resource Development & Modding / Releases - Cfx.re Community

Hi @lama-development , I love the shotspotter! With that being said I am having an issue where the map general location marker is not showing up when shots are fired do you know why this may be?