Server
This page documents all available server-side exports for SD-Horde. These exports allow you to interact with the horde system from other server-side scripts, integrate with custom group systems, create admin commands, and more.
Game Management
IsPlayerInHorde
Check if a player is currently in a horde game.
local inGame, game, gameId = exports['sd-horde']:IsPlayerInHorde(source)Parameters
source
number
Player server ID
Returns
inGame
boolean
Whether the player is in a horde game
game
table|nil
The game session data (if in game)
gameId
string|nil
The game ID (if in game)
Example
local inGame, game, gameId = exports['sd-horde']:IsPlayerInHorde(source)
if inGame then
print("Player is in game: " .. gameId)
print("Current round: " .. game.currentRound)
print("Map: " .. game.map)
endStartHordeGame
Start a horde game for a player. This creates a pending game and shows the entry location.
Parameters
source
number
Player server ID (host)
mapName
string
Map name from Maps config
difficultyId
string
Difficulty ID from map.difficulties
Returns
gameId
string|nil
The created game ID, or nil on failure
Example
ForceStartHordeGame
Start a horde game immediately, skipping the entry location requirement. Uses the player's existing group if they have one.
Parameters
source
number
Player server ID (host)
mapName
string
Map name from Maps config
difficultyId
string
Difficulty ID from map.difficulties
Returns
gameId
string|nil
The created game ID, or nil on failure
Example
StartHordeWithPlayers
The most flexible way to start a horde game. Accepts a custom list of players in various formats, bypassing the internal group system. This is the recommended export for integrating with custom group/party systems.
Parameters
players
table
Array of players (see formats below)
mapName
string
Map name from Maps config
difficultyId
string
Difficulty ID from map.difficulties
options
table|nil
Optional settings (see options below)
Supported Player Formats
The export is designed to work with any group system. It accepts players in multiple formats:
Options
skipEntry
boolean
false
Skip entry location, start immediately
immediate
boolean
false
Alias for skipEntry
skip_entry
boolean
false
Alias for skipEntry
host
number
first player
Server ID of the host player
Returns
gameId
string|nil
The created game ID, or nil on failure
error
string|nil
Error message if failed
Examples
ForceEndGame
Force end the game that a player is currently in. This ends the game for all players in that session.
Parameters
source
number
Player server ID
Returns
success
boolean
Whether the game was ended
Example
RemovePlayerFromGame
Remove a specific player from their current game without ending the game for others.
Parameters
source
number
Player server ID
Returns
success
boolean
Whether the player was removed
Example
GetActiveGames
Get information about all currently active horde games.
Returns
games
table
Array of game info objects
Game Info Object
gameId
string
Unique game identifier
map
string
Map name
difficulty
string
Difficulty ID
playerCount
number
Number of players
players
table
Array of player source IDs
currentRound
number
Current round number
state
string
Game state
money
number
Shared money pool
Example
GetPlayerGameInfo
Get detailed information about a player's current game.
Parameters
source
number
Player server ID
Returns
info
table|nil
Game info, or nil if not in game
Info Object
gameId
string
Unique game identifier
map
string
Map identifier
mapLabel
string
Display name of map
difficulty
string
Difficulty ID
difficultyLabel
string
Display name of difficulty
currentRound
number
Current round number
maxRounds
number
Maximum rounds for this difficulty
state
string
Game state
money
number
Shared money pool
playerCount
number
Number of players
players
table
Array of player source IDs
isDead
boolean
Whether this player is dead
Example
GetAvailableMaps
Get all available maps and their difficulties.
Returns
maps
table
Array of map info objects
Map Info Object
id
string
Map identifier
label
string
Display name
difficulties
table
Array of difficulty info
Difficulty Info Object
id
string
Difficulty identifier
label
string
Display name
maxRounds
number
Number of rounds
Example
Player Progression
GetPlayerStats
Get a player's horde statistics and progression.
Parameters
source
number
Player server ID
Returns
stats
table|nil
Player stats, or nil if unavailable
Stats Object
level
number
Player's horde level
xp
number
Current XP
stats
table
Detailed statistics
completedMaps
table
Map completion records
Stats Details
The stats table typically contains:
kills- Total enemy killsdeaths- Total deathsrounds- Total rounds survivedgamesCompleted- Games finishedgamesStarted- Games startedAnd more depending on configuration
Example
AddPlayerXP
Add XP to a player's horde progression.
Parameters
source
number
Player server ID
amount
number
Amount of XP to add (must be positive)
Returns
success
boolean
Whether XP was added
newLevel
number|nil
New level if player leveled up, otherwise nil
Example
SetPlayerLevel
Set a player's horde level directly. XP is automatically adjusted to match the level.
Parameters
source
number
Player server ID
level
number
Level to set (must be >= 1)
Returns
success
boolean
Whether level was set
Example
Cooldown Management
IsPlayerOnCooldown
Check if a player is on horde cooldown.
Parameters
source
number
Player server ID
Returns
onCooldown
boolean
Whether player is on cooldown
remainingSeconds
number|nil
Remaining seconds (if on cooldown)
formattedTime
string|nil
Human-readable time, e.g., "1h 30m"
Example
SetPlayerCooldown
Set a player's horde cooldown.
Parameters
source
number
Player server ID
minutes
number
Cooldown duration in minutes (0 or negative to clear)
Returns
success
boolean
Whether cooldown was set
Example
ClearPlayerCooldown
Clear a player's horde cooldown.
Parameters
source
number
Player server ID
Returns
success
boolean
Whether cooldown was cleared
Example
Perks System
ApplyPerkToAllPlayers
Apply a perk to all players in a specific game.
Parameters
gameId
string
The game ID
perkId
string
The perk identifier to apply
ClearAllPerksForAllPlayers
Clear all perks from all players in a specific game.
Parameters
gameId
string
The game ID
GetActivePerks
Get active perks for a specific game.
Parameters
gameId
string
The game ID
Returns
perks
table
Table of active perk IDs
ProcessWinningPerk
Process a perk that won the vote and apply it to all players.
Parameters
gameId
string
The game ID
perkId
string
The perk identifier that won
GetServerLootValueMultiplier
Get the server-side loot value multiplier for a game (affected by perks).
Parameters
gameId
string
The game ID
Returns
multiplier
number
The loot value multiplier
Mystery Box
CleanupMysteryBoxForGame
Clean up mystery box data for a specific game.
Parameters
gameId
string
The game ID
Last updated