From 3a04674340f448adc304a09847cc3d304d1247b1 Mon Sep 17 00:00:00 2001 From: ricardoofnl Date: Sat, 5 Sep 2026 09:36:20 +0700 Subject: [PATCH] [saco] Match `FUNC_10004120`; the counter is a free function whose loop index and bound are both locals declared ahead of the early return --- saco/net/localplayer.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/saco/net/localplayer.cpp b/saco/net/localplayer.cpp index 05d8853..c62bc51 100644 --- a/saco/net/localplayer.cpp +++ b/saco/net/localplayer.cpp @@ -9,6 +9,8 @@ extern CNetGame *pNetGame; DWORD dword_100FE0A4 = -1; DWORD dword_100FE0A8 = 30; DWORD dword_100FE0AC = 30; +DWORD dword_101189A0; +DWORD dword_101189A4; //---------------------------------------------------------- @@ -607,3 +609,41 @@ void CLocalPlayer::FUNC_10003FC0() pGame->DisplayGameText("Stay within the ~r~world boundries", 1000, 5); } } + +//---------------------------------------------------- + +// counts the spawned players, recomputed once every 30 calls +int FUNC_10004120() +{ + CPlayerPool *pPlayerPool = pNetGame->GetPlayerPool(); + WORD i = 0; + + if(dword_101189A4) + { + dword_101189A4--; + return dword_101189A0; + } + + int iCount = 0; + + dword_101189A4 = 30; + dword_101189A0 = 0; + + if(pPlayerPool) + { + int iMax = pPlayerPool->field_2F3A; + + for(; i <= iMax; i++) + { + if(pPlayerPool->GetSlotState(i)) + { + CRemotePlayer *pRemotePlayer = pPlayerPool->GetAt(i); + + if(pRemotePlayer->m_pPlayerPed && pRemotePlayer->field_10A) + dword_101189A0 = ++iCount; + } + } + } + + return iCount; +}