Raised This Month: $32 Target: $400
 8% 

Crash when creating a bot


Post New Thread Reply   
 
Thread Tools Display Modes
shauli
Member
Join Date: Jun 2018
Old 06-22-2018 , 15:47   Re: Crash when creating a bot
Reply With Quote #21

Quote:
Originally Posted by marcelowzd View Post
Now that you said it, he is very far away, but i can see his name in front of me.
I think I know what your problem is.
You used cs_set_user_team without the client (or in this case, your fake player) actually joining a team via 'jointeam' and then 'joinclass', so he's floating somewhere around the map and teleporting to some weird origins without any explanations.

Try to do engclient_cmd(g_iBotIndex, "jointeam", "1"); and joinclass 1.

Edit: looked at Bugys's code, i'm pretty certain that's the problem. He did this:
PHP Code:
    engclient_cmdg_BotID"jointeam"szTeam ); 
    
engclient_cmdg_BotID"joinclass""1" ); 
Do this instead of cs_set_user_team.

Last edited by shauli; 06-22-2018 at 15:49.
shauli is offline
marcelowzd
Senior Member
Join Date: Feb 2011
Location: São Paulo, Brazil
Old 06-22-2018 , 17:16   Re: Crash when creating a bot
Reply With Quote #22

Quote:
Originally Posted by shauli View Post
I think I know what your problem is.
You used cs_set_user_team without the client (or in this case, your fake player) actually joining a team via 'jointeam' and then 'joinclass', so he's floating somewhere around the map and teleporting to some weird origins without any explanations.

Try to do engclient_cmd(g_iBotIndex, "jointeam", "1"); and joinclass 1.

Edit: looked at Bugys's code, i'm pretty certain that's the problem. He did this:
PHP Code:
    engclient_cmdg_BotID"jointeam"szTeam ); 
    
engclient_cmdg_BotID"joinclass""1" ); 
Do this instead of cs_set_user_team.
Same thing, exactly the same thing to be honest. He is still very far in the radar but i still can se his name and health.

Code
PHP Code:
public BOTid )
{
    
g_iBotIndex engfuncEngFunc_CreateFakeClient"[SV] Pro 1 BOT" );

    if( !
g_iBotIndex )
        return 
PLUGIN_HANDLED;

    
engfuncEngFunc_FreeEntPrivateDatag_iBotIndex );

    
//new fOrigin[ 3 ]; pev( id, pev_origin, fOrigin ); 

    
static szBlock128 ];

    
dllfuncDLLFunc_ClientConnectg_iBotIndex"[SV] Pro 1 BOT""127.0.0.1"szBlock );

    if( !
is_user_connectedg_iBotIndex ) )
        return 
PLUGIN_HANDLED;

    
dllfuncDLLFunc_ClientPutInServerg_iBotIndex );

    
set_pevg_iBotIndexpev_spawnflagspevg_iBotIndexpev_spawnflags ) | FL_FAKECLIENT ); 
    
set_pevg_iBotIndexpev_flagspevg_iBotIndex,pev_flags ) | FL_FAKECLIENT );

    
//cs_set_user_team( g_iBotIndex, CS_TEAM_CT, CS_CT_GSG9 );

    
engclient_cmdg_iBotIndex"jointeam""2" ); 
    
engclient_cmdg_iBotIndex"joinclass""1" );  

    
ExecuteHamBHam_CS_RoundRespawng_iBotIndex );

    
//dllfunc( DLLFunc_Spawn, g_iBotIndex );

    
if( !is_user_aliveg_iBotIndex ) )
        return 
PLUGIN_HANDLED;

    
//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;

__________________

Last edited by marcelowzd; 06-22-2018 at 18:14.
marcelowzd is offline
shauli
Member
Join Date: Jun 2018
Old 06-22-2018 , 18:04   Re: Crash when creating a bot
Reply With Quote #23

Quote:
Originally Posted by marcelowzd View Post
Same thing, exactly the same thing to be honest. He is still very far in the radar but i still can se his name and health.
[/PHP]
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 
BOTid )
{
    
g_iBotIndex engfuncEngFunc_CreateFakeClient"[SV] Pro 1 BOT" );

    if( !
g_iBotIndex )
        return 
PLUGIN_HANDLED;

    
engfuncEngFunc_FreeEntPrivateDatag_iBotIndex );

    
//new fOrigin[ 3 ]; pev( id, pev_origin, fOrigin ); 

    
static szBlock128 ];

    
dllfuncDLLFunc_ClientConnectg_iBotIndex"[SV] Pro 1 BOT""127.0.0.1"szBlock );

    if( !
is_user_connectedg_iBotIndex ) )
        return 
PLUGIN_HANDLED;

    
dllfuncDLLFunc_ClientPutInServerg_iBotIndex );

    
set_pevg_iBotIndexpev_spawnflagspevg_iBotIndexpev_spawnflags ) | FL_FAKECLIENT ); 
    
set_pevg_iBotIndexpev_flagspevg_iBotIndex,pev_flags ) | FL_FAKECLIENT );

    
//cs_set_user_team( g_iBotIndex, CS_TEAM_CT, CS_CT_GSG9 );

    
engclient_cmdg_iBotIndex"jointeam""2" ); 
    
engclient_cmdg_iBotIndex"joinclass""1" );  

    
ExecuteHamBHam_CS_RoundRespawng_iBotIndex );

    
//dllfunc( DLLFunc_Spawn, g_iBotIndex );

    
if( !g_fwdStartFrame )
        
g_fwdStartFrame register_forwardFM_StartFrame"fwdStartFrame");

    if( !
is_user_aliveg_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_getglb_frametimeframetime );

        
//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.

        
engfuncEngFunc_RunPlayerMoveg_iBotIndexFloat:{ 0.00.00.0 }, 0.00.00.000floatroundframetime 1000.0 ) );
    }

    return 
FMRES_IGNORED;

shauli is offline
marcelowzd
Senior Member
Join Date: Feb 2011
Location: São Paulo, Brazil
Old 06-22-2018 , 18:19   Re: Crash when creating a bot
Reply With Quote #24

Quote:
Originally Posted by shauli View Post
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 
BOTid )
{
    
g_iBotIndex engfuncEngFunc_CreateFakeClient"[SV] Pro 1 BOT" );

    if( !
g_iBotIndex )
        return 
PLUGIN_HANDLED;

    
engfuncEngFunc_FreeEntPrivateDatag_iBotIndex );

    
//new fOrigin[ 3 ]; pev( id, pev_origin, fOrigin ); 

    
static szBlock128 ];

    
dllfuncDLLFunc_ClientConnectg_iBotIndex"[SV] Pro 1 BOT""127.0.0.1"szBlock );

    if( !
is_user_connectedg_iBotIndex ) )
        return 
PLUGIN_HANDLED;

    
dllfuncDLLFunc_ClientPutInServerg_iBotIndex );

    
set_pevg_iBotIndexpev_spawnflagspevg_iBotIndexpev_spawnflags ) | FL_FAKECLIENT ); 
    
set_pevg_iBotIndexpev_flagspevg_iBotIndex,pev_flags ) | FL_FAKECLIENT );

    
//cs_set_user_team( g_iBotIndex, CS_TEAM_CT, CS_CT_GSG9 );

    
engclient_cmdg_iBotIndex"jointeam""2" ); 
    
engclient_cmdg_iBotIndex"joinclass""1" );  

    
ExecuteHamBHam_CS_RoundRespawng_iBotIndex );

    
//dllfunc( DLLFunc_Spawn, g_iBotIndex );

    
if( !g_fwdStartFrame )
        
g_fwdStartFrame register_forwardFM_StartFrame"fwdStartFrame");

    if( !
is_user_aliveg_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_getglb_frametimeframetime );

        
//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.

        
engfuncEngFunc_RunPlayerMoveg_iBotIndexFloat:{ 0.00.00.0 }, 0.00.00.000floatroundframetime 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.
marcelowzd is offline
shauli
Member
Join Date: Jun 2018
Old 06-22-2018 , 18:24   Re: Crash when creating a bot
Reply With Quote #25

Quote:
Originally Posted by marcelowzd View Post
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,
NP my friend.
Basically I've added a register for the StartFrame forward and added EngFunc_RunPlayerMove.
This makes your fake player "alive", gives him rate, etc. Without it he will still be on the server but he won't be moving and everything because he doesn't have a framerate.

Last edited by shauli; 06-22-2018 at 18:26.
shauli is offline
Reply


Thread Tools
Display Modes

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


All times are GMT -4. The time now is 16:53.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode