.:: Bots United ::.

.:: Bots United ::. (http://forums.bots-united.com/index.php)
-   General Bot Coding (http://forums.bots-united.com/forumdisplay.php?f=24)
-   -   Creating a bot entity...! (http://forums.bots-united.com/showthread.php?t=6780)

He@dShot 14-05-2008 23:05

Creating a bot entity...!
 
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 ?:excl:

The Storm 15-05-2008 19:40

Re: Creating a bot entity...!
 
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");
        }
}


He@dShot 15-05-2008 20:05

Re: Creating a bot entity...!
 
Sorry, I don't know how to put the code in tags...
BTW: Thanx for answering member's questions...;)! Keep up the good work !

He@dShot 15-05-2008 20:07

Re: Creating a bot entity...!
 
BTW: I'm making a metamod plugin ! Does it have any difference ?

The Storm 15-05-2008 22:04

Re: Creating a bot entity...!
 
My code example is from metamod plugin too. :)

Whistler 16-05-2008 08:22

Re: Creating a bot entity...!
 
probably the crash is because the c_skin char array has never been put into anything before it's used.


All times are GMT +2. The time now is 02:03.

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.