C_BasePlayer* player = GetLocalPlayer(); // get a pointer to the local player int observerMode = player->GetObserverMode(); // get the observer mode of the player if (observerMode == OBS_MODE_CHASE) { // do something specific when the player is in chase mode }
C_BasePlayer* player = GetPlayerById(2); // get a pointer to a player by their ID int observerMode = player->GetObserverMode(); // get the observer mode of the player if (observerMode != OBS_MODE_NONE) { // do something specific when the player is observing another entity }This example gets the observer mode of another player by their ID and checks if they are observing another entity. If they are, then it executes a specific block of code. Package/Library: The C_BasePlayer class is part of the "BaseClient" package/library in the Source Engine.