Dispatch Integration

This guide explains how to disable dispatch alerts when players are participating in a horde game.


Why Disable Dispatch Alerts?

During horde games, players fire weapons constantly to fight off enemies. Without integration, this would spam your dispatch system with "shots fired" alerts, overwhelming your police department and breaking immersion.

Using the IsPlayerInHorde export, you can check if a player is in a horde game and skip dispatch alerts accordingly.


General Concept

The IsPlayerInHorde export returns whether a player is currently in a horde game:

Server-side:

local inGame, game, gameId = exports['sd-horde']:IsPlayerInHorde(source)
if inGame then
    -- Player is in horde, skip dispatch
    return
end

Client-side:

local inGame, state = exports['sd-horde']:IsPlayerInHorde()
if inGame then
    -- Player is in horde, skip dispatch
    return

The pattern is simple: check if the player is in a horde game at the point where dispatch alerts are triggered, and return early if they are.


ps-dispatch

ps-dispatch uses the game event CEventGunShot to automatically detect shooting. The detection logic is in client/eventhandlers.lua.

How It Works

When a gunshot event fires, ps-dispatch checks several conditions before sending an alert:

  • Is the weapon silenced?

  • Is the player in a no-dispatch zone?

  • Is the weapon whitelisted?

  • Are there witnesses?

We can add a horde check to this logic.

Integration

In ps-dispatch/client/eventhandlers.lua, find the CEventGunShot handler and add the horde check at the beginning:

This prevents any shooting alerts from being processed while the player is in a horde game.


Other Dispatch Scripts

The same concept applies to any dispatch script. Find where the shooting alert is triggered and add the check:

Most dispatch scripts either:

  1. Listen for game events (like CEventGunShot) - add the check in the event handler

  2. Use exports called by other scripts - add the check at the start of the export function

  3. Poll for weapon firing - add the check in the detection loop


Testing

To verify your integration:

  1. Start a horde game

  2. Fire your weapon

  3. Confirm no dispatch alerts appear

  4. End the horde game

  5. Fire your weapon again

  6. Confirm dispatch alerts work normally

Add debug prints if needed:

Last updated