4 週間前 · Jul 27, 2026 6:59 AM
To detect who is currently spectating your player pawn in CS2:
Iterate all 64 player controllers:
CPP
for (int i = 1; i <= 64; i++) {
uintptr_t pController = GetEntityByIndex(i);
if (!pController) continue;
uintptr_t pPawn = GetPawnFromController(pController);
if (pPawn && Read<int>(pPawn + m_iHealth) > 0) continue; // Alive players cannot spectate
uintptr_t observerPawn = GetEntityByIndex(Read<uint32_t>(pController + m_hObserverPawn));
uint32_t targetHandle = Read<uint32_t>(observerPawn + m_pObserverServices + m_hObserverTarget);
if (targetHandle == localPlayerPawnHandle) {
std::string spectatorName = ReadString(pController + m_iszPlayerName);
DrawSpectator(spectatorName);
}
}