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

Have a problem with int

countrykiller

New Member
Joined
Jul 13, 2010
Messages
25
Reaction score
3
Hey been trying to do something very simple as a learning process but i cant seem to figure out why i cannot get this to work


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

namespace NameSpaceTest{
   public class DefaultClass : Core
   {   
       
       public static string GetPluginAuthor()
       {
            return "Countrykiller";
       }

       public static string GetPluginVersion()
       {
           return "0.1.0.0";
       }
       
       public static string GetPluginDescription()
       {
           return "Testing Illegal Farming planting cucumbers it should work!!! with trees!!";
       }
       public int potatosplanted = 0;
       public int cucumbersplanted = 0; 
       //Call on plugin start
       public void PluginRun()
       {
           while (true)
           {
               RoundZone z = new RoundZone(me.X, me.Y, 25);
                CollectItemsInZone("Potato","Farming: Spend 1 Labor to harvest crops.",z);
                CollectItemsInZone("Cucumber","Farming: Spend 1 Labor to harvest crops.",z);
                CollectItemsInZone("Barley","Farming: Spend 1 Labor to harvest crops.",z);
                CollectItemsInZone("Pine Tree","Logging: Spend up to 10 Labor to chop down a tree.",z);
                if (cucumbersplanted >= 3)
                {
                    Thread.Sleep(100);   
                }
                if (cucumbersplanted <= 1) 
                {
                    PlantCucumbers(cucumbersplanted);
                }
            }
       } 
       public int PlantCucumbers(int cucumbersplanted)
       {
            RoundZone z = new RoundZone(me.X, me.Y, 5);
            PlantItemsInZone("Cucumber Seed", z);
            cucumbersplanted +=1;
            return cucumbersplanted;
       }
       public void PlantPotatos()
       {
            RoundZone z = new RoundZone(me.X, me.Y, 5);
            PlantItemsInZone("Potato Eyes", z);
       }
       //Call on plugin stop
       public void PluginStop()
       {
       }
   }
}

Its just not changing the int value of cucumbersplanted.. any help would be appreciated!!
 
Last edited:
Code:
cucumbersplanted = PlantCucumbers(cucumbersplanted);

The "cucumbersplanted" variable in "PlantCucumbers" is different variable than the variable in "PluginRun" (it could have different name), so assigning it will change the value only within the "PlantCucumbers" function. You need to reassign the value returned from your function.
 
Back
Top