From 4980a3c06758b75846a2b6ddb25e1708f86ede52 Mon Sep 17 00:00:00 2001 From: zaCade Date: Mon, 20 May 2019 21:25:06 +0200 Subject: [PATCH] Update extension.cpp --- extension.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/extension.cpp b/extension.cpp index 87d0b6b..c77ccd3 100644 --- a/extension.cpp +++ b/extension.cpp @@ -100,12 +100,21 @@ DETOUR_DECL_STATIC6(Detour_SendTo, int, int, s, char *, buf, int, len, int, flag // Skip game id NewBuf += 2; + // Calculate playercount + int iPlayers = 0; + + for (int index = 0; index <= SM_MAXPLAYERS; index++) + { + IGamePlayer *pPlayer = playerhelpers->GetGamePlayer(index); + + if (pPlayer != NULL && pPlayer->IsConnected() && !pPlayer->IsSourceTV()) + { + iPlayers += 1; + } + } + // Correct playercount - int NumPlayers = playerhelpers->GetNumPlayers(); - - NumPlayers -= 1; // Subtract SourceTV - - memset(NewBuf, NumPlayers, 1); + memset(NewBuf, iPlayers, 1); // Reset Pointer NewBuf = OldBuf;