Skip to content

Commit

Permalink
connection events
Browse files Browse the repository at this point in the history
  • Loading branch information
ineed bots committed Apr 25, 2024
1 parent e4d101a commit a836c95
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
26 changes: 26 additions & 0 deletions maps/mp/bots/_bot.gsc
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,11 @@ init()
if ( !isdefined( game[ "botWarfare" ] ) )
{
game[ "botWarfare" ] = true;
game[ "botWarfareInitTime" ] = gettime();
}

level.bot_inittime = gettime();

level.defuseobject = undefined;
level.bots_smokelist = List();
level.tbl_perkdata[ 0 ][ "reference_full" ] = true;
Expand Down Expand Up @@ -439,6 +442,21 @@ fixPerksAndScriptKick()
self.pers[ "isBot" ] = true;
}

/*
When a bot disconnects.
*/
onDisconnectPlayer()
{
self waittill( "disconnect" );
waittillframeend;

for ( i = 0; i < level.bots.size; i++ )
{
bot = level.bots[ i ];
bot BotNotifyBotEvent( "connection", "disconnected", self, self.name );
}
}

/*
When a bot disconnects.
*/
Expand All @@ -456,6 +474,14 @@ connected()
{
self endon( "disconnect" );

for ( i = 0; i < level.bots.size; i++ )
{
bot = level.bots[ i ];
bot BotNotifyBotEvent( "connection", "connected", self, self.name );
}

self thread onDisconnectPlayer();

if ( !isdefined( self.pers[ "bot_host" ] ) )
{
self thread doHostCheck();
Expand Down
21 changes: 21 additions & 0 deletions maps/mp/bots/_bot_chat.gsc
Original file line number Diff line number Diff line change
Expand Up @@ -268,10 +268,31 @@ start_chat_watch()
case "attack_dog":
self thread bot_chat_attack_dog_watch( a, b, c, d, e, f, g );
break;

case "connection":
self thread bot_chat_connection_player_watch( a, b, c, d, e, f, g );
break;
}
}
}

/*
When a player connected
*/
bot_chat_connection_player_watch( conn, player, playername, d, e, f, g )
{
self endon( "disconnect" );

switch ( conn )
{
case "connected":
break;

case "disconnected":
break;
}
}

/*
start_startgame_watch
*/
Expand Down

0 comments on commit a836c95

Please sign in to comment.