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:
localinGame, game, gameId=exports['sd-horde']:IsPlayerInHorde(source)ifinGamethen -- Player is in horde, skip dispatchreturnend
Client-side:
localinGame, state=exports['sd-horde']:IsPlayerInHorde()ifinGamethen -- Player is in horde, skip dispatchreturn
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:
Listen for game events (like CEventGunShot) - add the check in the event handler
Use 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
['CEventGunShot'] = function(witnesses, ped)
-- Add horde check - skip dispatch if in horde game
local inHorde = exports['sd-horde']:IsPlayerInHorde()
if inHorde then return end
-- Original code continues below...
if not PlayerData or not PlayerData.job then return end
-- ... rest of the handler
end,
-- Client-side check
local inGame = exports['sd-horde']:IsPlayerInHorde()
if inGame then return end
-- Or server-side check
local inGame = exports['sd-horde']:IsPlayerInHorde(source)
if inGame then return end
local inGame = exports['sd-horde']:IsPlayerInHorde()
print('[Dispatch] Player in horde: ' .. tostring(inGame))
if inGame then return end