Senior Member
Join Date: Feb 2011
Location: São Paulo, Brazil
|
06-22-2018
, 18:19
Re: Crash when creating a bot
|
#24
|
Quote:
Originally Posted by shauli
That's good, now he's properly connected and joined a team. All you have to do is to make him "running" with EngFunc_RunPlayerMove, here's an example:
PHP Code:
new g_fwdStartFrame;
public BOT( id ) { g_iBotIndex = engfunc( EngFunc_CreateFakeClient, "[SV] Pro 1 BOT" );
if( !g_iBotIndex ) return PLUGIN_HANDLED;
engfunc( EngFunc_FreeEntPrivateData, g_iBotIndex );
//new fOrigin[ 3 ]; pev( id, pev_origin, fOrigin );
static szBlock[ 128 ];
dllfunc( DLLFunc_ClientConnect, g_iBotIndex, "[SV] Pro 1 BOT", "127.0.0.1", szBlock );
if( !is_user_connected( g_iBotIndex ) ) return PLUGIN_HANDLED;
dllfunc( DLLFunc_ClientPutInServer, g_iBotIndex );
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 );
//cs_set_user_team( g_iBotIndex, CS_TEAM_CT, CS_CT_GSG9 );
engclient_cmd( g_iBotIndex, "jointeam", "2" ); engclient_cmd( g_iBotIndex, "joinclass", "1" );
ExecuteHamB( Ham_CS_RoundRespawn, g_iBotIndex );
//dllfunc( DLLFunc_Spawn, g_iBotIndex );
if( !g_fwdStartFrame ) g_fwdStartFrame = register_forward( FM_StartFrame, "fwdStartFrame", 1 );
if( !is_user_alive( g_iBotIndex ) ) return HAM_IGNORED;
//set_user_rendering( g_iBotIndex, kRenderFxNone, 255, 255, 255, kRenderNormal, 25 ); // 16
//fm_set_rendering( g_iBotIndex, kRenderNormal, 255, 255, 255, kRenderNormal, 25 );
//fm_set_user_rendering( g_iBotIndex, kRenderFxGlowShell, 0, 0, 0, kRenderNormal, 25 );
//set_pev( g_iBotIndex, pev_origin, fOrigin );
return PLUGIN_HANDLED; }
public fwdStartFrame( ) { if( g_iBotIndex ) { static Float:frametime; global_get( glb_frametime, frametime );
//This is for fake players only. It goes like this: engfunc( EngFunc_RunPlayerMove, client_index, view angle, forward speed, side speed, up speed, buttons, impulse, duration ) //The frametime*1000.0 is a nice and simple way to calculate a duration by the frametime. You don't need to change this. //If you're going to just spawn the bot and set the velocity/origin yourself, all this stuff can stay at 0.0. //If you're going to do it more complicated than that, change the values to whatever suits you the best.
engfunc( EngFunc_RunPlayerMove, g_iBotIndex, Float:{ 0.0, 0.0, 0.0 }, 0.0, 0.0, 0.0, 0, 0, floatround( frametime * 1000.0 ) ); }
return FMRES_IGNORED; }
|
Tbh i didn't understand at all what this code does, but for some reason after inserting this the bot appeared (He is finally visible). . I believed that creating and spawning him was enough. Thank you for everything,
__________________
Last edited by marcelowzd; 06-22-2018 at 18:20.
|
|