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

need help with getInvItems(id) or getItems()

Status
Not open for further replies.

remark

New Member
Joined
Nov 13, 2014
Messages
58
Reaction score
0
Trying to make a little plugin that will afk open my coinpurses without eating all my labor

PHP:
           List<Item> CoinPurses = getInvItems("Jester's Coinpurse");
           Log(Time()+"Total Jester's Coinpurse: "+CoinPurses.Count);

this returns, the number 5, though i have 500 purses. i do realize it returns the stacks i got, how would i go about getting the right amount i have?

i was thinking of making a list for each coinpurse, and then opening the lowest ones first.

or is there another way i could do it?
 
This is what i have so far if anyone wants to use it.

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 DefaultNameSpace{
    public class DefaultClass : Core
    {
        public static string GetPluginAuthor(){return "Remark";}
        public static string GetPluginVersion(){return "1.0.0.0";}
        public static string GetPluginDescription(){return "For patrons will open a coin purse every 5 minutes, for f2p every 10 minutes";}
       
        private Random random = new Random();
        int LP = 0;
        List<uint> purses = new List<uint>() { 32059, 34915, 29207, 29206, 29205, 29204, 29203 }; //Borrowed from Karls Haslaassistent
       
        void OpenPurses(int labor)
        {
            if((me.laborPoints - LP) >=10)
            {
                Log(Time()+"Gained " +labor.ToString()+" labor, trying to open a coinpurse");
                Wait(5,10);
                
                List<Item> inventory = getAllInvItems();
                
                foreach (Item item in inventory)
                    if(purses.Contains(item.id))
                        if(UseItem(item.id))
                            Log(Time()+"Opened a coinpurse, Laborpoints at :"+me.laborPoints.ToString());
                        
              LP = me.laborPoints;            
            } 
        } 
       
        //Call on plugin start
        public void PluginRun()
        {
            ClearLogs();
            Log(Time()+"Starting Coinpurse opener\r\n");
            Log(Time()+"Starting Labor: "+me.laborPoints.ToString());
           
            // --Purse counting - Borrowed from Karls Haslaassistant
            int purseCount = 0;
            foreach(var item in getAllInvItems())
                if(purses.Contains(item.id))
                    purseCount += item.count;    
            Log(Time()+"Total Coinpurses: "+purseCount.ToString());
           // --  
            onLaborAmountChanged += OpenPurses; 
            LP = me.laborPoints;
            while(gameState == GameState.Ingame)
            {
                Thread.Sleep(250);
            }
        }
        
        //Call on plugin stop
        public void PluginStop()
        {
        }    

        private void Wait(int min, int max)
        {
            int ran = random.Next(min*1000, max*1000) ;
            Log(Time()+"Waiting for "+(ran/1000).ToString()+" seconds");
            Thread.Sleep(ran);
        }
        
        public string Time() //- Get Time
        {
            string A = DateTime.Now.ToString("[HH:mm:ss] ");
            return A;
        }
   }
}
 
Last edited:
Code:
int uberItemCount = getAllInvItems().Where(i => i.id == uberId).Sum(i => i.count);

if (uberItemCount > 0)
{
    //do something uber
}
 
Thanks, got it to work like i wanted it, but it might need testing a bit more.
 
Coinpurse opened while afk to regain labor and open purses

Everytime you earn 10 or more labor, it will open purses, several of the smaller bags and 1 or two of the bigger bags.

There is a random wait timer after gaining labor, not sure if that helps with throwing off a server based check for repetitive tasks, but its there for now.

this will keep you on the server, opening bags for hours, i put myself inside my house and had it running for 8 hours.

opening a jesters bag every 5 minute



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 DefaultNameSpace{
    public class DefaultClass : Core
    {
        public static string GetPluginAuthor(){return "Remark";}
        public static string GetPluginVersion(){return "1.0.0.0";}
        public static string GetPluginDescription(){return "For patrons will open a coin purse every 5 minutes, for f2p every 10 minutes";}
       
        private Random random = new Random();
        //   29203   29204   29205     29206  29207 //
        long farmer, priest, merchant, noble, jester = 0;
        int LP = 0;
        
        void OpenPurses(int labor)
        {
            if((me.laborPoints - LP) >=10)
            {
                Log(Time()+"Gained " +labor.ToString()+" labor, trying to open a coinpurse");
                Wait(5,10);
                
                bool allreadyopened = false;
                
                if(farmer > 0 && !allreadyopened)
                {   
                    int c = 0;
                    while(c < 5)
                    { 
                        UseItemAndWait(29203);
                        c++;
                        farmer--;
                        if(farmer < 1)
                            break;
                    }
                    Log(Time()+"Opened "+c.ToString()+" Farmer's Coinpurse(s), Laborpoints at :"+me.laborPoints.ToString());
                    allreadyopened = true;
                }

                if(priest > 0 && !allreadyopened)
                {   
                    int c = 0;
                    while(c < 3)
                    { 
                        UseItemAndWait(29204);
                        c++;
                        priest--;
                        if(priest < 1)
                            break;
                    }
                    Log(Time()+"Opened "+c.ToString()+" Priest's Coinpurse(s), Laborpoints at :"+me.laborPoints.ToString());
                    allreadyopened = true;
                }
                
                
                if(merchant > 0 && !allreadyopened)
                {   
                    int c = 0;
                    while(c < 2)
                    { 
                        UseItemAndWait(29205);
                        c++;
                        merchant--;
                        if(merchant < 1)
                            break;
                    }
                    Log(Time()+"Opened "+c.ToString()+" Merchant's Coinpurse(s), Laborpoints at :"+me.laborPoints.ToString());
                    allreadyopened = true;
                }
                
                if(noble > 0 && !allreadyopened)
                {   
                    UseItemAndWait(29206);
                    noble--;
                    Log(Time()+"Opened 1 Noble's Coinpurse, Laborpoints at :"+me.laborPoints.ToString());
                    allreadyopened = true;
                }

                
                if(jester > 0 && !allreadyopened)
                {
                    UseItemAndWait(29207);
                    jester--;
                    Log(Time()+"Opened 1 Jester's coinpurse(s), Laborpoints at :"+me.laborPoints.ToString());
                    allreadyopened = true;
                }

                
                        
            }
            else
                LP = me.laborPoints;
        }
       
        //Call on plugin start
        public void PluginRun()
        {
            ClearLogs();
            Log(Time()+"-- Starting Coinpurse opener --");
            Log("Starting Labor : "+me.laborPoints.ToString());
            farmer   = itemCount(29203);
            priest   = itemCount(29204);
            merchant = itemCount(29205);
            noble    = itemCount(29206);
            jester   = itemCount(29207);
            if(farmer > 0) Log(farmer.ToString()+" : Farmer's Coinpurse");
            if(priest > 0) Log(priest.ToString()+" : Priest's Coinpurse");
            if(merchant > 0) Log(merchant.ToString()+" : Merchant's Coinpurse");
            if(noble > 0) Log(noble.ToString()+" : Noble's Coinpurse");
            if(jester > 0) Log(jester.ToString()+" : Jester's Coinpurse");
            
            onLaborAmountChanged += OpenPurses; 
            LP = me.laborPoints;
            while(gameState == GameState.Ingame)
            {
                Thread.Sleep(250);
            }
        }
        
        //Call on plugin stop
        public void PluginStop()
        {
        }    

        private void Wait(int min, int max)
        {
            int ran = random.Next(min*1000, max*1000) ;
            Log(Time()+"Waiting for "+(ran/1000).ToString()+" seconds");
            Thread.Sleep(ran);
        }
        
        public string Time() //- Get Time
        {
            string A = DateTime.Now.ToString("[HH:mm:ss] ");
            return A;
        }
        
        private bool UseItemAndWait(uint itemId, bool selfTarget = false)
        {
            while (me.isCasting || me.isGlobalCooldown)
                Thread.Sleep(50);

            UseItem(itemId, false);

            while (me.isCasting || me.isGlobalCooldown)
                Thread.Sleep(10);

            return true;
        }
        
   }
}
 
just had the thought putting in some random movement while its not opening bag,s like walk 2 meters that way, then 3 that way then 2 ther other way, turn around, etc.
 
Status
Not open for further replies.
Back
Top