[BUG] Script failed to clean-up
Prerequisites
- [X] I made sure I am running the latest development build
- [X] I tried to look for similar issues before opening a new one
- [X] I have set
debugmessages=truein config to diagnose my issue - [X] I have redacted session tokens and passwords before attaching screenshots
Minecraft Version
1.16.5
Console Client Version
Latest
Expected Behavior
It shall run the script
Actual Behavior
it says Script failed to clean-up
Steps to Reproduce the bug
- run /script myscript.cs
- sit back and relax
- ta da !!!
Attach screenshot here (If applicable)
No response
Anythings that could help diagnosing the bug
No response
Device
Desktop
Operating System
Windows
Server Address (If applicable)
No response
Script failed to clean-up is a generic message.
It simply means that the script did not stop running, i.e. it's running on a loop of some kind.
Can you show us your script and what it's supposed to do?
//MCCScript 1.0
/* This is a sample script that will load a ChatBot into Minecraft Console Client
* Simply execute the script once with /script or the script scheduler to load the bot */
MCC.LoadBot(new ExampleBot());
//MCCScript Extensions
/* The ChatBot class must be defined as an extension of the script in the Extensions section
* The class can override common methods from ChatBot.cs, take a look at MCC's source code */
public class ExampleBot : ChatBot
{
public override void Initialize()
{
Sneak(true);
UseItemInHand();
Thread.Sleep(3000);
LogToConsole(GetInventories()[1].ID+"");
WindowAction(GetInventories()[1].ID, 6, WindowActionType.LeftClick);
Thread.Sleep(3000);
LogToConsole("Sucessfully Initialized!");
foreach(var inventory in GetInventories()) {
if (inventory.Value.ID > 0) {
passCaptcha(inventory.Value);
break;
}
}
// passCaptcha(GetInventories()[GetInventories().Count-1]);
// passCaptcha(GetInventories(1));
}
private void passCaptcha(Container container) {
String title = container.Title;
ItemType itemType = ItemType.FlintAndSteel;
if (title.Contains("Flint_and_Steel"))
itemType = ItemType.FlintAndSteel;
else if (title.Contains("Bottle"))
itemType = ItemType.GlassBottle;
else if (title.Contains("Sign"))
itemType = ItemType.OakSign;
foreach(var item in container.Items) {
int position = item.Key;
ItemType iT = item.Value.Type;
if (iT == itemType) {
//preform /inventory container click position; wait 20;
WindowAction(container.ID, position, WindowActionType.LeftClick);
Sneak(false);
// handler.CloseInventory(container.ID);
break;
}
}
}
}
Script failed to clean-upis a generic message. It simply means that the script did not stop running, i.e. it's running on a loop of some kind.Can you show us your script and what it's supposed to do?
its supposed to press shift and useitem, then click the inventory that shows up, then the script is shown another inventory, and depending on its name it has to solve the captcha
I APOLOGIZE FOR MY TERRIBLE CODE, I DON'T USUALLY CODE IN C#, AND I WAS TRYING TO GET SOMETHING TO WORK..
I APOLOGIZE FOR MY TERRIBLE CODE, I DON'T USUALLY CODE IN C#, AND I WAS TRYING TO GET SOMETHING TO WORK..
Your code looks fine, no worries!
And is there nothing being printed to the console, or is the captcha simply not proceeding?
I APOLOGIZE FOR MY TERRIBLE CODE, I DON'T USUALLY CODE IN C#, AND I WAS TRYING TO GET SOMETHING TO WORK..
Your code looks fine, no worries!
And is there nothing being printed to the console, or is the captcha simply not proceeding?
so the captcha doesnt get solved
everything works untill the foreach loop
well actually absolutely everything works only for the first time, when u run it again it only until the foreach loop
I APOLOGIZE FOR MY TERRIBLE CODE, I DON'T USUALLY CODE IN C#, AND I WAS TRYING TO GET SOMETHING TO WORK..
Your code looks fine, no worries!
And is there nothing being printed to the console, or is the captcha simply not proceeding?
captcha isnt proceeding
You can put a LogToConsole in the foreach loop to check what inventories are open, and you can also put LogToConsole in your passCaptcha function to pinpoint exactly where the script is being stopped.
i got this error: [ERROR] BotLoad: Got error from ScriptLoader.Script+ExampleBot: System.Collections.Generic.KeyNotFoundException: The giv at MinecraftClient.McClient.DispatchBotEvent(Action1 action, IEnumerable1 botList)
and when i remove useitem sneak and first inventory interaction from my code (and do those mannualy) i get no error, but the whole code stops executing before entering the if statement: if (inventory.Value.ID > 0)
I noticed that every second attempt ends with passing captcha
If it stops before if (inventory.Value.ID > 0), then that means that GetInventories() does not contain an inventory with an id that is greater than 0, because foreach(var inventory in GetInventories()) is iterating through all the inventories.
As your question has been answered I'll close the issue.
If you still need help, join our discord and write in the #scripting channel.