I created this code before a month but i didn't tested it so try it and tell me if it's work or not
PHP Code:
#include <amxmodx>
#include <cstrike>
#include <fakemeta>
#include <hamsandwich>
#if !defined client_disconnected
#define client_disconnected client_disconnect
#endif
new iUserName[ 33 ][ 32 ], bool:bRoundEnd
public plugin_init()
{
register_plugin( "Replace random player when the last player disconnect" , "1.0" , "Supremache" );
register_logevent("OnRoundEnd", 2, "1=Round_End")
register_event("HLTV", "OnRoundStart", "a", "1=0", "2=0")
}
public client_authorized( id )
{
get_user_name( id , iUserName[ id ] , charsmax( iUserName[ ] ) );
}
public client_disconnected( id )
{
GetLastPlayer( id )
}
public OnRoundStart( )
{
bRoundEnd = false;
}
public OnRoundEnd( )
{
bRoundEnd = true;
}
public GetLastPlayer( const id )
{
if( bRoundEnd )
{
return;
}
new iPlayers[ CsTeams ][ 32 ] , iTeamCounts[ CsTeams ] , iPlayer;
for ( new CsTeams:iTeam = CS_TEAM_T ; iTeam <= CS_TEAM_CT ; iTeam++ )
{
get_players( iPlayers[ iTeam ] , iTeamCounts[ iTeam ] , "ae" , ( iTeam == CS_TEAM_T ) ? "TERRORIST" : "CT" );
iPlayer = iPlayers[ iTeam ][ random( iTeamCounts[ iTeam ] ) ]
if( !iTeamCounts[ iTeam ] )
{
cs_set_user_team( iPlayer, cs_get_user_team( id ) )
set_pev( iPlayer, pev_health, pev( id, pev_health ) )
ExecuteHamB( Ham_CS_RoundRespawn, iPlayer )
client_print( 0, print_chat, "The last player %s has left the game from team %s, %s is the new one.", iUserName[ id ], iTeam, iUserName[ iPlayer ] )
}
}
}
__________________