Raised This Month: $12 Target: $400
 3% 

PODBots control(kick or add) automatically.


Post New Thread Reply   
 
Thread Tools Display Modes
iveto69
Member
Join Date: Aug 2018
Old 04-15-2019 , 02:08   Re: PODBots control(kick or add) automatically.
Reply With Quote #11

Quote:
Originally Posted by Bugsy View Post
Having a hard time figuring out how to disable the automatic bot management. When my plugin kicks one, the module re-adds automatically.
or this is:


Human players = 1, X bots = 5
Human players = 1, X bots = 5
Human players = 2, X bots = 5
Human players = 3, X bots = 5
Human players = 4, X bots = 5
Human players = 5, X bots = 5
Human players = 6, X bots = 5
Human players = 7, X bots = 5
Human players = 8, X bots = 5
Human players = 9, X bots = 5
Human players = 10, X bots = 0
Human players = 11, X bots = 0
Human players = 12, X bots = 0
......
Human players = 20, X bots = 0
iveto69 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-15-2019 , 21:07   Re: PODBots control(kick or add) automatically.
Reply With Quote #12

I understand what you wanted, but as I said, I cannot disable to automatic podbot bot management. It keeps adding as I kick them to balance the bot count.

Try this:
Code:
pb_minbots 5
pb_maxbots 5
pb_bot_quota_match 5
__________________
Bugsy is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-16-2019 , 19:30   Re: PODBots control(kick or add) automatically.
Reply With Quote #13

Bot balancing occurs at round end or after first player join on map change/server start. I could not thoroughly test as I do not run a server so I could only test with 1 player.

Edit: Made update to adjust pb_maxbots cvar when balancing bots at round end.
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" );
        }
    }

__________________

Last edited by Bugsy; 04-30-2019 at 16:53.
Bugsy is offline
iveto69
Member
Join Date: Aug 2018
Old 04-17-2019 , 03:44   Re: PODBots control(kick or add) automatically.
Reply With Quote #14

Thanks ! I will test it.
iveto69 is offline
iveto69
Member
Join Date: Aug 2018
Old 04-18-2019 , 08:21   Re: PODBots control(kick or add) automatically.
Reply With Quote #15

I'm sorry, but it does not work. The plug-in is compiled, the server accepts it in the amx list, but it does not work.
I'm sorry, I know that you are quite experienced and you understand these things well... , but maybe what I want is unattainable ?
iveto69 is offline
Mordekay
Squirrel of Fortune
Join Date: Apr 2006
Location: Germany
Old 04-18-2019 , 13:27   Re: PODBots control(kick or add) automatically.
Reply With Quote #16

http://forums.bots-united.com/forumdisplay.php?f=47
This is the official forum for pod-bot. You may would ask there.
__________________

Mordekay is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-18-2019 , 18:41   Re: PODBots control(kick or add) automatically.
Reply With Quote #17

Can you be specific about what does not work? Like I said, when I test by myself, it works exactly as expected. What you requested is not complicated at all.

Server start/map change and no humans = no bots
Server start/map change, I connect, 5 bots join
__________________

Last edited by Bugsy; 04-18-2019 at 18:42.
Bugsy is offline
iveto69
Member
Join Date: Aug 2018
Old 04-30-2019 , 13:28   Re: PODBots control(kick or add) automatically.
Reply With Quote #18

Hi Bugsy ,

I apologize for the long pause. I was not at home... , and for a few days, I tested dozens of options to solve the problem , I also searched for similar topics on the Internet.
I have an idea and I want to share it with you:
For example: in the podbod.cfg I have the following settings:

Code:
pb_minbots 4
pb_maxbots 8
pb_bot_quota_match 0
..
..
pb add
pb add
pb add
pb add
pb add
pb add
pb add
pb add

And:
pb fillserver
And:
pb fillserver

And, when I submit a console manual command pb_minbots 3, or pb_minbots 2, or ... pb_minbots 0 - or pb_minbots 5, pb_minbots 6... - the minimum number of bots playing on the server is automatically changed:- 3, 2...0 or 6, 7 ... I'm sorry a lot for my wrong requests so far... , that's what I wanted: that's what I wanted: a way to get rid of these remaining bots, with the command "pb_minbots 4" in the podbot.cfg, then when the human players on the server reach the number of remaining free slots, bots to release these 4 slots.
There is another condition: If the number of bots drops below a certain value - enable a command to return the original minimum number of bots: in this case we have: pb_minbots 4 !
That is all !?
Or in short: Plug-in to track the number of players: If their number exceeds a value, enable the command:
pb_minbots 4 , if the number of players drops below another set value - enable the command:
pb_minbots 0 !?

A similar plug-in that tracks the number of human players, but removes or adds bots-spectators is here (only for ideas, if it helps with something):

Code:
#include < amxmodx >
#include < cstrike >
#include < fakemeta >

enum Cvars
{
	botname1,
	botname2,
	minplayers,
	starttime,
	endtime,
	onecon,
	onebot,
	norounds
};

new const cvar_names[ Cvars ][] =
{
	"amx_botname",
	"amx_botname2",
	"amx_minplayers",
	"amx_starttime",
	"amx_endtime",
	"amx_onecon",
	"amx_onebot",
	"amx_norounds"
};

new const cvar_defaults[ Cvars ][] =
{
	"Bot",
	"Bot 2",
	"10",
	"00",
	"12",
	"0",
	"0",
	"0"
};

new cvar_pointer[ Cvars ];
new bool:g_isTime = false;
new bool:g_ePlayers = false;
new bool:g_isFirstRound = true;
new g_BotNum = 0, g_maxplayers, g_bID1, g_bID2;

new const g_ConfigFile[] = "addons/amxmodx/configs/kgbbots.cfg"

public plugin_init() 
{
	register_plugin("KGB Bots", "2.3", "OvidiuS & Desikac")
	register_cvar("kgbbots", "1" , (FCVAR_SERVER|FCVAR_SPONLY))
	
	register_logevent("Event_RoundEnd", 2, "1=Round_End");
	register_event("HLTV", "Event_NewRound", "a", "1=0", "2=0");
	
	for ( new Cvars:i = botname1 ; i < Cvars ; i++ )
		cvar_pointer[ i ] = register_cvar( cvar_names[ i ] , cvar_defaults[ i ] );
	
	g_maxplayers = get_maxplayers();
	server_cmd("exec %s", g_ConfigFile)
	set_task(3.0, "isit")
}

public isit() {
	if(get_pcvar_num(cvar_pointer[norounds]))
		set_task(30.0, "CheckConditions",0,"",0,"b")
}

public plugin_precache() 
{
	if(!file_exists(g_ConfigFile)) 
	{
		write_file(g_ConfigFile, "KGB Bots - Podesavanja^n")
		write_file(g_ConfigFile, "amx_botname ^"KGB Bot1^"   //Ime prvog bota")
		write_file(g_ConfigFile, "amx_botname2 ^"KGB Bot2^"   //Ime drugog bota")
		write_file(g_ConfigFile, "amx_minplayers ^"10^"   //Botovi ce biti ubaceni samo ako je broj igraca manji od ove vrednosti.")
		write_file(g_ConfigFile, "amx_starttime ^"0^"   //Od koliko sati da botovi budu na serveru?")
		write_file(g_ConfigFile, "amx_endtime ^"12^"   //Do koliko sati da botovi budu na serveru?")
		write_file(g_ConfigFile, "amx_onecon ^"0^"   //Da li treba da bude ispunjen samo jedan uslov da bi se dodali botovi?")
		write_file(g_ConfigFile, "amx_onebot ^"0^"   //Da li da plugin ubacuje samo jednog bota?")
		write_file(g_ConfigFile, "amx_norounds ^"0^"   //Da li se na ovom serveru ne zavrsava runda?")
	}
}

public Event_RoundEnd()
{
	if (!g_isFirstRound)
		return;
 
	g_isFirstRound = false;
}

public Event_NewRound()
{
	if(g_isFirstRound)
		return;
		
	CheckConditions();
}

public CheckConditions()
{
	static iHours, m, s
	time(iHours, m, s)

	new iMin = get_pcvar_num(cvar_pointer[ starttime ]);
	new iMax = get_pcvar_num(cvar_pointer[ endtime ]);
	
	if(iMin == iMax)
		g_isTime = true;
	else if(iMin > iMax) 
	{
		switch(iHours) 
		{
			case 0..11: 
			{
				if(iMin >= iHours && iMax > iHours)
					g_isTime = true;
			}
			case 12..23: 
			{
				if(iMin <= iHours && iMax < iHours)
					g_isTime = true;
			}
		}
	}
	else if(iMin <= iHours && iMax > iHours)
		g_isTime = true;
	else 
		g_isTime = false;
		
	new iNum, iPlayers[32];
	get_players(iPlayers, iNum, "c");
	
	if(iNum <= get_pcvar_num(cvar_pointer[minplayers]))
		g_ePlayers = true;
	else
		g_ePlayers = false;

	if(g_maxplayers - iNum < 2)
		g_ePlayers = false;
	
	if(get_pcvar_num(cvar_pointer[minplayers]) == 0)
		g_ePlayers = true
	
	new iCondition = get_pcvar_num(cvar_pointer[ onecon ]);
	if( (!g_ePlayers && g_isTime || !g_isTime && g_ePlayers) && iCondition) 
	{
		g_isTime = true;
		g_ePlayers = true;
	}
	
	
		
	if((g_isTime && g_ePlayers) && !g_BotNum)
	{
		if(!get_pcvar_num(cvar_pointer[onebot]))
			set_task(1.5, "Task_AddBot")
		set_task(2.8, "Task_AddBot")
	}
	else if((!g_isTime || !g_ePlayers) && 0 < g_BotNum <= 2 )
	{
		g_BotNum = 0;
		server_cmd("kick #%d", g_bID1)
		server_cmd("kick #%d", g_bID2)
	}
}

public Task_AddBot()
{
	static iBot;
	new iBotName[35];
	
	switch(g_BotNum)
	{
		case 0: get_pcvar_string(cvar_pointer[ botname1 ], iBotName, charsmax( iBotName ));
		case 1:	get_pcvar_string(cvar_pointer[ botname2 ], iBotName, charsmax( iBotName ));
		case 2: return;
	}

	iBot = engfunc( EngFunc_CreateFakeClient, iBotName );
	
	if(!iBot)
		return;
		
	dllfunc( MetaFunc_CallGameEntity, "player", iBot );
	set_pev( iBot, pev_flags, FL_FAKECLIENT );

	set_pev( iBot, pev_model, "" );
	set_pev( iBot, pev_viewmodel2, "" );
	set_pev( iBot, pev_modelindex, 0 );

	set_pev( iBot, pev_renderfx, kRenderFxNone );
	set_pev( iBot, pev_rendermode, kRenderTransAlpha );
	set_pev( iBot, pev_renderamt, 0.0 );

	set_pdata_int( iBot, 114, 3 );
	cs_set_user_team( iBot, CS_TEAM_UNASSIGNED );
	
	switch(g_BotNum) 
	{
		case 0: g_bID1 = get_user_userid(iBot);
		case 1: g_bID2 = get_user_userid(iBot);
	}
	g_BotNum++;
}
Thank you for all your attention and I apologize once again for my vague requests !

Last edited by iveto69; 04-30-2019 at 13:35.
iveto69 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-30-2019 , 16:52   Re: PODBots control(kick or add) automatically.
Reply With Quote #19

If you can, go back to the default podbotcfg. Most importantly, remove all pb add commands as this plugin will handle everything. When my plugin loads, it calls pb removebots which appears to disable the built-in podbot management and it also sets the minbots/maxbots as needed.

I made additional tweaks to the code above, I found that podbot factors human players into the pb_maxbots count so I made it adjust that cvar when it balances out the bots at round end.
__________________
Bugsy is offline
iveto69
Member
Join Date: Aug 2018
Old 05-03-2019 , 08:01   Re: PODBots control(kick or add) automatically.
Reply With Quote #20

Hi again Bugsy,

this plugin now works, but does not exactly do what we debated - to have at least a few bots to a certain number of players. When starting the server, if there are no players - there are no bots, which is good. But - from the moment players start entering the server, bots are reduced, and after the number of players exceeds 5, bots on the server are gone(for example: 1player->5bots, 2players->4bots, 3players->3bots, 4players->2bots, 5players->1bots, 6players->0bots, 7players->0bots, 8players->0bots...32players->0bots- this is), no matter how many players(5 or 32) are on the server. I think if you have to always have these certain number of bots: 5, 5, 5, 4, 3, ...0 - this must be changed so:
- new g_PlayerCounts[ PlayerCount ] , g_RoundEnd;
new g_pMaxBots;

Here's how:
- new g_PlayerCounts[ PlayerCount ] , g_RoundEnd;
new g_pMinBots;

I tried to change them anywhere in the plugin, I compiled it, but... the plugin simply fills the entire bots server!

I do not want to confuse you sir, but can the plugin just track the number of players and when the minimum required number of bots must be changed - to submit this command in the console: pb_minbots 5, or pb_minbots 4... pb_minbots 0. When I do this manually through the console - this works ( with such settings in the configuration file: pb_minbots 3
pb_maxbots 7
pb_bot_quota_match 0!?

In order not to be confused, the plug-in should start 180sec after the map starts, and to do something of this kind(only for example-i do not understand by scripting):

Code:
{
    server_cmd("pb removebots"), // 0 humans //
    server_cmd("pb_minbots 5"), // 1 humans //
    server_cmd("pb_minbots 5"), // 2 humans //
    server_cmd("pb_minbots 5"), // 3 humans //
    server_cmd("pb_minbots 3"), // 4 humans //
    server_cmd("pb_minbots 5"), // 5 humans //
    server_cmd("pb_minbots 5"), // 6 humans //
    server_cmd("pb_minbots 5"), // 7 humans //
    server_cmd("pb_minbots 4"), // 8 humans //
    server_cmd("pb_minbots 4"), // 9 humans //
    server_cmd("pb_minbots 3"), // 10 humans //
    server_cmd("pb_minbots 2"), // 11 humans //
    server_cmd("pb_minbots 1")  // 12 humans //
                                               // 13-32 humans = pb removebots // 0 bots
}
Thank you for your attention !!!
Thanks !

Soorry , but this is : "...I made it adjust that cvar when it balances out the bots at round end..." ??? What is ? The server is DeathMatch... , no round end ?! I want to apologize for not telling you so far.

Last edited by iveto69; 05-03-2019 at 16:52.
iveto69 is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 19:28.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode