Question Getting spectator with m_hObserverTarget

  • CSGO recently moved logic from 'client_panorama.dll' to 'client.dll', you must update all code that uses 'client_panorama.dll' and replace it with 'client.dll' or the code will not work.
Hexui Undetected CSGO Cheats PUBG Accounts

TwoTen

Full Member
Jul 9, 2020
2
104
0
How long you been coding/hacking?
10+ years
Coding Language
C#
Hello!

I am not very familiar with the source engine, but I wrote my first external cheat and have been using it with great success for over a year now. It's written in C#. I have had no issues at all so far implementing all the features I want, except for one, which is the spectator list.

My understanding is, when a entity is dead and spectating another entity, (entityPtr + NetVars.hObserverTarget) should be a pointer to the entity being spectated. So I started a bot game with two accounts on where one is spectating the other. Below is a print of my findings:

Here, Client A is spectating BOT Shawn
Code:
ClientHandle: 696320000
EntityList: 81394644
Index: 0 Pointer: 338344400 Name: N/A Target: 2
Index: 1 Pointer: 1065779360 Name: ClientB Target: -1
Index: 2 Pointer: 1791324288 Name: ClientA Target: 10551307
Index: 3 Pointer: 1397221184 Name: Mark Target: -1
Index: 5 Pointer: 1719517520 Name: Nick Target: -1
Index: 6 Pointer: 1530143856 Name: Dean Target: -1
Index: 7 Pointer: 985699936 Name: Henry Target: -1
Index: 8 Pointer: 1512817888 Name: Doug Target: -1
Index: 9 Pointer: 1811396560 Name: Scott Target: -1
Index: 10 Pointer: 1424954528 Name: Dustin Target: -1
Index: 11 Pointer: 1805786384 Name: Shawn Target: -1
As you can see, from my understanding of the hObserverTarget, it should be set to 1805786384, but it's not. Then I switched Client A to spectating Client B. Here is the result:

Code:
ClientHandle: 696320000
EntityList: 81394644
Index: 0 Pointer: 338344400 Name: N/A Target: 2
Index: 1 Pointer: 1065779360 Name: ClientB Target: -1
Index: 2 Pointer: 1791324288 Name: ClientA Target: 50069505
Index: 3 Pointer: 1397221184 Name: Mark Target: -1
Index: 5 Pointer: 1719517520 Name: Nick Target: -1
Index: 6 Pointer: 1530143856 Name: Dean Target: -1
Index: 7 Pointer: 985699936 Name: Henry Target: -1
Index: 8 Pointer: 1512817888 Name: Doug Target: -1
Index: 9 Pointer: 1811396560 Name: Scott Target: -1
Index: 10 Pointer: 1424954528 Name: Dustin Target: -1
Index: 11 Pointer: 1805786384 Name: Shawn Target: -1
Here I am expecting the Target to be 1065779360, but it's not.

What am I doing wrong? What exactly is the hObserverTarget pointer pointing at?

Thanks in advance!
 

Rake

I'm not your friend
Administrator
Jan 21, 2014
13,058
79,068
2,472
Please for the love of god display hex not decimal

I think hObserverTarget is a handle, not a pointer and you have to convert the handle to the player id/address

if you check the source code:
C++:
#define    MAX_EDICT_BITS                11  
#define NUM_ENT_ENTRY_BITS        (MAX_EDICT_BITS + 1)
#define NUM_ENT_ENTRIES            (1 << NUM_ENT_ENTRY_BITS)
#define ENT_ENTRY_MASK            (NUM_ENT_ENTRIES - 1)

// Called from Recv Proxy, mainly to reset tone map scale
void C_BasePlayer::SetObserverTarget( EHANDLE hObserverTarget )
{
    // If the observer target is changing to an entity that the client doesn't know about yet,
    // NULL to NULL.  To combat this, we need to check against GetEntryIndex() and
    // GetSerialNumber().
    if ( hObserverTarget.GetEntryIndex())
    {...}
}
      
inline int CBaseHandle::GetEntryIndex() const
{
    return m_Index & ENT_ENTRY_MASK;
}
Then once you have the index, you just to EntityArray[index] to get the player's entry I think
 

Kekz

Maybe Pasting
Meme Tier VIP
Trump Tier Donator
Dank Tier Donator
Jan 10, 2020
221
6,703
29
Last edited:
  • Like
Reactions: TwoTen and Rake

TwoTen

Full Member
Jul 9, 2020
2
104
0
Thank you!

Don't know why I didn't notice the h prefix.

Here is the solution I went with for anyone in the future:

C#:
public int HObserverTarget => Memory.ReadInt(EntityPointer + NetVars.m_hObserverTarget);
public Entity ObserverTarget => HObserverTarget > 0 ? GetEntityAtIndex(HObserverTarget & 4095) : null;
 
  • Like
Reactions: Rake
Community Mods