menu_bookDocumentation

s&box ISpawnerExtensions: Creating spawner instances

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

ISpawnerExtensions: Creating ISpawner Instances

ISpawnerExtensions provides an extension method to create ISpawner instances from type strings, supporting various spawner types like props, mounts, entities, and duplicator saves.

Extension Method

CSHARP
public static class ISpawnerExtensions
{
    extension(ISpawner spawner)
    {
        public static ISpawner Create(string type, string path, string source = null, string metadata = null)
        {
            return type switch
            {
                "prop" => new PropSpawner(path),
                "mount" => new MountSpawner(path, metadata),
                "entity" or "sent" => new EntitySpawner(path),
                "dupe" => new DuplicatorSpawner(path, source),
                _ => null
            };
        }
    }
}

Parameters

  • string type - The spawner type: "prop", "mount", "entity", "sent", or "dupe"
  • string path - The asset path or ident for the resource to spawn
  • string source - Optional source for duplicator saves (e.g., cloud ident)
  • string metadata - Optional metadata for mount spawners

Supported Types

  • "prop" - Creates a PropSpawner for model props
  • "mount" - Creates a MountSpawner for mount content with metadata
  • "entity" or "sent" - Creates an EntitySpawner for ScriptedEntity resources
  • "dupe" - Creates a DuplicatorSpawner for duplicator save files

Usage

CSHARP
// Create a prop spawner
var propSpawner = ISpawner.Create("prop", "models/citizen_props/cardboardbox01.vmdl");

// Create a mount spawner with metadata
var mountSpawner = ISpawner.Create("mount", "content_id", metadata: "game_title");

// Create an entity spawner
var entitySpawner = ISpawner.Create("entity", "entities/my_entity.semit");

// Create a duplicator spawner with source
var dupeSpawner = ISpawner.Create("dupe", "save_id", source: "cloud");

// Await loading before use
await spawner.Loading;
if (spawner.IsReady)
{
    var objects = await spawner.Spawn(transform, player);
}

Notes

  • The spawner may still be loading after creation - await ISpawner.Loading before use
  • Returns null for unknown types
  • Used by the spawner system to deserialize spawner payloads from save data
  • The "entity" and "sent" types are aliases for the same EntitySpawner
Was this helpful?