# Developer Events & Integration

This page explains the **events and exports** your RedM scripts can use to work smoothly with CodexAC:

* Temporarily **whitelist legit heals / revives / teleports**
* Get **player identifiers** for whitelisting
* (Optional) Hook into **logs and dashboard data**

> 📝 All examples are generic Lua. Replace the comments with your own framework or script logic.

***

#### 🩹 Heal / Revive / Teleport Bypass Events <a href="#heal-revive-teleport-bypass-events" id="heal-revive-teleport-bypass-events"></a>

Use these when your script performs **legit actions** that CodexAC would normally detect as suspicious:

* Healing (bandages, medkits, doctors, etc.)
* Reviving players
* Teleporting players (admin, missions, fast travel, etc.)

All of them are **server → client** events.

***

**🩹 `codex_anticheat:healingBypass`**

**What it does**

Opens a **3-second window** where CodexAC will **allow fast health increases** for that player.

Use this right before you perform a **legit heal** on a player.

**Server-side pattern**

```lua
-- SERVER-SIDE EXAMPLE (HEAL)
-- This is just a pattern. Insert it inside your own item/command/event handlers.

local src = source  -- player you’re healing

-- 1) Tell CodexAC this heal is legit (3s bypass)
TriggerClientEvent('codex_anticheat:healingBypass', src)

-- 2) Your heal logic here (call your own client event / status code)
-- e.g. set player health, trigger your own client event, etc.
```

> ✅ Call this **immediately before** your heal logic.

***

**💉 `codex_anticheat:reviveBypass`**

**What it does**

Opens a **3-second window** where CodexAC will **allow a revive** for that player.

Use this before **any legit revive**, like doctors, EMS, or admin revives.

**Server-side pattern**

```lua
-- SERVER-SIDE EXAMPLE (REVIVE)
-- Use this inside your revive handler (doctor, EMS, admin, etc.).

local targetId = targetId  -- player you’re reviving

-- 1) Tell CodexAC this revive is legit (3s bypass)
TriggerClientEvent('codex_anticheat:reviveBypass', targetId)

-- 2) Your revive logic here
-- e.g. trigger your own client revive event, set ped status, etc.
```

> 🧠 Add this to every **legit revive flow** to avoid false flags.

***

**🚪 `codex_anticheat:teleportBypass`**

**What it does**

Opens a **5-second window** where CodexAC’s teleport detection will **not flag big position changes**.

Use this before **any legit teleport**, such as:

* Admin teleports
* Mission teleports
* Fast travel
* Interior / instance teleports

**Server-side pattern**

```lua
-- SERVER-SIDE EXAMPLE (TELEPORT)
-- Use this wherever you teleport a player.

local targetId = targetId  -- player you’re teleporting

-- 1) Tell CodexAC this teleport is legit (5s bypass)
TriggerClientEvent('codex_anticheat:teleportBypass', targetId)

-- 2) Your teleport logic here
-- e.g. send coords to client and move the player there.
```

> ✅ Keep the bypass and the teleport **very close together** in your code.

***

**🚫 When these are not needed**

If you turned off the related checks in `shared_anticheat_config.lua`:

* `HealReviveChecker = false` → `healingBypass` / `reviveBypass` not needed.
* `AntiPlayerTeleport = false` → `teleportBypass` not needed.

Calling them while disabled does nothing harmful, just unnecessary.

***

#### 🧾 Identifier Helpers & Whitelist Support <a href="#identifier-helpers-and-whitelist-support" id="identifier-helpers-and-whitelist-support"></a>

These help you get player IDs to put into the **config allowlist**, or to build your own admin UI.

***

**🧾 `getplayerindenti` (server)**

**Purpose**

Prints a JSON table of connected players and their **Steam identifiers** to the **server console**.

**Server-side usage**

```lua
-- SERVER-SIDE
-- Call this from any server script (or via a command wrapper if you want).
TriggerEvent('getplayerindenti')
```

You’ll see something like in the console:

```lua
{
  "3": { "steam": "steam:11000010ABCDEF1", "name": "PlayerOne" },
  "5": { "steam": "steam:11000010ABCDEFA", "name": "PlayerTwo" }
}
```

Copy the ID(s) you need into `allowlist` in `shared_anticheat_config.lua`.

***

**🔄 `requestPlayerIdentifiers` → `receivePlayerIdentifiers`**

Use these if you want a **full identifier list** in your **client** to drive a UI.

**Client-side usage**

```lua
-- CLIENT-SIDE
-- Ask the server for identifiers
TriggerServerEvent('requestPlayerIdentifiers')

-- Receive the list
RegisterNetEvent('receivePlayerIdentifiers')
AddEventHandler('receivePlayerIdentifiers', function(list)
    -- `list` is a table: [serverId] = { steam = "...", name = "..." }

    -- You can print it:
    print(json.encode(list))

    -- Or forward it to your NUI (sendNUIMessage, etc.)
end)
```

***

#### 🧩 Feature State Export <a href="#feature-state-export" id="feature-state-export"></a>

CodexAC exposes one **client export** so your scripts can check which module is active.

**🧩 `exports['codex_anticheat']:IsModuleEnabled(name)`**

**Side:** client **Returns:** `true` or `false`

**Usage**

```lua
-- CLIENT-SIDE
local isEnabled = exports['codex_anticheat']:IsModuleEnabled('AntiGodMode')

if isEnabled then
    -- Optional: adjust your logic if AntiGodMode is running
end
```

Valid `name` values match the config keys, for example:

* `"AntiGodMode"`
* `"AntiAimbot"`
* `"RaycastChecker"`
* `"HealReviveChecker"`
* `"Antiscaleoverride"`
* `"DisableNatives"`
* `"TamperDetection"`
* `"AntiResourceInjection"`
* `"AntiEntities"`
* `"TrackPlayerAccuracy"`
* `"TrackPlayerKDA"`

***

#### 📊 Logs & Dashboard (Advanced / Optional) <a href="#logs-and-dashboard-advanced-optional" id="logs-and-dashboard-advanced-optional"></a>

These are mostly for CodexAC’s internal admin UI, but you can hook into them if you’re building your own.

***

**📬 Subscribe / Unsubscribe to logs**

**Client → Server**

```lua
-- CLIENT-SIDE
-- Start receiving CodexAC logs and dashboard data
TriggerServerEvent('codexac:logs:subscribe')

-- Stop receiving
-- TriggerServerEvent('codexac:logs:unsubscribe')
```

***

**📈 Receiving dashboard & logs**

**Server → Client**

Handle these only if you are building a custom UI:

```lua
-- CLIENT-SIDE

-- Dashboard snapshot
RegisterNetEvent('codexac:client:updateDashboard')
AddEventHandler('codexac:client:updateDashboard', function(data)
    -- `data` contains aggregated stats (detections, players, etc.)
    -- Forward this to your NUI if needed
end)

-- Log entries
RegisterNetEvent('codexac:logs:push')
AddEventHandler('codexac:logs:push', function(entries)
    -- `entries` is an array of log entries
    -- Append these to your log UI
end)
```

***

**🛰 Request a dashboard snapshot**

**Client → Server**

```lua
-- CLIENT-SIDE
TriggerServerEvent('codexac:server:sendDashboardData')
-- You will receive data via 'codexac:client:updateDashboard'
```

***

#### 🧠 Quick Cheat Sheet (No Custom Events) <a href="#quick-cheat-sheet-no-custom-events" id="quick-cheat-sheet-no-custom-events"></a>

**🩹 Heals**

```lua
-- SERVER
TriggerClientEvent('codex_anticheat:healingBypass', playerId)
-- then perform your heal logic for that player
```

**💉 Revives**

```lua
-- SERVER
TriggerClientEvent('codex_anticheat:reviveBypass', playerId)
-- then perform your revive logic for that player
```

**🚪 Teleports**

```lua
-- SERVER
TriggerClientEvent('codex_anticheat:teleportBypass', playerId)
-- then teleport the player
```

**🧾 Whitelist helpers**

```lua
-- SERVER: dump IDs to console
TriggerEvent('getplayerindenti')

-- CLIENT: request all identifiers
TriggerServerEvent('requestPlayerIdentifiers')
-- handle 'receivePlayerIdentifiers'
```

**🧩 Module state (client)**

```lua
local active = exports['codex_anticheat']:IsModuleEnabled('AntiGodMode')
```

**Goal:** Tell CodexAC when something is **legit** so it doesn’t flag your own scripts.

**🩹 Legit Heals (bandages, doctors, etc.)**

```lua
-- SERVER
TriggerClientEvent('codex_anticheat:healingBypass', playerId)
-- then run your own heal logic for that player
```

***

**💉 Legit Revives**

```lua
-- SERVER
TriggerClientEvent('codex_anticheat:reviveBypass', playerId)
-- then run your own revive logic for that player
```

***

**🚪 Legit Teleports (admin, missions, fast travel)**

```lua
-- SERVER
TriggerClientEvent('codex_anticheat:teleportBypass', playerId)
-- then teleport the player in your own code
```

***

**🧾 Get IDs for Whitelist (config)**

```lua
-- SERVER: print all connected players & their steam IDs in console
TriggerEvent('getplayerindenti')
```

***

**🧩 Check if a module is enabled (client)**

```lua
-- CLIENT
local isOn = exports['codex_anticheat']:IsModuleEnabled('AntiGodMode')
```

> ✅ Everything else in this page just explains these in more detail.
