codeAPI Reference

s&box LimitsSystem: Spawn and tool limits

calendar_today May 12, 2026 schedule ~2 min read person PatrickJr verified 50

LimitsSystem GameObjectSystem API Reference

LimitsSystem enforces configurable limits on spawning and tool usage. Maintains a per-player tracked object list populated from post-events. Limit checks iterate only the player's objects, not the entire scene.

Type Signature

CSHARP
public sealed class LimitsSystem : GameObjectSystem<LimitsSystem>, Global.ISpawnEvents, IToolActionEvents
{
    [ConVar("sb.limit.props")] public static int MaxPropsPerPlayer { get; set; } = -1;
    [ConVar("sb.limit.explosives")] public static int MaxExplosivesPerPlayer { get; set; } = -1;
    [ConVar("sb.limit.balloons")] public static int MaxBalloons { get; set; } = -1;
    [ConVar("sb.limit.constraints")] public static int MaxConstraints { get; set; } = -1;
    [ConVar("sb.limit.emitters")] public static int MaxEmitters { get; set; } = -1;
    [ConVar("sb.limit.thrusters")] public static int MaxThrusters { get; set; } = -1;
    [ConVar("sb.limit.hoverballs")] public static int MaxHoverballs { get; set; } = -1;
    [ConVar("sb.limit.wheels")] public static int MaxWheels { get; set; } = -1;
}

Static Properties (ConVars)

Global.ISpawnEvents Implementation

IToolActionEvents Implementation

Behavior

  • Tracks objects per player using SteamId keys
  • Prunes destroyed objects during count checks
  • Duplicator: batch pre-check rejects entire dupe if it would exceed limits
  • Notifies players via Notices when limits are reached
  • -1 means unlimited, 0 means none allowed

Usage

CSHARP
// Set limits via console
ConsoleSystem.Run("sb.limit.props 100");
ConsoleSystem.Run("sb.limit.balloons 50");

// LimitsSystem automatically enforces these

Notes

  • Implements both ISpawnEvents and IToolActionEvents for comprehensive coverage
  • Uses per-player tracking for efficient limit checks
  • Handles explosive props specially via Model.Data.Explosive
  • Constraint tools checked via "constraint" tag
Was this helpful?