Kicking bots properly

In an online server when a bot is kicked a blank name still exists in the score screen. I tried both client.drop() and client.delete(). And .delete() doesn't even remove the bots at all from the server. The score menu gets properly updated when the next map is loaded if bots were kicked in the previous match. There are no such problem in an offline server.

Does anybody have any idea why .drop/.delete doesn't work properly in an online server before I spend more time looking into it? It would be really helpful to me as my bot mod makes use a lot of this feature. My bot mod currently uses .drop().

There's also a thread about this but no good solution was posted:
https://www.tribesnext.com/forum/index.php/topic,1047.0.html

Comments

  • edited May 2020
    ai.drop() is in principle the correct call in that it runs a set of cleanup routines specific to AI tasks, and I wouldn't recommend using ai.delete() directly because it won't actually trigger the expected client disconnection cleanup process; you'll end up with an orphaned player, name tag, etc.

    In practice however ai.drop() only handles cleanup on the server side: you also need to notify the client that there's work to be done. Clients need to receive a 'MsgClientDrop' chat message when the bot is removed in order for it to run the player/lobby cleanup handler -- for human players normally this is triggered by the "X has left the game." message, but it's often also sent as a blank message (see functions kick() or ban() in server.cs and try running kick(ai); to see).
    To be more specific, adding a line similar to this to the AI drop sequence would ensure clients register their removal from the game:
    messageAll('MsgClientDrop', "", %client.name, %client);
    


    As an additional note: there was definitely a bit overlooked in regards to removing bots from the game, so something you may also note if doing this often on a long running server is that their associated tagged strings and targets will not be cleaned up with the default handling (i.e. you'll eventually hit the max allocation if you're running the server for weeks and replacing the bots every match). You should be able to fix this by copying the appropriate parts of the GameConnection onDrop cleanup over to AIConnection::onAIDrop.
  • Wow, thanks! This is perfect, exactly the information I needed. I will also do the GameConnection onDrop to AIConnection::onAIDrop thing while I'm at it. That's something I didn't know about. I will try making these changes and post again if it worked or not.
  • It worked. You saved me a lot of time with your post, so I really want to thank you for that. Thanks to this, I made a small update on the bot mod I'm still working on, fixing this issue.
Sign In or Register to comment.