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
endClient-side:
local inGame, state = exports['sd-horde']:IsPlayerInHorde()
if inGame then
-- Player is in horde, skip dispatch
returnThe 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:
Listen for game events (like
CEventGunShot) - add the check in the event handlerUse exports called by other scripts - add the check at the start of the export function
Poll for weapon firing - add the check in the detection loop
Testing
To verify your integration:
Start a horde game
Fire your weapon
Confirm no dispatch alerts appear
End the horde game
Fire your weapon again
Confirm dispatch alerts work normally
Add debug prints if needed:
Last updated