I actually made a stock to test such things when I dont have players in my server, here is it:
PHP Code:
stock CreateBot(CsTeams:team, const szBotName[], bool:god) {
if(find_player("a", szBotName) > 0) {
log_to_file("BotSpawner.log", "This bot's name is already taken! (%s)", szBotName)
return -1
}
if(team != CS_TEAM_CT && team != CS_TEAM_T) {
log_to_file("BotSpawner.log", "Could not create bot, unknown team!")
return -1
}
new id = engfunc( EngFunc_CreateFakeClient, szBotName );
if( pev_valid( id ) ) {
engfunc( EngFunc_FreeEntPrivateData, id );
dllfunc( MetaFunc_CallGameEntity, "player", id );
set_user_info( id, "rate", "3500" );
set_user_info( id, "cl_updaterate", "25" );
set_user_info( id, "cl_lw", "1" );
set_user_info( id, "cl_lc", "1" );
set_user_info( id, "cl_dlmax", "128" );
set_user_info( id, "cl_righthand", "1" );
set_user_info( id, "_vgui_menus", "0" );
set_user_info( id, "_ah", "0" );
set_user_info( id, "dm", "0" );
set_user_info( id, "tracker", "0" );
set_user_info( id, "friends", "0" );
set_user_info( id, "*bot", "1" );
set_pev( id, pev_flags, pev( id, pev_flags ) | FL_FAKECLIENT );
set_pev( id, pev_colormap, id );
new szMsg[ 128 ];
dllfunc( DLLFunc_ClientConnect, id, szBotName, "127.0.0.1", szMsg );
dllfunc( DLLFunc_ClientPutInServer, id );
cs_set_user_team( id, team );
ExecuteHamB( Ham_CS_RoundRespawn, id );
set_user_godmode(id, god ? 1 : 0)
set_pev( id, pev_effects, pev( id, pev_effects ) | EF_NODRAW );
set_pev( id, pev_solid, SOLID_NOT );
dllfunc( DLLFunc_Think, id );
return id
}
return -1
}
returns id of bot created if success, else returns -1