Developer knowledge network · moderated exchange

UnreliableCode 커뮤니티

개발자 연구, 리버스 엔지니어링 및 코딩 커뮤니티

Knowledge index살다
4Categories
919Threads
2.8K게시물
Guide

Spectator List detection in CS2 from CCSPlayerController observe targets

csgo_offset_hound
Offset Master
MEMBER
대표: 114
가입 날짜: Apr 2019
게시물: 16
감사해요: 16
4주 전 · Jul 27, 2026 6:59 AM
#1

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);
    }
}
vtable_slayer
Senior Reverser
MEMBER
대표: 215
가입 날짜: Mar 2018
게시물: 86
감사해요: 61
3주 전 · Jul 27, 2026 3:43 PM
#2

Works like a charm. Shows both teammates and enemy spectators in casual/deathmatch.

netvar_ninja
Schema Master
MEMBER
대표: 145
가입 날짜: Nov 2018
게시물: 16
감사해요: 89
3주 전 · Jul 28, 2026 5:51 AM
#3

Clean observer services pointer chain. Very useful to toggle off risky features when someone is watching.