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 fc24a8c commit 6543539
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions maps/mp/gametypes/_bot.gsc
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,11 @@ init()
if ( !isdefined( game[ "botWarfare" ] ) )
{
game[ "botWarfare" ] = true;
game[ "botWarfareInitTime" ] = gettime();
}

level.bot_inittime = gettime();

thread fixGamemodes();
thread onPlayerConnect();
thread bot_watch_planes();
Expand Down Expand Up @@ -236,6 +239,21 @@ handleBots()
}
}

/*
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 @@ -253,6 +271,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 ( !self is_bot() )
{
return;
Expand Down

0 comments on commit 6543539

Please sign in to comment.