Help! Counter Flame player class

viscount1x

Platinian
Does anyone know player class for counterflame hooking class PlayerController update method only gives local player
103816.jpg
 
C#:
HOOK ADDRESSES (offsets inside libil2cpp.so, game version 1.4)
--------------------------------------------------------------
Method                                    Address      Notes
PlayerNetwork::Update                     0x28f4928    Runs for every player. Your main hook.
PlayerNetwork::OnPhotonSerializeView      0x28f66f4    Runs when position updates arrive over the network
PlayerNetwork::TryGetPosition             0x28f5da0    Gets a remote player's position
PlayerNetwork::Awake                      0x28f4750    Use to collect each player into your own list
PlayerNetwork::Start                      0x28f47b4    Use to collect each player into your own list
PlayerController::Update                  0x28fccd4    The one you have now (local player only)
PlayerController::TakeDamage              0x28fd1e4
PlayerController::Die                     0x290021c
BotController::Start                      0x278c060    Bots, which are likely your opponents offline
BotController::TakeDamage                 0x278c100
BotController::Respawn                    0x278c328


FIELD OFFSETS (read from the getter code)
-----------------------------------------
PlayerController:
  +0x80  the network view (get_Photon)
  +0x90  the player record (get_Player)
  +0xa8  a byte flag for "is dead" (get_IsDeath)

BotController:
  +0x18  health (an int)

The player record (Photon.Realtime.Player):
  Carries get_Health, get_IsAlive, get_Team, get_NickName, get_Kills and get_Money.
  You can call those getters on the object at PlayerController +0x90.

@viscount1x
 
Last edited:
@Wxrnin is there any way to clear player list i can only hook PlayerNetwork::Update to get player there's no OnDestroy or OnDisable to hook i can only clear player list a ImGui checbox manually evrytime when match end otherwise it keep reading and crash
 
@Wxrnin is there any way to clear player list i can only hook PlayerNetwork::Update to get player there's no OnDestroy or OnDisable to hook i can only clear player list a ImGui checbox manually evrytime when match end otherwise it keep reading and crash
Yes. You don't need OnDestroy on PlayerNetwork. Two ways, and I'd use both.

When a PlayerNetwork object is destroyed, its Update stops running. So record
when you last saw each player, and drop anyone not seen for about 300 ms. That
covers match end, leaving, respawn and scene change, with no hook needed.

C++:
#include <unordered_map>
#include <mutex>
#include <chrono>

struct PlayerEntry { void* net; int64_t lastSeenMs; };

static std::unordered_map<void*, PlayerEntry> g_players;
static std::mutex g_playersMtx;

static int64_t NowMs() {
    using namespace std::chrono;
    return duration_cast<milliseconds>(steady_clock::now().time_since_epoch()).count();
}

// PlayerNetwork::Update  (libil2cpp.so + 0x28f4928)
void (*old_PlayerNetwork_Update)(void* self);
void hk_PlayerNetwork_Update(void* self) {
    old_PlayerNetwork_Update(self);
    if (!self) return;
    std::lock_guard<std::mutex> lk(g_playersMtx);
    g_players[self] = { self, NowMs() };   // add or refresh
}

// Call at the top of your ImGui / ESP draw, before you read any player
void PrunePlayers() {
    const int64_t now = NowMs();
    std::lock_guard<std::mutex> lk(g_playersMtx);
    for (auto it = g_players.begin(); it != g_players.end(); ) {
        if (now - it->second.lastSeenMs > 300) it = g_players.erase(it);
        else ++it;
    }
}

In your draw code, copy the list under the lock, then read from the copy:

C++:
PrunePlayers();
std::vector<void*> snapshot;
{
    std::lock_guard<std::mutex> lk(g_playersMtx);
    for (auto& [k, e] : g_players) snapshot.push_back(e.net);
}
for (void* net : snapshot) { /* read position etc. */ }

The lock matters. Your hook runs on Unity's main thread, but ImGui draws on the
render thread. If the list changes while you're looping over it, that alone can
crash, even when no player has been destroyed.


ALSO CLEAR THE WHOLE LIST WHEN A MATCH ENDS (extra safety)
PlayerController does have OnDestroy. It's on the same player object as
PlayerNetwork, so it fires when players are removed. Clearing everything there
is simple and safe, because live players re-add themselves on their next Update.

Hook Address What to do
C++:
PlayerController::OnDestroy            0x28fce00   Clear g_players
GameHelper::OnLeftRoom                0x2aeb884   Clear g_players (fires when you leave a match or room)

C++:
void (*old_PC_OnDestroy)(void* self);
void hk_PC_OnDestroy(void* self) {
    { std::lock_guard<std::mutex> lk(g_playersMtx); g_players.clear(); }
    old_PC_OnDestroy(self);
}

void (*old_GH_OnLeftRoom)(void* self);
void hk_GH_OnLeftRoom(void* self) {
    { std::lock_guard<std::mutex> lk(g_playersMtx); g_players.clear(); }
    old_GH_OnLeftRoom(self);
}

IF IT STILL CRASHES
- Never keep a pointer you got from a PlayerNetwork (its transform, its
PlayerController, and so on) from one frame to the next. Look it up again
from the player object each frame.
- Check every pointer before you read through it: not null, and not obviously
invalid (below 0x10000).
 
Back
Top Bottom