Skip to content
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Donate
Collapse

Plutonium

  1. Home
  2. BO2 Modding Releases & Resources
  3. [Resource] Make a bot leave when people connect to server

[Resource] Make a bot leave when people connect to server

Scheduled Pinned Locked Moved BO2 Modding Releases & Resources
5 Posts 3 Posters 815 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Former User? Offline
    A Former User? Offline
    A Former User
    wrote on last edited by Mr. Android
    #1

    Those who are using bots on their servers and are looking for a way to kick bots automatically as people join, I will be displaying the code below. Essentially, one takes the KickAllBots function frequently seen and simply breaks the code to create a kick1Bot function, then threads it under onplayerconnect.

    kickBot()
    {
    foreach(player in level.players)
    	{
    	if(isDefined(player.pers["isBot"])&& player.pers["isBot"]){
    		kick(player getEntityNumber(),"EXE_PLAYERKICKED");
    		break;
    		}
    	}
    }
    

    One should have a verification level that the bots are assigned to that destroys the menu when they connect as to not cause problems. I chose mine to be Bots.

    verificationToNum(status)
    {
    	if (status == "Host")
    		return 3;
    	if (status == "VIP")
    		return 2;
    	if (status == "Unverified")
    		return 1;
    	else
    		return 0;
    }
    
    verificationToColor(status)
    {
    	if (status == "Host")
    		return "^5Host";
    	if (status == "VIP")
    		return "^5VIP";
    	if (status == "Unverified")
    		return "^7Unverified";
    	else
    		return "^7Bots";
    }
    

    Remember to destroy the menu for bots.

    if(player.status == "Bots")
    	self thread destroyMenu(player);
    

    Assign the verification level for the bots under onplayerconnect as such. ie:

    if(isDefined(player.pers["isBot"])&& player.pers["isBot"])
    	player.status = "Bots";
    

    With the remaining verifications levels, create an if statement that threads the kickBot function should the player not be a bot. Note: if you have not created a separate verification for bots and they are a assigned a level in this if statement they will simply keep kicking each other and only one bot will spawn. Place this under the previous code for assigning the bots' verification level. You can obviously add more levels than this.

    if(player.status == "Host" || player.status == "VIP" || player.status == "Unverified")
    	player thread kickBot();
    

    And that should do it. Cheers.

    1 Reply Last reply
    0
    • Ducxyundefined Offline
      Ducxyundefined Offline
      Ducxy
      wrote on last edited by
      #2

      yes skid, i do indeed need this my good sir 🙄

      A Former User? 1 Reply Last reply
      0
      • A Former User? Offline
        A Former User? Offline
        A Former User
        replied to Ducxy on last edited by
        #3

        @MrDucxy 🤙 🤙

        1 Reply Last reply
        0
        • Mr. Androidundefined Offline
          Mr. Androidundefined Offline
          Mr. Android Plutonium Admin
          wrote on last edited by
          #4

          Seems like a nice release.

          A Former User? 1 Reply Last reply
          0
          • A Former User? Offline
            A Former User? Offline
            A Former User
            replied to Mr. Android on last edited by
            #5

            Mr. Android Thanks 😊

            1 Reply Last reply
            0

            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Donate