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

Crash when creating a bot


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
marcelowzd
Senior Member
Join Date: Feb 2011
Location: São Paulo, Brazil
Old 06-22-2018 , 00:49   Crash when creating a bot
Reply With Quote #1

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 
BOTid )
{
    
g_iBotIndex engfuncEngFunc_CreateFakeClient"Test Bot" );

    if( !
g_iBotIndex )
        return 
PLUGIN_HANDLED;

    
console_printid"Bot criado com id %i"g_iBotIndex );

    
engfuncEngFunc_FreeEntPrivateDatag_iBotIndex );

    static 
szBlock128 ];

    
//console_print( id, "Tentativa de conectar PRE" );

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

    
console_printid"Tentativa de conectar POST" );

    if( !
is_user_connectedg_iBotIndex ) )
        return 
PLUGIN_HANDLED;

    
console_printid"Bot conectado" );

    
dllfuncDLLFunc_ClientPutInServerg_iBotIndex );

    
console_printid"Bot entrou no server" );

    
set_pevg_iBotIndexpev_spawnflagspevg_iBotIndexpev_spawnflags ) | FL_FAKECLIENT ); 
    
set_pevg_iBotIndexpev_flagspevg_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.
__________________

Last edited by marcelowzd; 06-22-2018 at 00:51.
marcelowzd is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 06-22-2018 , 03:57   Re: Crash when creating a bot
Reply With Quote #2

FL_FAKECLIENT this is not a spawn flag constants/values it doesnt go with pev_spawnflags, the ones that does go with it starts with prefix SF_

Try looking at some already existing plugins for how to correctly create a fake bot.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 06-22-2018 at 04:01.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
marcelowzd
Senior Member
Join Date: Feb 2011
Location: São Paulo, Brazil
Old 06-22-2018 , 04:26   Re: Crash when creating a bot
Reply With Quote #3

What? This code is from Bugsy's Aimbot Detection Plugin (https://forums.alliedmods.net/showthread.php?p=689045)

He even had problems with this before, here ( https://forums.alliedmods.net/showthread.php?p=768468 )

Also, if i remove them the game still crashes.
__________________

Last edited by marcelowzd; 06-22-2018 at 04:29.
marcelowzd is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 06-22-2018 , 04:37   Re: Crash when creating a bot
Reply With Quote #4

Try swaping the bot into a team.

The code looks fine.

The crash might be not from that peice of code.

If you still believe the crash is from this use log to file. As debug
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 06-22-2018 at 04:40.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
marcelowzd
Senior Member
Join Date: Feb 2011
Location: São Paulo, Brazil
Old 06-22-2018 , 10:14   Re: Crash when creating a bot
Reply With Quote #5

Did as you requested with the same code, but changed everything to log_amx()

PHP Code:
public BOTid )
{
    
g_iBotIndex engfuncEngFunc_CreateFakeClient"Test Bot" );

    if( !
g_iBotIndex )
        return 
PLUGIN_HANDLED;

    
log_amx"Bot created with ID %i"g_iBotIndex );

    
log_amx"FREE ENT PRIVATE DATA PRE" );

    
engfuncEngFunc_FreeEntPrivateDatag_iBotIndex );

    
log_amx"FREE ENT PRIVATE DATA POST" );

    static 
szBlock128 ];

    
log_amx"BOT CONNECT PRE" );

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

    
log_amx"BOT CONNECT POST" );

    if( !
is_user_connectedg_iBotIndex ) )
        return 
PLUGIN_HANDLED;

    
log_amx"BOT CONNECTED" );

    
log_amx"BOT PUTINSERVER PRE" );

    
dllfuncDLLFunc_ClientPutInServerg_iBotIndex );

    
log_amx"BOT PUTINSERVER POST" );

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

The log shows nothing.

Code:
L 06/22/2018 - 01:36:38: -------- Mapchange to bhm_novice --------
L 06/22/2018 - 01:38:05: -------- Mapchange to bhop_celsbrick --------
L 06/22/2018 - 01:52:26: -------- Mapchange to bhm_novice --------
L 06/22/2018 - 11:10:16: -------- Mapchange to bhop_celsbrick --------
The game freezes and than crashes is a better description. Also, this is the only plugin running.
__________________

Last edited by marcelowzd; 06-22-2018 at 10:14.
marcelowzd is offline
marcelowzd
Senior Member
Join Date: Feb 2011
Location: São Paulo, Brazil
Old 06-22-2018 , 13:11   Re: Crash when creating a bot
Reply With Quote #6

After doing a clean install for the second time it started working, but now when i spawn the bot he is invisible.

PHP Code:
public BOTid )
{
    
g_iBotIndex engfuncEngFunc_CreateFakeClient"Test Bot" );

    if( !
g_iBotIndex )
        return 
PLUGIN_HANDLED;

    
engfuncEngFunc_FreeEntPrivateDatag_iBotIndex );

    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_teamg_iBotIndexCS_TEAM_CTCS_CT_GSG9 );

    
ExecuteHamBHam_CS_RoundRespawng_iBotIndex ); // Tried

    //dllfunc( DLLFunc_Spawn, g_iBotIndex );  // Tried

    
if( !is_user_aliveg_iBotIndex ) )
        return 
PLUGIN_HANDLED;

    
//set_user_rendering( g_iBotIndex, kRenderFxNone, 255, 255, 255, kRenderNormal, 25 ); // Tried

    
fm_set_renderingg_iBotIndexkRenderNormal255255255kRenderNormal25 ); // Tried

    //fm_set_user_rendering( g_iBotIndex, kRenderFxGlowShell, 0, 0, 0, kRenderNormal, 25 ); //Tried

    //set_pev( g_iBotIndex, pev_origin, fOrigin );

    
return PLUGIN_HANDLED;

I can see his name, health and he can block me, but he is completely invisible.
Neither option listed above worked.
__________________

Last edited by marcelowzd; 06-22-2018 at 18:14.
marcelowzd is offline
Kushfield
Member
Join Date: Jan 2017
Location: Estonia
Old 06-22-2018 , 13:58   Re: Crash when creating a bot
Reply With Quote #7

Try running this line twice in a row:
ExecuteHamB( Ham_CS_RoundRespawn, g_iBotIndex ); // Tried

I can't remember what exactly, but there's some issues when executing it just once, this might be one of them.
Kushfield is offline
marcelowzd
Senior Member
Join Date: Feb 2011
Location: São Paulo, Brazil
Old 06-22-2018 , 14:02   Re: Crash when creating a bot
Reply With Quote #8

Tested, same happens, and i'm pretty sure you're talking about fun's spawn() function, because it used to have problems when spawning players (i'm not sure if it still does, but everyone says you should use ExecuteHam to spawn a player)
__________________
marcelowzd is offline
Kushfield
Member
Join Date: Jan 2017
Location: Estonia
Old 06-22-2018 , 14:22   Re: Crash when creating a bot
Reply With Quote #9

I tried the exact code you last posted as the only plugin on my server and the bot is visible to me. Could the problem be somewhere else?
Kushfield is offline
Old 06-22-2018, 14:39
Natsheh
This message has been deleted by Natsheh.
Natsheh
Veteran Member
Join Date: Sep 2012
Old 06-22-2018 , 15:11   Re: Crash when creating a bot
Reply With Quote #10

Try giving him amodel and set an animation.

Can i ask whats the point of this?
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 06-22-2018 at 15:11.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Reply



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 18:01.


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