Hello, i was trying to create a simple BOT with the following code.
PHP Code:
new g_iBotIndex;
public plugin_init( )
{
register_clcmd( "CreateBot", "BOT" );
}
public BOT( id )
{
g_iBotIndex = engfunc( EngFunc_CreateFakeClient, "Test Bot" );
if( !g_iBotIndex )
return PLUGIN_HANDLED;
console_print( id, "Bot criado com id %i", g_iBotIndex );
engfunc( EngFunc_FreeEntPrivateData, g_iBotIndex );
static szBlock[ 128 ];
//console_print( id, "Tentativa de conectar PRE" );
dllfunc( DLLFunc_ClientConnect, g_iBotIndex, "[SV] Pro 1 BOT", "127.0.0.1", szBlock );
console_print( id, "Tentativa de conectar POST" );
if( !is_user_connected( g_iBotIndex ) )
return PLUGIN_HANDLED;
console_print( id, "Bot conectado" );
dllfunc( DLLFunc_ClientPutInServer, g_iBotIndex );
console_print( id, "Bot entrou no server" );
set_pev( g_iBotIndex, pev_spawnflags, pev( g_iBotIndex, pev_spawnflags ) | FL_FAKECLIENT );
set_pev( g_iBotIndex, pev_flags, pev( g_iBotIndex,pev_flags ) | FL_FAKECLIENT );
return PLUGIN_HANDLED;
}
Sometimes it works and sometimes it just crashes my CS. As you can see i already used some debug messages, but when the game crashes, it doesn't show anything at all. What could be the problem?
Some more info: Using AMXX 1.8.3 +dev5154, Metamod-P v1.21p37.
__________________