Witnesses - Advanced NPC Reactions

Witnesses
Enables NPCs as witnesses to any crime the player commits, only if they can be seen or heard.

Preview

If the preview doesn’t work, click here

Features
Visual Detection - If an NPC is close enough to witness a crime, they have a chance to report it.
Crimes are defined in the configuration with a visual threshold, audio threshold, and severity.

Player Description - If the NPC can see the player, they will report the following based on how far they are away

  • Eye Color
  • Hair Color
  • Top Color
  • Bottoms Color
  • Shoes Color
  • Carrying Melee
  • Carrying Firearm
  • Carrying Explosives
  • Accessories (Helmet)
  • Player Health

Player Actions

  • Hit & Run
  • Crashes
  • Stuns
  • Reloading
  • Diving
  • Falling
  • Shooting
  • Carjacking
  • Swimming

Crime Detection - The following crimes are included with the resource and do not require any setup

  • Shots Fired - Triggered when the player fires their gun
  • Brandishing Firearm - Triggered when the player aims at an NPC
  • Carjacking - Triggered when the player steals a vehicle
  • Homicide - Triggered when the player kills an NPC (animals do not count)
  • Reckless Driving - Triggered when the player drives against traffic
  • Criminal Speeding - Triggered when the player drives over a set speed (configurable)
  • Vehicular Collision - Triggered when the player crashes
  • Vehicular Assault - Triggered when the player runs over an NPC
  • Unresponsive Individual - Triggered when the player is in ragdoll for more than 5 seconds

Ped Blacklist - Functions have been included to blacklist certain peds as witnesses (e.g. shopkeepers)

Easy Integration - Crime detection can be added to existing code with one line

Configuration Options

  • Default Values - Some default values have been included so they don’t have to be included in other parts of the configuration
    • Crime Severity
    • Ped Trust Factors
    • Groups
  • Report Time - Minimum and maximum times reports are taken
  • Crimes
    • Visual Radius
    • Audio Radius
    • Severity
  • Text Entries - Included for easy translation
  • Ped Cooperation Factors - How likely a certain ped model is to contact the police
    • Gangsters have 0% by default
    • Police have 100% by default
  • Mask Configuration - If wearing a certain mask the eye/hair color will be removed from the report
    • Masks that hide hair
    • Masks that hide eyes

Standalone - There is no need for any framework with this script.

You can find the resource here

We offer support! Please check our readme files for contact information :heart:

Code is accessible Partial
Subscription-based No
Lines (approximately) 2,000+
Requirements Standalone
Support Yes

Check out our other resources!

Skills
Home Invasions
Dog Walking
Contract Killings
Dynamic Weather
Gang Activity
Art Theft
Global Garages
Poster Placement Job
Throwable Objects

5 Likes

It would be cool if it could be deactivated in “zones”.

and also a way to link it to a disaptch system

2 Likes

What are the dependencies? Which dispatch system is compatible with?

2 Likes

whats the resmon on this?

1 Like

Great idea, will include this in the next update!

It is not compatible with any dispatch system in particular, what is included is an event. It looks like this:

RegisterServerEvent("Witnesses:Dispatch")
AddEventHandler("Witnesses:Dispatch", function(code, crime, description, report, vehicle, coordinates, group)
    --Dispatch logic here
end)

The information should be able to be formatted and passed to any dispatch system. If you need help with this, we offer support :slight_smile:

There are no dependencies other than a resource named “Outfits” which is included (for color detection).

0.02-0.04ms idle.

2.00-4.00ms or .02-.04ms

Very big difference lol.

1 Like

0.02-0.04ms :heart:

The resource has been further optimized and now idles at 0.01-0.02ms
image

2 Likes

Witnesses has been updated to include zones

These can be defined as polygons or a center coordinate with a radius.

Zones are used for one of two features:

  1. Triggering the “Trespassing” crime
  2. Deactivating witnesses in certain areas

Thank @Info.sachsenrp for the idea :slight_smile:

If anyone else has ideas for additions to this resource feel free to comment :heart:

Cool script! Just got it.

Is there anyway to dispatch to cd_dispatch?

local data = exports['cd_dispatch']:GetPlayerInfo()
TriggerServerEvent('cd_dispatch:AddNotification', {
    job_table = {'police', }, 
    coords = data.coords,
    title = '10-15 - Store Robbery',
    message = 'A '..data.sex..' robbing a store at '..data.street, 
    flash = 0,
    unique_id = data.unique_id,
    sound = 1,
    blip = {
        sprite = 431, 
        scale = 1.2, 
        colour = 3,
        flashes = false, 
        text = '911 - Store Robbery',
        time = 5,
        radius = 0,
    }
})
1 Like

nice! top and fast

1 Like

Replace the event in server.lua as follows :slight_smile:

RegisterServerEvent("Witnesses:Dispatch")
AddEventHandler("Witnesses:Dispatch", function(code, crime, description, report, vehicle, coordinates, group)
	TriggerEvent('cd_dispatch:AddNotification', {
	    job_table = {group}, 
	    coords = coordinates,
	    title = code..' - '..crime,
	    message = description..' '..report, 
	    flash = 0,
	    unique_id = source,
	    sound = 1,
	    blip = {
	        sprite = 431, 
	        scale = 1.2, 
	        colour = 3,
	        flashes = false, 
	        text = code,
	        time = 5,
	        radius = 0,
	    }
	})
end)