Minecraft-Console-Client icon indicating copy to clipboard operation
Minecraft-Console-Client copied to clipboard

[BUG] Script failed to clean-up

Open iamkurcze opened this issue 3 years ago • 13 comments

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=true in 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

  1. run /script myscript.cs
  2. sit back and relax
  3. 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

iamkurcze avatar Sep 26 '22 16:09 iamkurcze

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?

breadbyte avatar Sep 26 '22 16:09 breadbyte

//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;

            }


        }


    }

}

iamkurcze avatar Sep 26 '22 16:09 iamkurcze

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?

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..

iamkurcze avatar Sep 26 '22 16:09 iamkurcze

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?

breadbyte avatar Sep 26 '22 16:09 breadbyte

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

iamkurcze avatar Sep 26 '22 16:09 iamkurcze

everything works untill the foreach loop

iamkurcze avatar Sep 26 '22 16:09 iamkurcze

well actually absolutely everything works only for the first time, when u run it again it only until the foreach loop

iamkurcze avatar Sep 26 '22 16:09 iamkurcze

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

iamkurcze avatar Sep 26 '22 17:09 iamkurcze

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.

breadbyte avatar Sep 26 '22 17:09 breadbyte

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)

iamkurcze avatar Sep 26 '22 17:09 iamkurcze

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)

iamkurcze avatar Sep 26 '22 17:09 iamkurcze

I noticed that every second attempt ends with passing captcha

iamkurcze avatar Sep 26 '22 17:09 iamkurcze

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.

breadbyte avatar Sep 26 '22 17:09 breadbyte

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.

milutinke avatar Oct 22 '22 13:10 milutinke