What's new
  • Visit Rebornbuddy
  • Visit Panda Profiles
  • Visit LLamamMagic
  • Visit Resources
  • Visit Downloads
  • Visit Portal

[Plugin] Another auto farming plugin, now with farmID auto assignment!

No, I don't know about coding but think it needs to have some logic, like... if air < 30 % use the skill like scarecrow does
Go up to your aquafarm and get the string for the air bubble. Then make a new plugin with just this line to see if it works:

Code:
CollectItemsAtFarm("Aquafarm","STRING HERE",FARMIDHERE);

Setting conditions should be easy, but I need a working interaction method before I can put it in my code.
 
//Call on plugin start
public void PluginRun()
{
CollectItemsAtFarm("Aquafarm","Refill your breath inside a bubble from an aquafarm breathing device",7762);
}
Not working
 
//Call on plugin start
public void PluginRun()
{
CollectItemsAtFarm("Aquafarm","Refill your breath inside a bubble from an aquafarm breathing device",7762);
}
Not working
Did you change the name of your aquafarm to something else?
 
No, the name is right
Add this function to your code:
Code:
public void UseDoodad(string doodadname) {
           DoodadObject y = getDoodads().FirstOrDefault(x => x.dist(me) <= 5d && x.name == doodadname);
           List<Skill> sList;
           sList = y.getUseSkills();
           UseDoodadSkill(sList[0].id, y, true);
       }
And add this at the start of PluginRun(); to test it.
Code:
UseDoodad("Aquafarm");
 
Add this function to your code:
Code:
public void UseDoodad(string doodadname) {
           DoodadObject y = getDoodads().FirstOrDefault(x => x.dist(me) <= 5d && x.name == doodadname);
           List<Skill> sList;
           sList = y.getUseSkills();
           UseDoodadSkill(sList[0].id, y, true);
       }
And add this at the start of PluginRun(); to test it.
Code:
UseDoodad("Aquafarm");

Error: Referencia a objeto no establecida como instancia de un objeto.
9:13:11: Stack trace: en DefaultNameSpace.DefaultClass.UseDoodad(String doodadname) en c:\Users\Mitry\Desktop\Badt\Plugins\quaa\aqua.cs:línea 29
en DefaultNameSpace.DefaultClass.PluginRun() en c:\Users\Mitry\Desktop\Badt\Plugins\quaa\aqua.cs:línea 35
 
Cant get this to work using family farms. Seems to be having issue getting the farmid. In the Log its saying
Starting Farm Bot...
0
0
0
waiting for 2 minutes

I did a bit of debugging (Im terrible at C) and it seems its comparing Family names to only 1 nearby farm owner name.

Might be easier on the program if we could just enter the family/guild members name instead of it trying to find a farm with a name that matches a family members name.
 
Last edited:
Cant get this to work using family farms. Seems to be having issue getting the farmid. In the Log its saying


I did a bit of debugging (Im terrible at C) and it seems its comparing Family names to only 1 nearby farm owner name.

Might be easier on the program if we could just enter the family/guild members name instead of it trying to find a farm with a name that matches a family members name.

That would be a quick workaround, if you want to do this just change part of the GetFarmIds function from farms1 to farms:

Code:
if (farms1.Count > 0) {     
                   Housing plnt = farms1.First() as Housing;
                   farmids.Add(plnt.uniqHousingId);
                   farmnames.Add(plnt.name);
                   farms1.RemoveAt(0);
                }
change to
Code:
if (farms.Count > 0) {     
                   Housing plnt = farms.First() as Housing;
                   farmids.Add(plnt.uniqHousingId);
                   farmnames.Add(plnt.name);
                   farms.RemoveAt(0);
                }
Keep in mind your farmnames cannot be the same as any other farm around you.
 
i have the farms side by side and at 15 meters is the seed merchant cant search the merchant without the path.db?
 
i have the farms side by side and at 15 meters is the seed merchant cant search the merchant without the path.db?
Merchant has to be close enough to buy from to work, for this you need gps point to move to merchant.
 
nevermint i used this below and now without path goes to merchant from 75+ meters away. ty anyway

// -------------------- Gps Functions, copy/paste if you have farms spread out and need gps to go between them --------------------//
private Gps gps;
// string _gpsfile = "\\plugins\\Farms\\Farming.db3"; // COMMENT OUT IF NOT USING GPS
public void MoveToFarm()
{
gps = new Gps(this);
gps.LoadDataBase(Application.StartupPath);
gps.GpsMove("Farms");
}
public void MoveToVendor()
{
gps = new Gps(this);
gps.LoadDataBase(Application.StartupPath);
gps.GpsMove("Seed Merchant");
}
 
Hay amazingnessn.
Its my first time trying to make a sciped.
Im having problemems getting it to work. Hope you maby can look at it for me?
Just want i to plant and harvest all night long ^^

Thanks alot
/DonBugge

using System;
using System.Drawing;
using System.Windows.Forms;
using System.Threading;
using System.Collections.Generic;
using System.Linq;
using ArcheBuddy.Bot.Classes;

namespace YourNamespace {
public class YourClass: Core {

public static string GetPluginAuthor()
{
return "amazingnessn";
}
public static string GetPluginVersion()
{
return "1.1";
}

public static string GetPluginDescription()
{
return "Farming Bot - Auto gather/plant your crops with auto farm ID";
}

// ----------------------------------------------- if you have more/less # of farms, add/comment out what you need --------------------------------
// ------------------------------------------------ Change Farm Names Here ---------------------------------------------------------
private string farm1name = "Bugge";
private string farm2name = "Buggeone";
private string farm3name = "Buggetwo";
private string farm4name = "Buggetree";
//private string farm5name = "FARM NAME HERE";

private uint farm1id;
private uint farm2id;
private uint farm3id;
private uint farm4id;
//private uint farm5id;

// -------------------- Gps Functions, add more functions if you have farms spread out and need gps to go between them --------------------//
private bool gps_on = false; //Set to true if using gps, false if not
private Gps gps;
string _gpsfile = "\\plugins\\Farms\\Farming.db3";
public void MoveToFarm()
{
gps = new Gps(this);
gps.LoadDataBase(Application.StartupPath + _gpsfile);
gps.GpsMove("Farms");
}
public void MoveToVendor()
{
gps = new Gps(this);
gps.LoadDataBase(Application.StartupPath + _gpsfile);
gps.GpsMove("Seed Merchant");
}


public void GetFarmIds()
{

// Don't edit this if you don't know what it does :p
int p = 0;
List<long> farmids = new List<long>();
List<string> farmnames = new List<string>();
List<Creature> farms = getCreatures().Where(x => x.type == BotTypes.Housing).ToList();
List<Creature> farms1 = farms.Where(x => x.ownerUniqId == me.uniqId).ToList();
List<Creature> farmsfam = farms.Where(x => x.ownerUniqId != me.uniqId).ToList();
foreach(var y in farms) {
if (farms1.Count > 0) {
Housing plnt = farms1.First() as Housing;
farmids.Add(plnt.uniqHousingId);
farmnames.Add(plnt.name);
farms1.RemoveAt(0);
}

if (farmsfam.Count > 0) {
Housing plnt1 = farmsfam.First() as Housing;
foreach(var d in me.family.getMembers()){
if (plnt1.ownerName == d.name) {
farmids.Add(plnt1.uniqHousingId);
farmnames.Add(plnt1.name);
farmsfam.RemoveAt(0);
}
}
}
}
foreach(var i in farmnames){
if (farmnames[p] == this.farm1name) { this.farm1id = (uint)farmids[p]; }
if (farmnames[p] == this.farm2name) { this.farm2id = (uint)farmids[p]; }
if (farmnames[p] == this.farm3name) { this.farm3id = (uint)farmids[p]; }
//if (farmnames[p] == this.farm4name) { this.farm4id = (uint)farmids[p]; }
//if (farmnames[p] == this.farm5name) { this.farm5id = (uint)farmids[p]; }
p++;
}
}

public void PluginRun() {
ClearLogs();
Log("Starting Farm Bot...");

// --------------------------------------- stops if under this much labor, change if desired---------------------------------------------------
int laborstop = 200;
// ------------------------------------- put farmID, seed, plant, collect strings here --------------------------------------
//FARM 1
var Bugge = "corn seed";
var Bugge = "corn";
var Bugge = "corn";
//FARM 2
var Buggeone = "corn seed";
var Buggeone = "corn";
var Buggeone = "corn";
//FARM 3
var Buggetwo = "corn seed";
var Buggetwo = "corn";
var Buggetwo = "corn";
//FARM 4
var Buggetree = "corn seed";
var Buggetree = "corn";
var Buggetree = "corn";
//FARM 5
var farm5seed = "SEED NAME HERE";
var farm5plant = "PLANT NAME HERE";
var farm5collect = "TOOLTIP STRING HERE"; */

// ----------------------------------------- how many seeds to buy when you get low -----------------------------------------
var farm1seedbuy = 1000;
var farm2seedbuy = 1000;
var farm3seedbuy = 1000;
var farm4seedbuy = 1000;
//var farm5seedbuy = 1000;



while (true) {
var farm1seedcount = itemCount(farm1seed);
var farm2seedcount = itemCount(farm2seed);
var farm3seedcount = itemCount(farm3seed);
var farm4seedcount = itemCount(farm4seed);
//var farm5seedcount = itemCount(farm5seed);
//Gather infos
if (gameState == GameState.Ingame){
GetFarmIds();
Log(farm1id.ToString());
Log(farm2id.ToString());
Log(farm3id.ToString());
//get Labor points
int labor = me.laborPoints;
//Start Doin Stuff
//if Labor > 200
if (labor > laborstop) {

if (gps_on == true){
if (farm1seedcount < (farm1seedbuy / 5) | farm2seedcount < (farm2seedbuy / 5) | farm3seedcount < (farm3seedbuy / 5)) {
MoveToVendor();
Thread.Sleep(2000);
if (farm1seedcount < (farm1seedbuy / 5)) {BuyItems(farm1seed, farm1seedbuy);}
if (farm2seedcount < (farm2seedbuy / 5)) {BuyItems(farm2seed, farm2seedbuy);}
if (farm3seedcount < (farm3seedbuy / 5)) {BuyItems(farm3seed, farm3seedbuy);}
//if (farm4seedcount < (farm4seedbuy / 10)) {BuyItems(farm4seed, farm4seedbuy);}
//if (farm5seedcount < (farm5seedbuy / 10)) {BuyItems(farm5seed, farm5seedbuy);}
Thread.Sleep(5000);
MoveToFarm();
}}

//add/remove farms here
//Plant farm 1
SetPlantMotionType(PlantMotionType.Standart); // change motion type if needed
CollectItemsAtFarm(farm1plant, farm1collect, farm1id);
CollectItemsAtFarm(farm1plant, farm1collect, farm1id);
CollectItemsAtFarm(farm1plant, farm1collect, farm1id);
PlantItemsAtFarm(farm1seed, farm1id);

//Plant farm 2
CollectItemsAtFarm(farm2plant, farm2collect, farm2id);
CollectItemsAtFarm(farm2plant, farm2collect, farm2id);
CollectItemsAtFarm(farm2plant, farm2collect, farm2id);
PlantItemsAtFarm(farm2seed, farm2id);

//Plant farm 3
CollectItemsAtFarm(farm3plant, farm3collect, farm3id);
CollectItemsAtFarm(farm3plant, farm3collect, farm3id);
CollectItemsAtFarm(farm3plant, farm3collect, farm3id);
PlantItemsAtFarm(farm3seed, farm3id);

//Plant farm 4
CollectItemsAtFarm(farm4plant, farm4collect, farm4id);
CollectItemsAtFarm(farm4plant, farm4collect, farm4id);
CollectItemsAtFarm(farm4plant, farm4collect, farm4id);
PlantItemsAtFarm(farm4seed, farm4id);

//Plant farm 5
CollectItemsAtFarm(farm5plant, farm5collect, farm5id);
CollectItemsAtFarm(farm5plant, farm5collect, farm5id);
CollectItemsAtFarm(farm5plant, farm5collect, farm5id);
PlantItemsAtFarm(farm5seed, farm5id); */

//if Labor < 200 wait
} else {
PlantItemsAtFarm(farm1seed, farm1id);
PlantItemsAtFarm(farm2seed, farm2id);
PlantItemsAtFarm(farm3seed, farm3id);
PlantItemsAtFarm(farm4seed, farm4id);
//PlantItemsAtFarm(farm5seed, farm5id);
Log("Labor under 200, waiting to regen");
}

//Generate random time between 3-5 minutes
Random random = new Random();
decimal mseconds = random.Next(180, 300) * 1000;
decimal seconds = mseconds / 1000;
decimal minutes = seconds / 60;
Log("Waiting for " + minutes.ToString() + " minutes");

//sleep for random time
Thread.Sleep((int)mseconds);
}
}
}
//Call on plugin stop
public void PluginStop()
{
Log("Plugin Stopped...");
}
}
}
 
Hay amazingnessn.
Its my first time trying to make a sciped.
Im having problemems getting it to work. Hope you maby can look at it for me?
Just want i to plant and harvest all night long ^^

Thanks alot
/DonBugge
You changed the variable names for each farm's seed, plant, and string. Only change the string values for these, not the actual names that were "farm1seed, farm1plant, farm1collect" etc.

Also for the collect value, the string needs to be whatever the tooltip for that plant is, not just plant name again. And you need to make sure capitalization/punctuation is correct.

Other thing I saw is you need to uncomment
Code:
//if (farmnames[p] == this.farm4name) { this.farm4id = (uint)farmids[p]; }
in your GetFarmIds function or plugin won't gather/plant your 4th farm.
 
That would be a quick workaround, if you want to do this just change part of the GetFarmIds function from farms1 to farms:


change to
Code:
if (farms.Count > 0) {     
                   Housing plnt = farms.First() as Housing;
                   farmids.Add(plnt.uniqHousingId);
                   farmnames.Add(plnt.name);
                   farms.RemoveAt(0);
                }
Keep in mind your farmnames cannot be the same as any other farm around you.


The family farms have unique names and this isn't working. After doing the edits you told me the plugins just starts and immediately stops.


Here is the code Im using.

PHP:
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Threading;
using System.Collections.Generic;
using System.Linq;
using ArcheBuddy.Bot.Classes;

namespace YourNamespace {
    public class YourClass: Core { 
        
       public static string GetPluginAuthor()
       {
           return "amazingnessn";
       }
       public static string GetPluginVersion()
       {
           return "1.1";
       }

       public static string GetPluginDescription()
       {
           return "Farming Bot - Auto gather/plant your crops with auto farm ID";
       }
       
       // ----------------------------------------------- if you have more/less # of farms, add/comment out what you need -------------------------------- 
       // ------------------------------------------------ Change Farm Names Here --------------------------------------------------------- 
       private string farm1name = "Unoone";
       private string farm2name = "Dostwo";
       private string farm3name = "Tresthree";
       private string farm4name = "Quatrofour";
       private string farm5name = "Cinofive";
              
       private uint farm1id;
       private uint farm2id;
       private uint farm3id;
       private uint farm4id;
       private uint farm5id;
       
       // -------------------- Gps Functions, add more functions if you have farms spread out and need gps to go between them --------------------//
       private bool gps_on = false;   //Set to true if using gps, false if not
       private Gps gps;
       string _gpsfile = "\\plugins\\Farms\\Farming.db3";       
       public void MoveToFarm()        
        {         
           gps = new Gps(this); 
           gps.LoadDataBase(Application.StartupPath + _gpsfile); 
           gps.GpsMove("Farms");                
         }
       public void MoveToVendor()        
        {         
           gps = new Gps(this); 
           gps.LoadDataBase(Application.StartupPath + _gpsfile); 
           gps.GpsMove("Seed Merchant");                
         }
       
       
       public void GetFarmIds()
        {   
            
            // Don't edit this if you don't know what it does :p
            int p       = 0;
            List<long> farmids = new List<long>();
            List<string> farmnames = new List<string>();
            List<Creature> farms = getCreatures().Where(x => x.type == BotTypes.Housing).ToList();
            List<Creature> farms1 = farms.Where(x => x.ownerUniqId == me.uniqId).ToList();
            List<Creature> farmsfam = farms.Where(x => x.ownerUniqId != me.uniqId).ToList();
            foreach(var y in farms)   { 
                if (farms.Count > 0) {     
                   Housing plnt = farms.First() as Housing;
                   farmids.Add(plnt.uniqHousingId);
                   farmnames.Add(plnt.name);
                   farms.RemoveAt(0);
                }
                
                if (farmsfam.Count > 0) {
                   Housing plnt1 = farmsfam.First() as Housing;
                   foreach(var d in me.family.getMembers()){ 
                       if (plnt1.ownerName == d.name) {    
                        Log(d.name);
                        Log(plnt1.ownerName); 
                        farmids.Add(plnt1.uniqHousingId);
                        farmnames.Add(plnt1.name);
                        farmsfam.RemoveAt(0); 
                    }
                }
                }   
           }
            foreach(var i in farmnames){
                if (farmnames[p] == this.farm1name) { this.farm1id = (uint)farmids[p]; }
                if (farmnames[p] == this.farm2name) { this.farm2id = (uint)farmids[p]; }
                if (farmnames[p] == this.farm3name) { this.farm3id = (uint)farmids[p]; }
                if (farmnames[p] == this.farm4name) { this.farm4id = (uint)farmids[p]; }
                if (farmnames[p] == this.farm5name) { this.farm5id = (uint)farmids[p]; }    
                p++;              
            }        
         }
                   
        public void PluginRun() { 
            ClearLogs();
            Log("Starting Farm Bot...");            
            
            // --------------------------------------- stops if under this much labor, change if desired---------------------------------------------------
            int laborstop = 200;
            // ------------------------------------- put farmID, seed, plant, collect strings here --------------------------------------
            //FARM 1
            var farm1seed    = "Clover Seed";
            var farm1plant   = "Clover";
            var farm1collect = "Gathering: Spend 1 Labor to gather materials.";
            //FARM 2
            var farm2seed    = "Clover Seed";
            var farm2plant   = "Clover";
            var farm2collect = "Gathering: Spend 1 Labor to gather materials.";
            //FARM 3
            var farm3seed    = "Clover Seed";
            var farm3plant   = "Clover";
            var farm3collect = "Gathering: Spend 1 Labor to harvest crops."; 
            //FARM 4
            var farm4seed    = "Clover Seed";
            var farm4plant   = "Clover";
            var farm4collect = "Gathering: Spend 1 Labor to gather materials.";
            //FARM 5
            var farm5seed    = "Clover Seed";
            var farm5plant   = "Clover";
            var farm5collect = "Gathering: Spend 1 Labor to gather materials.";
    
            // ----------------------------------------- how many seeds to buy when you get low -----------------------------------------
            var farm1seedbuy = 1000;    
            var farm2seedbuy = 1000;
            var farm3seedbuy = 1000;
            var farm4seedbuy = 1000;
            var farm5seedbuy = 1000;
            
            
            
            while (true) {                         
                var farm1seedcount = itemCount(farm1seed);
                var farm2seedcount = itemCount(farm2seed);
                var farm3seedcount = itemCount(farm3seed);
                var farm4seedcount = itemCount(farm4seed);
                var farm5seedcount = itemCount(farm5seed);
                //Gather infos
                if (gameState == GameState.Ingame){
                GetFarmIds();
                Log(farm1id.ToString());
                Log(farm2id.ToString());
                Log(farm3id.ToString());
                //get Labor points 
                int labor = me.laborPoints;               
                //Start Doin Stuff
                if (labor > laborstop) {
                     
                    if (gps_on == true){
                    if (farm1seedcount < (farm1seedbuy / 5) | farm2seedcount < (farm2seedbuy / 5) | farm3seedcount < (farm3seedbuy / 5)) {
                        MoveToVendor();
                        Thread.Sleep(2000);
                        if (farm1seedcount < (farm1seedbuy / 5)) {BuyItems(farm1seed, farm1seedbuy);}
                        if (farm2seedcount < (farm2seedbuy / 5)) {BuyItems(farm2seed, farm2seedbuy);}
                        if (farm3seedcount < (farm3seedbuy / 5)) {BuyItems(farm3seed, farm3seedbuy);}
                        if (farm4seedcount < (farm4seedbuy / 10)) {BuyItems(farm4seed, farm4seedbuy);}
                        if (farm5seedcount < (farm5seedbuy / 10)) {BuyItems(farm5seed, farm5seedbuy);}
                        Thread.Sleep(5000);
                        MoveToFarm();
                    }}                                       
                    
                    //add/remove farms here
                    //Plant farm 1  
                    SetPlantMotionType(PlantMotionType.Standart);        // change motion type if needed
                    CollectItemsAtFarm(farm1plant, farm1collect, farm1id);
                    CollectItemsAtFarm(farm1plant, farm1collect, farm1id);
                    CollectItemsAtFarm(farm1plant, farm1collect, farm1id);                    
                    PlantItemsAtFarm(farm1seed, farm1id);
              
                    //Plant farm 2
                    CollectItemsAtFarm(farm2plant, farm2collect, farm2id);
                    CollectItemsAtFarm(farm2plant, farm2collect, farm2id);
                    CollectItemsAtFarm(farm2plant, farm2collect, farm2id);
                    PlantItemsAtFarm(farm2seed, farm2id);
                    
                    //Plant farm 3
                    CollectItemsAtFarm(farm3plant, farm3collect, farm3id);
                    CollectItemsAtFarm(farm3plant, farm3collect, farm3id);
                    CollectItemsAtFarm(farm3plant, farm3collect, farm3id);
                    PlantItemsAtFarm(farm3seed, farm3id); 

                    //Plant farm 4
                    CollectItemsAtFarm(farm4plant, farm4collect, farm4id);
                    CollectItemsAtFarm(farm4plant, farm4collect, farm4id);
                    CollectItemsAtFarm(farm4plant, farm4collect, farm4id);
                    PlantItemsAtFarm(farm4seed, farm4id); 
                    
                    //Plant farm 5
                    CollectItemsAtFarm(farm5plant, farm5collect, farm5id);
                    CollectItemsAtFarm(farm5plant, farm5collect, farm5id);
                    CollectItemsAtFarm(farm5plant, farm5collect, farm5id);
                    PlantItemsAtFarm(farm5seed, farm5id); 
                                     
                    //if Labor < 200 wait 
                } else { 
                    PlantItemsAtFarm(farm1seed, farm1id);
                    PlantItemsAtFarm(farm2seed, farm2id);
                    PlantItemsAtFarm(farm3seed, farm3id);
                    PlantItemsAtFarm(farm4seed, farm4id);
                    PlantItemsAtFarm(farm5seed, farm5id);
                    Log("Labor under 200, waiting to regen");
                }

                //Generate random time between 3-5 minutes       
                Random random    = new Random();                                   
                decimal mseconds = random.Next(789, 1554) * 1000;
                decimal seconds  = mseconds / 1000;
                decimal minutes  = seconds / 60;
                Log("Waiting for " + minutes.ToString() + " minutes");

                //sleep for random time
                Thread.Sleep((int)mseconds);
            }
            }
        }
       //Call on plugin stop
       public void PluginStop()
       { 
           Log("Plugin Stopped...");
       } 
    }
}
 
Last edited:
The family farms have unique names and this isn't working. After doing the edits you told me the plugins just starts and immediately stops.


Here is the code Im using.

PHP:
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Threading;
using System.Collections.Generic;
using System.Linq;
using ArcheBuddy.Bot.Classes;

namespace YourNamespace {
    public class YourClass: Core { 
        
       public static string GetPluginAuthor()
       {
           return "amazingnessn";
       }
       public static string GetPluginVersion()
       {
           return "1.1";
       }

       public static string GetPluginDescription()
       {
           return "Farming Bot - Auto gather/plant your crops with auto farm ID";
       }
       
       // ----------------------------------------------- if you have more/less # of farms, add/comment out what you need -------------------------------- 
       // ------------------------------------------------ Change Farm Names Here --------------------------------------------------------- 
       private string farm1name = "Unoone";
       private string farm2name = "Dostwo";
       private string farm3name = "Tresthree";
       private string farm4name = "Quatrofour";
       private string farm5name = "Cinofive";
              
       private uint farm1id;
       private uint farm2id;
       private uint farm3id;
       private uint farm4id;
       private uint farm5id;
       
       // -------------------- Gps Functions, add more functions if you have farms spread out and need gps to go between them --------------------//
       private bool gps_on = false;   //Set to true if using gps, false if not
       private Gps gps;
       string _gpsfile = "\\plugins\\Farms\\Farming.db3";       
       public void MoveToFarm()        
        {         
           gps = new Gps(this); 
           gps.LoadDataBase(Application.StartupPath + _gpsfile); 
           gps.GpsMove("Farms");                
         }
       public void MoveToVendor()        
        {         
           gps = new Gps(this); 
           gps.LoadDataBase(Application.StartupPath + _gpsfile); 
           gps.GpsMove("Seed Merchant");                
         }
       
       
       public void GetFarmIds()
        {   
            
            // Don't edit this if you don't know what it does :p
            int p       = 0;
            List<long> farmids = new List<long>();
            List<string> farmnames = new List<string>();
            List<Creature> farms = getCreatures().Where(x => x.type == BotTypes.Housing).ToList();
            List<Creature> farms1 = farms.Where(x => x.ownerUniqId == me.uniqId).ToList();
            List<Creature> farmsfam = farms.Where(x => x.ownerUniqId != me.uniqId).ToList();
            foreach(var y in farms)   { 
                if (farms.Count > 0) {     
                   Housing plnt = farms.First() as Housing;
                   farmids.Add(plnt.uniqHousingId);
                   farmnames.Add(plnt.name);
                   farms.RemoveAt(0);
                }
                
                if (farmsfam.Count > 0) {
                   Housing plnt1 = farmsfam.First() as Housing;
                   foreach(var d in me.family.getMembers()){ 
                       if (plnt1.ownerName == d.name) {    
                        Log(d.name);
                        Log(plnt1.ownerName); 
                        farmids.Add(plnt1.uniqHousingId);
                        farmnames.Add(plnt1.name);
                        farmsfam.RemoveAt(0); 
                    }
                }
                }   
           }
            foreach(var i in farmnames){
                if (farmnames[p] == this.farm1name) { this.farm1id = (uint)farmids[p]; }
                if (farmnames[p] == this.farm2name) { this.farm2id = (uint)farmids[p]; }
                if (farmnames[p] == this.farm3name) { this.farm3id = (uint)farmids[p]; }
                if (farmnames[p] == this.farm4name) { this.farm4id = (uint)farmids[p]; }
                if (farmnames[p] == this.farm5name) { this.farm5id = (uint)farmids[p]; }    
                p++;              
            }        
         }
                   
        public void PluginRun() { 
            ClearLogs();
            Log("Starting Farm Bot...");            
            
            // --------------------------------------- stops if under this much labor, change if desired---------------------------------------------------
            int laborstop = 200;
            // ------------------------------------- put farmID, seed, plant, collect strings here --------------------------------------
            //FARM 1
            var farm1seed    = "Clover Seed";
            var farm1plant   = "Clover";
            var farm1collect = "Gathering: Spend 1 Labor to gather materials.";
            //FARM 2
            var farm2seed    = "Clover Seed";
            var farm2plant   = "Clover";
            var farm2collect = "Gathering: Spend 1 Labor to gather materials.";
            //FARM 3
            var farm3seed    = "Clover Seed";
            var farm3plant   = "Clover";
            var farm3collect = "Gathering: Spend 1 Labor to harvest crops."; 
            //FARM 4
            var farm4seed    = "Clover Seed";
            var farm4plant   = "Clover";
            var farm4collect = "Gathering: Spend 1 Labor to gather materials.";
            //FARM 5
            var farm5seed    = "Clover Seed";
            var farm5plant   = "Clover";
            var farm5collect = "Gathering: Spend 1 Labor to gather materials.";
    
            // ----------------------------------------- how many seeds to buy when you get low -----------------------------------------
            var farm1seedbuy = 1000;    
            var farm2seedbuy = 1000;
            var farm3seedbuy = 1000;
            var farm4seedbuy = 1000;
            var farm5seedbuy = 1000;
            
            
            
            while (true) {                         
                var farm1seedcount = itemCount(farm1seed);
                var farm2seedcount = itemCount(farm2seed);
                var farm3seedcount = itemCount(farm3seed);
                var farm4seedcount = itemCount(farm4seed);
                var farm5seedcount = itemCount(farm5seed);
                //Gather infos
                if (gameState == GameState.Ingame){
                GetFarmIds();
                Log(farm1id.ToString());
                Log(farm2id.ToString());
                Log(farm3id.ToString());
                //get Labor points 
                int labor = me.laborPoints;               
                //Start Doin Stuff
                if (labor > laborstop) {
                     
                    if (gps_on == true){
                    if (farm1seedcount < (farm1seedbuy / 5) | farm2seedcount < (farm2seedbuy / 5) | farm3seedcount < (farm3seedbuy / 5)) {
                        MoveToVendor();
                        Thread.Sleep(2000);
                        if (farm1seedcount < (farm1seedbuy / 5)) {BuyItems(farm1seed, farm1seedbuy);}
                        if (farm2seedcount < (farm2seedbuy / 5)) {BuyItems(farm2seed, farm2seedbuy);}
                        if (farm3seedcount < (farm3seedbuy / 5)) {BuyItems(farm3seed, farm3seedbuy);}
                        if (farm4seedcount < (farm4seedbuy / 10)) {BuyItems(farm4seed, farm4seedbuy);}
                        if (farm5seedcount < (farm5seedbuy / 10)) {BuyItems(farm5seed, farm5seedbuy);}
                        Thread.Sleep(5000);
                        MoveToFarm();
                    }}                                       
                    
                    //add/remove farms here
                    //Plant farm 1  
                    SetPlantMotionType(PlantMotionType.Standart);        // change motion type if needed
                    CollectItemsAtFarm(farm1plant, farm1collect, farm1id);
                    CollectItemsAtFarm(farm1plant, farm1collect, farm1id);
                    CollectItemsAtFarm(farm1plant, farm1collect, farm1id);                    
                    PlantItemsAtFarm(farm1seed, farm1id);
              
                    //Plant farm 2
                    CollectItemsAtFarm(farm2plant, farm2collect, farm2id);
                    CollectItemsAtFarm(farm2plant, farm2collect, farm2id);
                    CollectItemsAtFarm(farm2plant, farm2collect, farm2id);
                    PlantItemsAtFarm(farm2seed, farm2id);
                    
                    //Plant farm 3
                    CollectItemsAtFarm(farm3plant, farm3collect, farm3id);
                    CollectItemsAtFarm(farm3plant, farm3collect, farm3id);
                    CollectItemsAtFarm(farm3plant, farm3collect, farm3id);
                    PlantItemsAtFarm(farm3seed, farm3id); 

                    //Plant farm 4
                    CollectItemsAtFarm(farm4plant, farm4collect, farm4id);
                    CollectItemsAtFarm(farm4plant, farm4collect, farm4id);
                    CollectItemsAtFarm(farm4plant, farm4collect, farm4id);
                    PlantItemsAtFarm(farm4seed, farm4id); 
                    
                    //Plant farm 5
                    CollectItemsAtFarm(farm5plant, farm5collect, farm5id);
                    CollectItemsAtFarm(farm5plant, farm5collect, farm5id);
                    CollectItemsAtFarm(farm5plant, farm5collect, farm5id);
                    PlantItemsAtFarm(farm5seed, farm5id); 
                                     
                    //if Labor < 200 wait 
                } else { 
                    PlantItemsAtFarm(farm1seed, farm1id);
                    PlantItemsAtFarm(farm2seed, farm2id);
                    PlantItemsAtFarm(farm3seed, farm3id);
                    PlantItemsAtFarm(farm4seed, farm4id);
                    PlantItemsAtFarm(farm5seed, farm5id);
                    Log("Labor under 200, waiting to regen");
                }

                //Generate random time between 3-5 minutes       
                Random random    = new Random();                                   
                decimal mseconds = random.Next(789, 1554) * 1000;
                decimal seconds  = mseconds / 1000;
                decimal minutes  = seconds / 60;
                Log("Waiting for " + minutes.ToString() + " minutes");

                //sleep for random time
                Thread.Sleep((int)mseconds);
            }
            }
        }
       //Call on plugin stop
       public void PluginStop()
       { 
           Log("Plugin Stopped...");
       } 
    }
}
Worked without issue on my end, if it starts and stops then you should have some error code in the main archebuddy window, copy paste this here please.
 
@amazingnessn
It work now thanks alot for the help. Im testing it now ^^
 
Here is the error.
11:16:14 PM: Script [c:\users\pc\desktop\a\Plugins\Farmer - Multi\Farmer - Multi.dll] run error:
11:16:14 PM: Error: Collection was modified; enumeration operation may not execute.
11:16:14 PM: Stack trace: at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
at System.Collections.Generic.List`1.Enumerator.MoveNextRare()
at System.Collections.Generic.List`1.Enumerator.MoveNext()
at YourNamespace.YourClass.GetFarmIds() in c:\Users\PC\Desktop\A\Plugins\Farmer - Multi\Farmer - Multi.cs:line 68
at YourNamespace.YourClass.PluginRun() in c:\Users\PC\Desktop\A\Plugins\Farmer - Multi\Farmer - Multi.cs:line 144
 
Here is the error.
Weird, try this
Code:
            int p       = 0; 
            List<long> farmids = new List<long>(); 
            List<string> farmnames = new List<string>(); 
            List<Creature> farms = getCreatures().Where(x => x.type == BotTypes.Housing).ToList(); 
            List<Creature> farms1 = farms.ToList(); 
            List<Creature> farmsfam = farms.Where(x => x.ownerUniqId != me.uniqId).ToList(); 
            foreach(var y in farms)   {  
                if (farms1.Count > 0) {      
                   Housing plnt = farms1.First() as Housing; 
                   farmids.Add(plnt.uniqHousingId); 
                   farmnames.Add(plnt.name); 
                   farms1.RemoveAt(0); 
                }
 
Never read all posts but did you ever get it to use farms farther apart? Couldn't you just call
GetFarmIds();
Log(farm1id.ToString());
Log(farm2id.ToString());
Log(farm3id.ToString());
after each movetofarm so it gets new id's ? you may have already done this as i only read first 3 or so pages so if so then disregard but if not that would probably make that part work?
 
Back
Top