.:: Bots United ::.  
filebase forums discord server github wiki web
cubebot epodbot fritzbot gravebot grogbot hpbbot ivpbot jkbotti joebot
meanmod podbotmm racc rcbot realbot sandbot shrikebot soulfathermaps yapb

Go Back   .:: Bots United ::. > Developer's Farm > General Bot Coding
General Bot Coding See what a pain it is to get those little mechs shooting around

Reply
 
Thread Tools
Creating a bot entity...!
Old
  (#1)
He@dShot
Member
 
He@dShot's Avatar
 
Status: Offline
Posts: 40
Join Date: Mar 2008
Location: Romania, Craiova
Warning Creating a bot entity...! - 14-05-2008

Here's my code:
//-----------------------------------------------------------------------
edict_t *bot;
int modelIndex;
char c_skin[32];
char c_name[32] = "Player";
char c_index[3];
char *infobuffer;

modelIndex = RANDOM_LONG(0,3); // Assign a random model

char dir_name[32];
char filename[128];
char ptr[128];

sprintf(ptr, "Creating bot \"%s\" using model %s with skill=%d\n", c_name, modelIndex);

GET_GAME_DIR(dir_name);

sprintf(filename, "%s\\models\\player\\%s", dir_name, c_skin);

bot = CREATE_FAKE_CLIENT(c_name); // Create the player entity

infobuffer = GET_INFOBUFFER( bot );

SET_CLIENT_KEY_VALUE( 1, infobuffer, "model", c_skin );
SET_CLIENT_KEY_VALUE( 1, infobuffer, "index", c_index );

MDLL_ClientConnect (bot, c_name, "127.0.0.1", ptr);
MDLL_ClientPutInServer (bot);
//-----------------------------------------------------------------------
What am I doing wrong ?
when I try it it crashes...!
How can I create a player entity in COunter-Strike ?
what functions do you use ?
  
Reply With Quote
Re: Creating a bot entity...!
Old
  (#2)
The Storm
Council Member / E[POD]bot developer
 
The Storm's Avatar
 
Status: Offline
Posts: 1,618
Join Date: Jul 2004
Location: Bulgaria
Default Re: Creating a bot entity...! - 15-05-2008

Put your code in code tags next time. Here's my bot creation function (its for Counter-Strike)
Code:
void BotPutInServer (int iTeam, const char *szName)
{
	edict_t *pEdict = g_engfuncs.pfnCreateFakeClient(szName);

	if (FNullEnt( pEdict ))
        {
		ALERT(at_console, "Max. Players reached.  Can't create bot!\n");
		return;
	}
	else
	{
		MDLL_ClientPutInServer( pEdict );

		pEdict->v.flags |= FL_FAKECLIENT;

		ENTITY_SET_KEYVALUE(pEdict, "_vgui_menus", "0");
		ENTITY_SET_KEYVALUE(pEdict, "_cl_autowepswitch", "1");
		ENTITY_SET_KEYVALUE(pEdict, "*bot", "1");
	}
}

Last edited by The Storm; 16-05-2008 at 00:25..
  
Reply With Quote
Re: Creating a bot entity...!
Old
  (#3)
He@dShot
Member
 
He@dShot's Avatar
 
Status: Offline
Posts: 40
Join Date: Mar 2008
Location: Romania, Craiova
Default Re: Creating a bot entity...! - 15-05-2008

Sorry, I don't know how to put the code in tags...
BTW: Thanx for answering member's questions...! Keep up the good work !
  
Reply With Quote
Re: Creating a bot entity...!
Old
  (#4)
He@dShot
Member
 
He@dShot's Avatar
 
Status: Offline
Posts: 40
Join Date: Mar 2008
Location: Romania, Craiova
Default Re: Creating a bot entity...! - 15-05-2008

BTW: I'm making a metamod plugin ! Does it have any difference ?
  
Reply With Quote
Re: Creating a bot entity...!
Old
  (#5)
The Storm
Council Member / E[POD]bot developer
 
The Storm's Avatar
 
Status: Offline
Posts: 1,618
Join Date: Jul 2004
Location: Bulgaria
Default Re: Creating a bot entity...! - 15-05-2008

My code example is from metamod plugin too.
  
Reply With Quote
Re: Creating a bot entity...!
Old
  (#6)
Whistler
Summoner
 
Whistler's Avatar
 
Status: Offline
Posts: 1,499
Join Date: Feb 2004
Location: Mist Village
Default Re: Creating a bot entity...! - 16-05-2008

probably the crash is because the c_skin char array has never been put into anything before it's used.
  
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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



Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
vBulletin Skin developed by: vBStyles.com