Thread: PodBot Manager
View Single Post
Author Message
iclassdon
AlliedModders Donor
Join Date: May 2006
Old 01-21-2020 , 14:45   PodBot Manager
Reply With Quote #1

PHP Code:
#include <amxmodx>

new const Version[] = "0.2";

enum PlayerCount
{
    
HumanCount,
    
BotCount
}

new 
g_PlayerCountsPlayerCount ] , g_RoundEnd;
new 
g_pMaxBots;

new const 
g_BotsNeeded32 ] = 
{
    
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" "1=Round_End" );
    
    
server_cmd"pb removebots" );
    
    
set_cvar_num"pb_bot_quota_match" );
    
set_cvar_num"pb_minbots" );
    
set_pcvar_num( ( g_pMaxBots get_cvar_pointer"pb_maxbots" ) ) , g_BotsNeeded] );
}

public 
client_authorizedid )
{
    
g_PlayerCountsPlayerCount:is_user_botid ) ]++;
    
    
//Handle bots on map change
    
if ( !g_RoundEnd )
    {
        
set_task5.0 "BalanceBots" );
        
g_RoundEnd get_systime();
    }
}

public 
client_disconnected(idbool:dropMsg[], Len)   
{
    
g_PlayerCountsPlayerCount:is_user_botid ) ]--;
}

public 
RoundEnd()
{
    if ( ( 
get_systime() - g_RoundEnd ) > )
    {
        
BalanceBots();
    }
    
    
g_RoundEnd get_systime();
}

public 
BalanceBots()
{
    new 
iNumBots g_PlayerCountsBotCount ];
    new 
iNumHumans g_PlayerCountsHumanCount ];
    new 
iBotsNeeded g_BotsNeedediNumHumans ];
    new 
szName32 ] , iBots32 ] , iBotCount i;
    
    
set_pcvar_numg_pMaxBots iNumHumans iBotsNeeded );
    
    if ( 
iNumBots iBotsNeeded )
    {
        
get_playersiBots iBotCount "d" );
        
        while ( 
iNumBots-- > iBotsNeeded )
        {
            
get_user_nameiBotsi++ ] , szName charsmaxszName ) );
            
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.

Last edited by iclassdon; 01-21-2020 at 14:46.
iclassdon is offline
Send a message via MSN to iclassdon