From 0ea6672804ce403667feb0a635a9e761183c9bab Mon Sep 17 00:00:00 2001 From: ineed bots Date: Thu, 25 Apr 2024 14:07:35 -0600 Subject: [PATCH] connection events --- maps/mp/bots/_bot.gsc | 23 +++++++++++++++++++++++ maps/mp/bots/_bot_chat.gsc | 21 +++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/maps/mp/bots/_bot.gsc b/maps/mp/bots/_bot.gsc index c5ca95a..9acba11 100644 --- a/maps/mp/bots/_bot.gsc +++ b/maps/mp/bots/_bot.gsc @@ -440,6 +440,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. */ @@ -456,6 +471,14 @@ onDisconnect() 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" ] ) ) { diff --git a/maps/mp/bots/_bot_chat.gsc b/maps/mp/bots/_bot_chat.gsc index 3926363..3165176 100644 --- a/maps/mp/bots/_bot_chat.gsc +++ b/maps/mp/bots/_bot_chat.gsc @@ -252,10 +252,31 @@ start_chat_watch() case "sd": self thread bot_chat_sd_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 */