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

Name
Type
Description

source

number

Player server ID

Returns

Name
Type
Description

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)
end

StartHordeGame

Start a horde game for a player. This creates a pending game and shows the entry location.

Parameters

Name
Type
Description

source

number

Player server ID (host)

mapName

string

Map name from Maps config

difficultyId

string

Difficulty ID from map.difficulties

Returns

Name
Type
Description

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

Name
Type
Description

source

number

Player server ID (host)

mapName

string

Map name from Maps config

difficultyId

string

Difficulty ID from map.difficulties

Returns

Name
Type
Description

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

Name
Type
Description

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

Option
Type
Default
Description

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

Name
Type
Description

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

Name
Type
Description

source

number

Player server ID

Returns

Name
Type
Description

success

boolean

Whether the game was ended

Example


RemovePlayerFromGame

Remove a specific player from their current game without ending the game for others.

Parameters

Name
Type
Description

source

number

Player server ID

Returns

Name
Type
Description

success

boolean

Whether the player was removed

Example


GetActiveGames

Get information about all currently active horde games.

Returns

Name
Type
Description

games

table

Array of game info objects

Game Info Object

Field
Type
Description

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

Name
Type
Description

source

number

Player server ID

Returns

Name
Type
Description

info

table|nil

Game info, or nil if not in game

Info Object

Field
Type
Description

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

Name
Type
Description

maps

table

Array of map info objects

Map Info Object

Field
Type
Description

id

string

Map identifier

label

string

Display name

difficulties

table

Array of difficulty info

Difficulty Info Object

Field
Type
Description

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

Name
Type
Description

source

number

Player server ID

Returns

Name
Type
Description

stats

table|nil

Player stats, or nil if unavailable

Stats Object

Field
Type
Description

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 kills

  • deaths - Total deaths

  • rounds - Total rounds survived

  • gamesCompleted - Games finished

  • gamesStarted - Games started

  • And more depending on configuration

Example


AddPlayerXP

Add XP to a player's horde progression.

Parameters

Name
Type
Description

source

number

Player server ID

amount

number

Amount of XP to add (must be positive)

Returns

Name
Type
Description

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

Name
Type
Description

source

number

Player server ID

level

number

Level to set (must be >= 1)

Returns

Name
Type
Description

success

boolean

Whether level was set

Example


Cooldown Management

IsPlayerOnCooldown

Check if a player is on horde cooldown.

Parameters

Name
Type
Description

source

number

Player server ID

Returns

Name
Type
Description

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

Name
Type
Description

source

number

Player server ID

minutes

number

Cooldown duration in minutes (0 or negative to clear)

Returns

Name
Type
Description

success

boolean

Whether cooldown was set

Example


ClearPlayerCooldown

Clear a player's horde cooldown.

Parameters

Name
Type
Description

source

number

Player server ID

Returns

Name
Type
Description

success

boolean

Whether cooldown was cleared

Example


Perks System

ApplyPerkToAllPlayers

Apply a perk to all players in a specific game.

Parameters

Name
Type
Description

gameId

string

The game ID

perkId

string

The perk identifier to apply


ClearAllPerksForAllPlayers

Clear all perks from all players in a specific game.

Parameters

Name
Type
Description

gameId

string

The game ID


GetActivePerks

Get active perks for a specific game.

Parameters

Name
Type
Description

gameId

string

The game ID

Returns

Name
Type
Description

perks

table

Table of active perk IDs


ProcessWinningPerk

Process a perk that won the vote and apply it to all players.

Parameters

Name
Type
Description

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

Name
Type
Description

gameId

string

The game ID

Returns

Name
Type
Description

multiplier

number

The loot value multiplier


Mystery Box

CleanupMysteryBoxForGame

Clean up mystery box data for a specific game.

Parameters

Name
Type
Description

gameId

string

The game ID

Last updated