Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Ricochet HLTV Support
#1
This code will prevent an HLTV Proxy from being entered into matches while on arena (it already worked in deathmatch):

In disc_arena.cpp (Line 93):
Code:
if (pPlayer && (pPlayer->m_pCurrentArena == this) && pPlayer->m_bHasDisconnected != TRUE && (stricmp(GETPLAYERAUTHID(pPlayer->edict()), "HLTV") != 0))

This is what the function CDiscArena::Reset will look like after the code has been added (starting on line 86):
Code:
void CDiscArena::Reset( void )
{
    // Remove all clients in the queue
&nbsp;&nbsp;&nbsp;&nbsp;for ( int i = 1; i <= gpGlobals->maxClients; i++ )
&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CBasePlayer *pPlayer = (CBasePlayer *)UTIL_PlayerByIndex( i );

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (pPlayer &amp;&amp; (pPlayer->m_pCurrentArena == this) &amp;&amp; pPlayer->m_bHasDisconnected != TRUE &amp;&amp; (stricmp(GETPLAYERAUTHID(pPlayer->edict()), "HLTV") != 0))
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;RemoveClient( pPlayer );

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Move her into spectator mode
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//MoveToSpectator( pPlayer );
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;}

&nbsp;&nbsp;&nbsp;&nbsp;m_pPlayerQueue = NULL;
&nbsp;&nbsp;&nbsp;&nbsp;m_iPlayers = 0;
&nbsp;&nbsp;&nbsp;&nbsp;m_flTimeLimitOver = 0;
&nbsp;&nbsp;&nbsp;&nbsp;m_bShownTimeWarning = FALSE;
&nbsp;&nbsp;&nbsp;&nbsp;m_iArenaState = ARENA_WAITING_FOR_PLAYERS;
&nbsp;&nbsp;&nbsp;&nbsp;memset( m_hCombatants, 0, sizeof( m_hCombatants ) );

&nbsp;&nbsp;&nbsp;&nbsp;SetThink( NULL );
&nbsp;&nbsp;&nbsp;&nbsp;pev->nextthink = 0;
}

Any HLTV Proxy that connects to a server has the SteamID of HLTV, which makes it easier to distinguish from real players.
Reply
#2
I can't seem to edit my post, but anyway, it can be a little buggy as in when connecting to the HLTV the client thinks that it's a deathmatch server, so it changes the scoreboard accordingly. None of that effects the gameplay, only the people connected to the HLTV. So it's good enough for now, and I'll update the client later to support it with more features, since I just learned that you can have different client.dll's.
Reply
#3
nicely found;)!


-Tribute
Reply
#4
Alright, forgetting what I've said above, here is the complete fix with the changes in bold. All of these functions are in disc_arena.cpp.

Quote:void CDiscArena::Reset( void )
{
// Remove all clients in the queue
for ( int i = 1; i &lt;= gpGlobals-&gt;maxClients; i++ )
{
CBasePlayer *pPlayer = (CBasePlayer *)UTIL_PlayerByIndex( i );

if (pPlayer &amp;&amp; (pPlayer-&gt;m_pCurrentArena == this) &amp;&amp; pPlayer-&gt;m_bHasDisconnected != TRUE &amp;&amp; (stricmp(GETPLAYERAUTHID(pPlayer-&gt;edict()), &quot;HLTV&quot;) != 0))
{
RemoveClient( pPlayer );

// Move her into spectator mode
//MoveToSpectator( pPlayer );
}
}

m_pPlayerQueue = NULL;
m_iPlayers = 0;
m_flTimeLimitOver = 0;
m_bShownTimeWarning = FALSE;
m_iArenaState = ARENA_WAITING_FOR_PLAYERS;
memset( m_hCombatants, 0, sizeof( m_hCombatants ) );

SetThink( NULL );
pev-&gt;nextthink = 0;
}
<!--/sizec-->

Quote:void AddClientToArena( CBasePlayer *pPlayer )
{

if (stricmp(GETPLAYERAUTHID(pPlayer-&gt;edict()), &quot;HLTV&quot;) == 0)
{
return;
}


// First, find an arena for this player to be put into
for (int i = 0; i &lt; MAX_ARENAS; i++)
{
if ( g_pArenaList[i]-&gt;IsFull() == FALSE )
{
int iArenaNumber = i;

g_pArenaList[iArenaNumber]-&gt;AddClient( pPlayer, TRUE );

bool bFoundOne = TRUE;
// Now, if this arena's not full, try to find more player to join her
//Commented out - .asm 06/03/03
/* while ( (g_pArenaList[iArenaNumber]-&gt;IsFull() == FALSE) &amp;&amp; bFoundOne )
{
bFoundOne = FALSE;

// Cycle through all the arenas and find a spare player
for (int j = 0; j &lt; MAX_ARENAS; j++)
{
CBasePlayer *pSparePlayer = g_pArenaList[j]-&gt;GetFirstSparePlayer();
if (pSparePlayer &amp;&amp; pSparePlayer != pPlayer)
{
g_pArenaList[j]-&gt;RemoveClient( pSparePlayer );
g_pArenaList[iArenaNumber]-&gt;AddClient( pSparePlayer, TRUE );
bFoundOne = TRUE;
break;
}
}
} */

// If we couldn't find another player for this arena, just add them to an existing arena
if ( g_pArenaList[iArenaNumber]-&gt;IsFull() == FALSE )
{
// Add to the first full arena
for (int j = 0; j &lt; MAX_ARENAS; j++)
{
if ( g_pArenaList[j]-&gt;IsFull() )
{
// Remove from current
g_pArenaList[iArenaNumber]-&gt;RemoveClient( pPlayer );

// Add to full one
iArenaNumber = j;
g_pArenaList[iArenaNumber]-&gt;AddClient( pPlayer, TRUE );
break;
}
}
}
//Beginning of added code to prevent reconnectors - .asm 06/03/03
else
{
bFoundOne = FALSE;

// Cycle through all the arenas and find a spare player
for (int j = 0; j &lt; MAX_ARENAS; j++)
{
CBasePlayer *pSparePlayer = g_pArenaList[j]-&gt;GetFirstSparePlayer();
if (pSparePlayer &amp;&amp; pSparePlayer != pPlayer)
{
g_pArenaList[j]-&gt;RemoveClient( pSparePlayer );
g_pArenaList[iArenaNumber]-&gt;AddClient( pSparePlayer, TRUE );
bFoundOne = TRUE;
break;
}
}
}

//End of added code to prevent reconnectors - .asm 06/03/03


//ALERT( at_console, &quot;ADDED %s to Arena %d\n&quot;, STRING(pPlayer-&gt;pev-&gt;netname), iArenaNumber );
return;
}
}
}
<!--/sizec-->

Quote:int AddPlayers( int iPlayers, int iArenaNum )
{
for ( int i = 1; i &lt;= gpGlobals-&gt;maxClients; i++ )
{
CBasePlayer *pPlayer = (CBasePlayer *)UTIL_PlayerByIndex( i );

if (pPlayer &amp;&amp; (pPlayer-&gt;m_pCurrentArena == NULL) &amp;&amp; (pPlayer-&gt;m_bHasDisconnected != TRUE) &amp;&amp; (stricmp(GETPLAYERAUTHID(pPlayer-&gt;edict()), &quot;HLTV&quot;) != 0))
{
if ( pPlayer-&gt;m_iLastGameResult != iPlayers )
continue;

g_pArenaList[iArenaNum]-&gt;AddClient( pPlayer, FALSE );
if ( g_pArenaList[iArenaNum]-&gt;IsFull() )
iArenaNum++;
}
}

return iArenaNum;
}<!--sizec-->
<!--/sizec-->
Reply
#5
Still spawns during a match.
&lt;@Miagi&gt; !8 Am I spamming?
&lt;@ChanServ&gt; Miagi: Yes.
&lt;@Miagi&gt; !8 Should I stop?
&lt;@ChanServ&gt; Miagi: Oh, please, PLEASE, make it stop!

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)