MCCTeam / Minecraft-Console-Client

Lightweight console for Minecraft chat and automated scripts
https://mccteam.github.io
Other
1.67k stars 402 forks source link

Script Scheduler or Anti AFK for /look command? #2730

Closed twnku closed 6 months ago

twnku commented 6 months ago

Is there any way to do /look command using Script Scheduler feature? i tried using this but its not working, it send a command to the server and not mcc. my TerrainAndMovements = true is enabled, and it works fine if i send the command directly to mcc Screenshot 2024-05-08 085059

[[ChatBot.ScriptScheduler.TaskList]]
    Task_Name = "/look down"
    Trigger_On_Interval = { Enable = true, MinTime = 140.0, MaxTime = 160.0 }
    Action = "send /look down"

and also this

[[ChatBot.ScriptScheduler.TaskList]]
    Task_Name = "/look down"
    Trigger_On_Interval = { Enable = true, MinTime = 140.0, MaxTime = 160.0 }
    Action = "look down"

Screenshot 2024-05-08 083232 it says Unknown command. Type /help for a list of commands. which mean it sends /look command into the server, and not looking at direction.

twnku commented 6 months ago

i guess the only option is using c# script with infinite loop, by adding this to MinecraftClient.ini to run the script on first login

[ChatBot.ScriptScheduler]
Enabled = true
[[ChatBot.ScriptScheduler.TaskList]]
Task_Name = "run script.cs on login"
Trigger_On_First_Login = true
Action = "script script.cs"

and for the script.cs

//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 CustomBot());

//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 CustomBot : ChatBot
{
    Random rnd = new Random();

    public override void Initialize()
    {
        antiAFKLoop();
    }

    public async void antiAFKLoop()
    {
        while (true)
        {
            if(isAFKon)
            {
                LogToConsole("§a["+this.GetUsername()+"] Location: §e"+this.GetCurrentLocation());
                this.PerformInternalCommand("look -90 0");
                LogToConsole("§a["+this.GetUsername()+"] Yaw:§e "+this.GetYaw()+" §aPitch:§e "+this.GetPitch());
                await System.Threading.Tasks.Task.Delay(rnd.Next(180000, 300000)); 
                this.PerformInternalCommand("look -90 45");
                LogToConsole("§a["+this.GetUsername()+"] New Yaw:§e "+this.GetYaw()+" §aNew Pitch:§e "+this.GetPitch());
                await System.Threading.Tasks.Task.Delay(rnd.Next(180000, 300000)); 
            }
        }
    }

}