# CodeRanch - cEvidence

A forensic evidence system for RedM / VORP servers. Runs on the **cBase** framework.

## Requirements

* **cBase** (framework adapter)
* **oxmysql** (database)
* **ox\_target** (optional, enabled with `Config.UseTarget = true`)

## Installation

{% stepper %}
{% step %}

### Run the SQL setup

Run `sql/cevidence.sql` in your database. This creates 3 tables and 3 items:

* Tables: `evidence_world`, `evidence_collected`, `evidence_analysis`
* Items: `evidence_casing`, `evidence_dna`, `evidence_kit`
  {% endstep %}

{% step %}

### Start the resource

Start the resource with `ensure cEvidence`.
{% endstep %}
{% endstepper %}

## How It Works

### Evidence Generation

* When a player **fires a weapon**, bullet casing evidence drops on the ground.
* When a player **takes damage**, bloodstain evidence drops on the ground.
* Evidence is saved to the database and automatically cleaned up after a set duration.
* Bullet casings left while wearing gloves cannot be traced back to a player.

### Evidence Viewing (2 Modes)

Selected via the `VisibilityMode` config setting:

| Mode          | Description                                                                                           |
| ------------- | ----------------------------------------------------------------------------------------------------- |
| `"lantern"`   | Using the `evidence_kit` item equips a handheld lantern, nearby evidence appears as markers/props.    |
| `"eagle_eye"` | Using the `evidence_kit` item activates Eagle Eye, evidence becomes visible through eagle eye vision. |

### Evidence Collection

* While the viewer is active, approach nearby evidence and collect it via prompt.
* Collected evidence is added to the player's inventory (`evidence_casing` or `evidence_dna`).
* If `ox_target` is enabled, evidence can also be collected via target zones.

### Evidence Analysis (Lab)

* An evidence lab is located at `Config.Station.Interaction.Coords`.
* Authorized jobs (`police`, `sheriff`, `marshal`) can open the lab UI.
* Collected evidence is analyzed in the lab, revealing suspect details such as name, age, gender, and job.

## Key Config Settings

| Setting                                 | Default                    | Description                                       |
| --------------------------------------- | -------------------------- | ------------------------------------------------- |
| `Config.Debug`                          | `false`                    | Enables debug logs (F8 console)                   |
| `Config.Locale`                         | `"en"`                     | Language (`en`, `tr`, `es`, `fr`, `it`, `ar`)     |
| `Config.Evidence.VisibilityMode`        | `"lantern"`                | Viewing mode: `"lantern"` or `"eagle_eye"`        |
| `Config.Evidence.WorldRetentionMinutes` | `180`                      | How long uncollected evidence stays in SQL (min)  |
| `Config.Evidence.DrawDistance`          | `7.0`                      | Distance at which evidence markers become visible |
| `Config.Evidence.AllowedJobs`           | `police, sheriff, marshal` | Jobs with lab access                              |
| `Config.Decay.BulletLifetimeMinutes`    | `60`                       | Bullet casing decay time (min)                    |
| `Config.Decay.BloodLifetimeMinutes`     | `30`                       | Bloodstain decay time (min)                       |
| `Config.WeatherImpact.Enabled`          | `true`                     | Rain/wind reduces evidence lifetime               |
| `Config.Gloves.Enabled`                 | `true`                     | Glove system on/off                               |
| `Config.Inventory.ViewerItem`           | `"evidence_kit"`           | Item that activates the viewer                    |
| `Config.EvidenceProps.Enabled`          | `true`                     | 3D prop display for evidence                      |
| `Config.Collection.DurationMs`          | `3500`                     | Evidence collection duration (ms)                 |
| `Config.Analysis.DurationMs`            | `18000`                    | Lab analysis duration (ms)                        |

## Commands

| Command              | Description                                   |
| -------------------- | --------------------------------------------- |
| `/clearlant`         | Clears the lantern prop (for stuck states)    |
| `/toggleevidenceeye` | Toggles Eagle Eye mode (eagle\_eye mode only) |
| `X key`              | Quick stow shortcut for lantern/Eagle Eye     |

## Weapon Calibers

The `Config.WeaponCalibers` table maps each weapon to a caliber label, shown in analysis results. To add a new weapon, simply add an entry to the table.

## Language Support

Supported languages in `locales/`: English, Turkish, Spanish, French, Italian, Arabic.\
Change via `Config.Locale`.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://coderanch-redm-store.gitbook.io/coderanch-redm-store-docs/coderanch-cevidence.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
