Spawn Codes

How to use spawn codes in C++ scripts and the server console.

Spawn codes are string identifiers that map directly to item asset classes in the engine. They are assigned in the Wiki item editor by admins and can be read from any item's Properties section.

Using Spawn Codes in the Server Console

bash
# Spawn an item at a player's location
ardem.spawn spawn_item_dmr_01 PlayerName

# Spawn multiple items
ardem.spawn spawn_item_bandage 5 PlayerName

# Spawn a world item at coordinates
ardem.spawn spawn_item_supply_crate_01 x=1234 y=500 z=5678

Using Spawn Codes in C++

cpp
#include "ArdemItemRegistry.h"
#include "ArdemPlayerController.h"

UArdemItemRegistry* Registry = IArdemModAPI::Get().GetItemRegistry();

// Give a player an item directly by spawn code
Registry->GiveItemBySpawnCode(Player, TEXT("spawn_item_dmr_01"), 1);

// Or use the slug (recommended — more readable and stable)
Registry->GiveItemBySlug(Player, TEXT("dmr"), 1);

// Spawn a world pickup at a location
FArdemSpawnParams Params;
Params.Location  = FVector(1200.f, 500.f, 3400.f);
Params.Count     = 1;

Registry->SpawnWorldItem(TEXT("spawn_item_supply_crate_01"), Params);

ADMIN_ONLY Items

Items with the ADMIN_ONLY flag in their itemFlag property can only be spawned from server-side code running with admin authority. Attempts from non-admin contexts will be rejected by the security layer and logged.

Giving Multiple Items (Starter Kit)

cpp
// Build a starter kit using an array of slugs
void UMyModSubsystem::GiveStarterKit(AArdemPlayerController* Player)
{
    if (!Player) return;

    UArdemItemRegistry* Registry = IArdemModAPI::Get().GetItemRegistry();

    const TArray<FString> Kit = {
        TEXT("bandage"),
        TEXT("water-bottle"),
        TEXT("flashlight"),
        TEXT("map"),
    };

    for (const FString& Slug : Kit)
    {
        Registry->GiveItemBySlug(Player, Slug, 1);
    }

    Player->ClientSendChatMessage(TEXT("You received a starter kit. Good luck."));
}