PHP Code:
#include <amxmodx>
new const Version[] = "0.2";
enum PlayerCount
{
HumanCount,
BotCount
}
new g_PlayerCounts[ PlayerCount ] , g_RoundEnd;
new g_pMaxBots;
new const g_BotsNeeded[ 32 ] =
{
0, // 0 humans
5, // 1 humans
5, // 2 humans
5, // 3 humans
5, // 4 humans
5, // 5 humans
5, // 6 humans
5, // 7 humans
4, // 8 humans
4, // 9 humans
3, // 10 humans
2, // 11 humans
1 // 12 humans
// 13-32 humans = 0 bots
}
public plugin_init()
{
register_plugin( "PodBot Manager", Version , "bugsy" );
register_logevent( "RoundEnd" , 2 , "1=Round_End" );
server_cmd( "pb removebots" );
set_cvar_num( "pb_bot_quota_match" , 0 );
set_cvar_num( "pb_minbots" , 0 );
set_pcvar_num( ( g_pMaxBots = get_cvar_pointer( "pb_maxbots" ) ) , g_BotsNeeded[ 1 ] );
}
public client_authorized( id )
{
g_PlayerCounts[ PlayerCount:is_user_bot( id ) ]++;
//Handle bots on map change
if ( !g_RoundEnd )
{
set_task( 5.0 , "BalanceBots" );
g_RoundEnd = get_systime();
}
}
public client_disconnected(id, bool:drop, Msg[], Len)
{
g_PlayerCounts[ PlayerCount:is_user_bot( id ) ]--;
}
public RoundEnd()
{
if ( ( get_systime() - g_RoundEnd ) > 5 )
{
BalanceBots();
}
g_RoundEnd = get_systime();
}
public BalanceBots()
{
new iNumBots = g_PlayerCounts[ BotCount ];
new iNumHumans = g_PlayerCounts[ HumanCount ];
new iBotsNeeded = g_BotsNeeded[ iNumHumans ];
new szName[ 32 ] , iBots[ 32 ] , iBotCount , i;
set_pcvar_num( g_pMaxBots , iNumHumans + iBotsNeeded );
if ( iNumBots > iBotsNeeded )
{
get_players( iBots , iBotCount , "d" );
while ( iNumBots-- > iBotsNeeded )
{
get_user_name( iBots[ i++ ] , szName , charsmax( szName ) );
server_cmd( "pb remove ^"%s^"" , szName );
}
}
else if ( iNumBots < iBotsNeeded )
{
while ( iNumBots++ < iBotsNeeded )
{
server_cmd( "pb add" );
}
}
}
Could someone please help me edit this to work with CSDM. As it is written bot balancing occurs at round end or after first player join on map change/server start. Deathmatch doesn't have rounds.
Please help and thanks.