Guides

Snapshot Inspector

What an entity sends to the clients, field by field, encoded the way the engine encodes it for a snapshot — for debugging networking.

Schema fields are what an entity holds; a snapshot is what it sends. ISource2ModSnapshots runs the engine's own serializer over one entity and hands you every field that goes out, by its network name and with its value as the engine prints it — the way to see whether a change you made actually reaches the clients.

plugin.cpp
#include "source2mod/ISource2ModSnapshots.h"

if (!g_pSource2ModSnapshots)
    return;   // a core older than the snapshot inspector

CCSPlayerController* controller = CCSPlayerController::FromSlot(slot);

char money[64];
if (g_pSource2ModSnapshots->GetField(controller, "m_pInGameMoneyServices.m_iAccount", money, sizeof(money)))
    META_CONPRINTF("account on the wire: %s\n", money);

g_pSource2ModSnapshots->GetFields(controller, [](uint32_t path, const char* name, const char* type, const char* value)
{
    META_CONPRINTF("%s (%s) = %s\n", name, type, value);
});

ISource2ModSnapshots001 comes through the factory only: SOURCE2MOD_SAVEVARS() fills g_pSource2ModSnapshots, and it is null on a core that does not have it. The plugin API stays 12.

The calls

C++ (g_pSource2ModSnapshots->)SourcePawn (Source2ModSnapshots.)
GetFields(entity, callback)GetFields(entity, callback, data)Every field that goes out, as (path, name, type, value); returns their number, -1 when the entity cannot be encoded
GetField(entity, name, buffer, maxlen)GetField(entity, name, buffer, maxlen)One field's encoded value by its network name; false when the entity does not send it now
Dump(entity, callback)Dump(entity, callback, data)The engine's own dump of the encoded entity, line by line
GetNetworkClassName(entity)GetNetworkClassName(entity, buffer, maxlen)The network class ("CCSPlayerPawn"); null / false for an entity that is not networked
IsAvailable()IsAvailable()Whether the engine's serializer interfaces are there

Names and values

Names are network names, with the components and arrays on the way: "m_iHealth", "m_pInGameMoneyServices.m_iAccount", "m_perRoundStats[0].m_iKills". path is the packed field path (the index in the class's flattened serializer, then in nested serializers and arrays). Values are what the engine prints: "16000", "Solman", "true".

What you get is the full state, before send proxies cull it per player — a field one client never receives is still listed. Encoding costs about as much as one entity's snapshot, so this is a debugging tool, not something to run every tick.

From the console

s2m snapshot <entity index>            every field the entity sends
s2m snapshot <entity index> <field>    one field, e.g. m_iHealth
s2m snapshot <entity index> dump       the engine's own dump

Reference: ISource2ModSnapshots, Schema fields for what a write does and when it is networked.

On this page