[Resource] Make a bot leave when people connect to server
-
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.
-
yes skid, i do indeed need this my good sir
-
@MrDucxy
-
Seems like a nice release.
-
Mr. Android Thanks