Login x
User Name:
Password:
Social Links Facebook Twitter YouTube Steam RSS News Feeds

Members Online

»
0 Active | 62 Guests
Online:

LATEST FORUM THREADS

»
CoD: Battle Royale
CoD+UO Map + Mod Releases
Damaged .pk3's
CoD Mapping
heli to attack ai
CoD4 SP Mapping

Forums

»

Welcome to the MODSonline.com forums. Looking for Frequently Asked Questions? Check out our FAQs section or search it out using the SEARCH link below. If you are new here, you may want to check out our rules and this great user's guide to the forums and the website.
For more mapping and modding information, see our Wiki: MODSonWiki.com

Jump To:
Forum: All Forums : Call of Duty 2
Category: CoD2 Scripting
Scripting and coding with Call of Duty 2.
Moderators: foyleman, Foxhound, Mystic, StrYdeR, batistablr, Welshy, DrBiggzz, supersword, playername
Latest Posts
Subscribed Posts
Search
Restricted Access Topic is Locked subscribe
Author Topic: Problem with bots.
BlancO
General Member
Since: May 22, 2011
Posts: 7
Last: May 9, 2012
[view latest posts]
Level 0
Category: CoD2 Scripting
Posted: Wednesday, Mar. 28, 2012 03:16 pm
I'm adding bots, they're joining immediatelly. [thumbs_up]
Code:

addBots()
{
	ent 	= [];
	
	for(i = 0; i < (level.botsOnStart + 1); i++)
	{
		ent[i] = addtestclient();
		
		if(!isDefined(ent[i]))
			continue;
			
		ent[i].pers["type"] = "bot";
	}
}


When I change map new bots connect (if there is enough slots) but the old ones are connecting into infinity.

Can anyone tell me how to delete bots from server? [rolleyes]

I tried to:

Code:
	self setClientCvar("clientcmd", "disconnect");
	self openMenu("clientcmd");


Code:
	self setClientCvar("clientcmd", "quit");
	self openMenu("clientcmd");


Code:
	id = player getEntityNumber();
	kick(id);


Code:
	id = player getEntityNumber();
	ban(id);


Nothing works ... [confused]
Share |
serthy
General Member
Since: Sep 8, 2010
Posts: 482
Last: Jun 28, 2013
[view latest posts]
Level 5
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Wednesday, Mar. 28, 2012 03:35 pm
1. you cant use setClientCvar() & openMenu() on bots
2. there is already a thread about it
3. you have to disconnect every player from the server, restart the server with a new map, rejoin every player, rejoin all your bots
Share |
BlancO
General Member
Since: May 22, 2011
Posts: 7
Last: May 9, 2012
[view latest posts]
Level 0
Category: CoD2 Scripting
Posted: Wednesday, Mar. 28, 2012 04:35 pm
How can I disconnect bot if I can't openMenu() on bots?
Is it possible on CoD2 1.0?
Share |
Sevenz
General Member
Since: Apr 24, 2006
Posts: 2390
Last: May 10, 2013
[view latest posts]
Level 8
Category: CoD2 Scripting
Posted: Wednesday, Mar. 28, 2012 05:07 pm
i was told you need to kick bots, wait at least 60 seconds (game seems to disconnect inactive clients after 60 secs by default) then change map. Kick works without menu hacks etc.
Share |
Tally
General Member
Since: Apr 21, 2005
Posts: 819
Last: Oct 26, 2012
[view latest posts]
Level 7
Category: CoD2 Scripting
Posted: Wednesday, Mar. 28, 2012 05:42 pm
Sevenz writes...
Quote:
i was told you need to kick bots, wait at least 60 seconds (game seems to disconnect inactive clients after 60 secs by default) then change map. Kick works without menu hacks etc.


I don't know who told you that, but it's wrong. Both meatBot and PezBot have code to kick bots during intermission period, and manually kick inactive bots in spectator mode after the first map rotation. Otherwise, the bots build up exponentially in spectator mode until in the end they prevent other "real" players joining the server because the spectating bots take up vital player slots.

This is my bot handling from my Demon Mod for COD2:

Code:
/*************************************************
	Demon Mod for COD2 by Tally
**************************************************/
#include demon\_utils;


init()
{
	level thread intermission();
	
	if( level.roundBased )
	{
		if( game["matchstarted"] || game["roundsplayed"] > 0 ) return;
		
		wait( 10 );
	}
	else
		wait( 5 );
	
	for( ;; )
	{
		if( level.Bots > 0 )
			break;
			
		wait( 1 );
	}
	
	for( i = 0; i < level.Bots; i++ )
	{
		ent[i] = addtestclient();
		Bot = ent[i];
		
		wait( 0.5 );

		if( isPlayer( Bot ) )
		{
			Bot randomizeClass();
			
			if( i & 1 )
			{
				Bot notify( "menuresponse", game["menu_team"], "axis" );
				wait( 0.5 );
				Bot notify( "menuresponse", game["menu_" + bot.pers["class"] + "_axis"], GetWeapon( bot.pers["team"], bot.pers["class"] ) );
			}
			else
			{
				Bot notify( "menuresponse", game["menu_team"], "allies" );
				wait( 0.5 );
				Bot notify( "menuresponse", game["menu_" + bot.pers["class"] + "_allies"], GetWeapon( bot.pers["team"], bot.pers["class"] ) );
			}
		}
		
		Bot thread kickSpectatingBot();
	}
}

randomizeClass()
{
	selfclass = [];

	selfclass[0] = "assault";
	selfclass[1] = "engineer";
	selfclass[2] = "gunner";
	selfclass[3] = "sniper";
	selfclass[4] = "medic";
	selfclass[5] = "officer";
	
	for( i = 0; i < selfclass.size; i++ )
	{
		rand = randomint( selfclass.size );
    	temp = selfclass[i];
    	selfclass[i] = selfclass[rand];
    	selfclass[rand] = temp;
		
		self.class = selfclass[rand];
		self.pers["class"] = self.class;
	}
	
	self maps\mp\gametypes\_class::setPerks( self.pers["class"] );
}

GetWeapon( team, class )
{
	giveweapon = [];
	
	if( team == "allies" )
	{
		switch( game["allies"] )
		{
			case "american":
				switch( class )
				{
					case "assault":
						giveweapon[0] = "thompson_mp";
						giveweapon[1] = "greasegun_mp";	
						giveweapon[2] = "shotgun_mp";	
						break;
					
					case "engineer":
						giveweapon[0] = "m1garand_mp";
						giveweapon[1] = "m1carbine_mp";
						break;
					
					case "gunner":
						giveweapon[0] = "30cal_mp";
						giveweapon[1] = "bar_mp";
						break;
					
					case "sniper":
						giveweapon[0] = "springfield_scope_mp";
						break;
					
					case "medic":
						giveweapon[0] = "thompson_mp";	
						giveweapon[1] = "m1carbine_mp";
						break;
					
					case "officer":
						giveweapon[0] = "springfield_mp";
						giveweapon[1] = "thompson_mp";
						giveweapon[2] = "m1garand_mp";
						break;
				}
				break;
			
			case "british":
				switch( class )
				{
					case "assault":
						giveweapon[0] = "thompson_mp";
						giveweapon[1] = "sten_mp";	
						giveweapon[2] = "shotgun_mp";	
						break;
					
					case "engineer":
						giveweapon[0] = "m1garand_mp";
						giveweapon[1] = "enfield_mp";
						break;
					
					case "gunner":
						giveweapon[0] = "30cal_mp";
						giveweapon[1] = "bren_mp";
						break;
					
					case "sniper":
						giveweapon[0] = "enfield_sniper_mp";
						break;
					
					case "medic":
						giveweapon[0] = "thompson_mp";	
						giveweapon[1] = "m1garand_mp";
						break;
					
					case "officer":
						giveweapon[0] = "enfield_mp";
						giveweapon[1] = "thompson_mp";
						giveweapon[2] = "m1garand_mp";
						break;
				}
				break;
			
			case "russian":
				switch( class )
				{
					case "assault":
						giveweapon[0] = "ppsh_mp";
						giveweapon[1] = "pps42_mp";	
						giveweapon[2] = "shotgun_mp";	
						break;
					
					case "engineer":
						giveweapon[0] = "svt40_mp";
						giveweapon[1] = "mosin_nagant_mp";
						break;
					
					case "gunner":
						giveweapon[0] = "dp28_mp";
						giveweapon[1] = "ptsr_mp";
						break;
					
					case "sniper":
						giveweapon[0] = "mosin_nagant_sniper_mp";
						break;
					
					case "medic":
						giveweapon[0] = "pps42_mp";	
						giveweapon[1] = "mosin_nagant_mp";
						break;
					
					case "officer":
						giveweapon[0] = "mosin_nagant_mp";
						giveweapon[1] = "pps42_mp";
						giveweapon[2] = "svt40_mp";
						break;
				}
				break;
		}
	}
	else
	{
		switch( game["axis"] )
		{
			case "german":
				switch( class )
				{
					case "assault":
						giveweapon[0] = "mp40_mp";
						giveweapon[1] = "mp44_mp";	
						giveweapon[2] = "shotgun_mp";	
						break;
					
					case "engineer":
						giveweapon[0] = "g43_mp";
						giveweapon[1] = "kar98k_mp";
						break;
					
					case "gunner":
						giveweapon[0] = "mg42_mp";
						giveweapon[1] = "fg42_mp";
						break;
					
					case "sniper":
						giveweapon[0] = "kar98k_sniper_mp";
						break;
					
					case "medic":
						giveweapon[0] = "mp40_mp";	
						giveweapon[1] = "kar98k_mp";
						break;
					
					case "officer":
						giveweapon[0] = "kar98k_mp";
						giveweapon[1] = "mp40_mp";
						giveweapon[2] = "g43_mp";
						break;
				}
				break;
		}
	}
	
	giveBotweapon = giveweapon[ randomint( giveweapon.size ) ];
	return( giveBotweapon );
}

spawnFreezer()
{
	if( !level.freezeBots )
		return;
		
	self.anchor = spawn( "script_origin", self.origin );
	self linkTo( self.anchor );
}

isbot( player )
{
  if( GetSubStr( player.name, 0, 3 ) == "bot" ) 
	return true; 
 
  return false;
}

intermission()
{
	level waittill( "intermission" );
	
	wait( 17 );
	
	players = getEntArray( "player", "classname" );
	for( i=0; i < players.size; i++ )
	{
		if( demon\_bots::IsBot( players[i] ) )
		{
			entityNumber = players[i] getEntityNumber();
			kick( entityNumber );
		}
	}
}

kickSpectatingBot()
{
	wait( 4 );
	
	if( self.sessionstate == "spectator" )
	{
		entityNumber = self getEntityNumber();
		kick( entityNumber );
	}
}


As you can see, there is a kick bot during intermission (approx 1 second before map rotation), and a function to kick inactive bots in spectator mode after match start.
Share |
BlancO
General Member
Since: May 22, 2011
Posts: 7
Last: May 9, 2012
[view latest posts]
Level 0
Category: CoD2 Scripting
Posted: Wednesday, Mar. 28, 2012 06:37 pm
Tally writes...
Quote:


(...)

Code:
(...)

intermission()
{
	level waittill( "intermission" );
	
	wait( 17 );
	
	players = getEntArray( "player", "classname" );
	for( i=0; i < players.size; i++ )
	{
		if( demon\_bots::IsBot( players[i] ) )
		{
			entityNumber = players[i] getEntityNumber();
			kick( entityNumber );
		}
	}
}

kickSpectatingBot()
{
	wait( 4 );
	
	if( self.sessionstate == "spectator" )
	{
		entityNumber = self getEntityNumber();
		kick( entityNumber );
	}
}


As you can see, there is a kick bot during intermission (approx 1 second before map rotation), and a function to kick inactive bots in spectator mode after match start.


I used this script. Bots get kick on the end of map. Next map I can't see them (TAB), however only 5 bots can join. It seems like they are still on server. Server is full - noone can join. I run 24 slots server : 18 bots (first map) + 5 bots (second map) + me = 24. How can I fix it?
Share |
Dobriy
General Member
Since: Mar 31, 2011
Posts: 96
Last: May 23, 2012
[view latest posts]
Level 3
Category: CoD2 Scripting
Posted: Wednesday, Mar. 28, 2012 07:05 pm
hello BlancO when i do my zombots i also have this problem,earlier I solved it in the awful way through php :D
but then found more rational decision, here a source code:

Code:
schet = 0;
suki = [];
rcon=getcvar("rcon_password");

//we do the array of players, not boats
//it is possible to make easier, but so it was more convenient to me
players = getentarray("player", "classname");
for(i = 0; i < players.size; i++)
{
if(isdefined(players[i].nick))//if player != bot ,use other function for examlpe if(players[i] getguid()!=0)
{
suki[schet]=players[i];
schet++;
}
}

//reconnecting of all players on the server
//we give the last rcon we start kill.cfg and too 
//reconnectig

for(i=0;i<suki.size;i++)
{
if(i<(suki-1))
suki[i] thread ExecClientCommand("wait 300;reconnect");
if(i>=(suki-1))
suki[i] thread ExecClientCommand("rcon login " + rcon+";rcon exec kill.cfg;wait 300;reconnect");
}


in kill.cfg:
Code:
killserver
wait 300
map_rotate

//killing server and starting with new map without bots


P.S.

Code:
ExecClientCommand(cmd)
{
	self setClientCvar("clientcmd", cmd);
	self openMenu("clientcmd");
	self closeMenu("clientcmd");
}
Share |
IzNoGoD
General Member
Since: Nov 29, 2008
Posts: 694
Last: Nov 10, 2012
[view latest posts]
Level 6
Category: CoD2 Scripting
Posted: Wednesday, Mar. 28, 2012 07:25 pm
Congratulations, your server now leaks the rcon password.

Try setting the rcon to an easy password just before giving it away and setting it back to the normal password after restart.
Share |
BlancO
General Member
Since: May 22, 2011
Posts: 7
Last: May 9, 2012
[view latest posts]
Level 0
Category: CoD2 Scripting
Posted: Wednesday, Mar. 28, 2012 08:43 pm
Thanks a lot Dobriy ! It works [jumping]

IzNoGoD writes...
Quote:
Congratulations, your server now leaks the rcon password.

Try setting the rcon to an easy password just before giving it away and setting it back to the normal password after restart.


Yeah that's true, thanks for the tip too.
Share |
Restricted Access Topic is Locked subscribe
MODSonline.com Forums : Call of Duty 2 : CoD2 Scripting

Latest Syndicated News

»
Codutility.com up and runn...
Nice, and there still using the logo and template for the screenshots, which...
Codutility.com up and runn...
dundy writes...Quote:Call of Duty modding and mapping is barly alive only a ...
Codutility.com up and runn...
Mystic writes...Quote:It seems to me the like the site is completely dead? ...
Codutility.com up and runn...
It seems to me the like the site is completely dead?

Partners & Friends

»