Jump to content

FM2009 Ingame Scout/Editor Framework Released! (incl. source code)


DrBernhard

Recommended Posts

  • Replies 331
  • Created
  • Last Reply
Erm you first have to lookup the memoryaddress of a club (by querying the fmDataContext), then read the memoryAddress into a Int32, and then write the int32 to the Contract.ClubPointer (or clubaddress, don't have source here atm) address. Although I'm not sure that will suddenly works. Had loads of problems doing that for players.

ClubPointer is private, so there is no access to it outside class scope. I've changed it to public, but even that doesn't work. As you said - there are problems. Staff is still in old club but I have options to offer new contract, sack him etc. :D

Link to post
Share on other sites

You can do by invoking properties using reflection, though not a beginners-topic.

Better would be a base list which gets filtered:

IEnumerable<Player> base = fmDataContext.Players;

if(!string.IsNullOrEmpty(AgeMinTextbox.Text)) base = base.Where(p=>p.Age > int.Parse(AgeMinTextbox.Text));
if(!string.IsNullOrEmpty(AgeMaxTextbox.Text)) base = base.Where(p=>p.Age < int.Parse(AgeMaxTextbox.Text));

etc.

is there anywhere I can read about these, im struggling to implement a base list.

Link to post
Share on other sites

Hello all,

Could you tell me what is wrong in my code below ?

The ContractExpiryDate is not the good for french player "Stephane Cassard'.

In game I have 30/06/2009 and in my application I have 01/01/2056.

Replacing with the following code worked for me:

In Young3.FMSearch.Business.Entities.InGame.Player

   private int ContractAddress
   {
       get {
           return ProcessManager.ReadInt32(ProcessManager.ReadInt32(MemoryAddress + PlayerOffsets.ContractAddress));
           //return ProcessManager.ReadInt32(MemoryAddress + PlayerOffsets.ContractAddress);
       }
       set { ProcessManager.WriteInt32(value, ProcessManager.ReadInt32(MemoryAddress + PlayerOffsets.ContractAddress)); }
   }


In Young3.FMSearch.Business.Entities.InGame.Contract

   public DateTime ContractExpiryDate
   {
       get
       {
           return ProcessManager.ReadDateTime(MemoryAddress + ContractOffsets.ContractExpiresDays);
       }
       set
       {
           ProcessManager.WriteDateTime(value, MemoryAddress + ContractOffsets.ContractExpiresDays);
       }
   }

Link to post
Share on other sites

Replacing with the following code worked for me:

In Young3.FMSearch.Business.Entities.InGame.Player

   private int ContractAddress
   {
       get {
           return ProcessManager.ReadInt32(ProcessManager.ReadInt32(MemoryAddress + PlayerOffsets.ContractAddress));
           //return ProcessManager.ReadInt32(MemoryAddress + PlayerOffsets.ContractAddress);
       }
       set { ProcessManager.WriteInt32(value, ProcessManager.ReadInt32(MemoryAddress + PlayerOffsets.ContractAddress)); }
   }


In Young3.FMSearch.Business.Entities.InGame.Contract

   public DateTime ContractExpiryDate
   {
       get
       {
           return ProcessManager.ReadDateTime(MemoryAddress + ContractOffsets.ContractExpiresDays);
       }
       set
       {
           ProcessManager.WriteDateTime(value, MemoryAddress + ContractOffsets.ContractExpiresDays);
       }
   }

Terrific, thanks, I will add to SVN shortly.

               string playerID;
               playerID = this.dataGridView2.CurrentRow.Cells[0].Value.ToString();
               Player id = fmDataContext.Players.Single(i=>i.ID==playerID);

why will this not work?

You have to cast playerID to an integer. So it would be Player id = fmDataContext.Players.Single(i=>i.ID==int.Parse(playerID));

What is the difference between PositionalSkills and newPositionalSkills ?

PositionalSkills are the current skills, newPosSkills are the possible skills a player can have (after training and such)

Link to post
Share on other sites

thanks DrB, now it doesnt seem to compile on the LINQ

               string playerID;
               playerID = this.dataGridView2.CurrentRow.Cells[0].Value.ToString();
               Player pid = fmDataContext.Players.Single(i=>i.ID==int.Parse(playerID));
               var playerIdQuery =
                   from q in fmDataContext.Players
                   where 
                   q.ID != null && q.ID == pid    <-- this line
                   select new {
                       ID = q.ID,
                       Name = q.ToString(),
                       Club = q.Team.Club.Name,
                    }

Link to post
Share on other sites

thanks DrB

Every player should have a value for left or right foot right?

Using ...

public string GetFoot(Player player)
       {
           string outp = "";
               if ((player.PhysicalSkills.LeftFoot >= 80) && (player.PhysicalSkills.RightFoot >= 80))
               {
                   outp += "Either";
               }
               if ((player.PhysicalSkills.LeftFoot < 80) && (player.PhysicalSkills.LeftFoot >= 50) && (player.PhysicalSkills.RightFoot >= 80))
               {
                   outp += "Right";
               }
               if ((player.PhysicalSkills.LeftFoot < 50) && (player.PhysicalSkills.RightFoot >= 80))
               {
                   outp += "Right Only";
               }
               if ((player.PhysicalSkills.LeftFoot >= 80) && (player.PhysicalSkills.RightFoot >= 50) && (player.PhysicalSkills.RightFoot < 80))
               {
                   outp += "Left";
               }
               if ((player.PhysicalSkills.LeftFoot >= 80) && (player.PhysicalSkills.RightFoot < 50))
               {
                   outp += "Left Only";
               }
               if ((player.PhysicalSkills.LeftFoot < 50) && (player.PhysicalSkills.RightFoot < 50))
               {
                   outp += "Neither";
               }
       }

Returns a compile error saying not all code paths return a value, Ive even tried it so that both values are checked for null

Link to post
Share on other sites

why can you get the club name under player.team.club.name and under player.contract.club.name you cant?

and why it seems that all nonplayingstaf have the same roles?

Two more issues i've found include the player wages which are wrong and the player contract expiry dates.

Link to post
Share on other sites

Here are the player happiness and squad number off sets. Both go in the Contract.cs file, in the Offsets folder.

Public Shared Happines As Integer = 49

Public Shared SquadNumber As Integer = 50

Here are 2 properties to store those values, both go in the contract.cs file in the InGame folder.

Public Property Happiness() As Integer

Get

Return ProcessManager.ReadByte(MemoryAddress + ContractOffsets.Happines)

End Get

Set(ByVal value As Integer)

ProcessManager.WriteByte(value, MemoryAddress + ContractOffsets.Happines)

End Set

End Property

Public Property SquadNumber() As Integer

Get

Return ProcessManager.ReadByte(MemoryAddress + ContractOffsets.SquadNumber)

End Get

Set(ByVal value As Integer)

ProcessManager.WriteByte(value, MemoryAddress + ContractOffsets.SquadNumber)

End Set

End Property

Link to post
Share on other sites

Ok, something I found weird. Currently I get the players wages wrong and player expiry dates wrong. For staff it's ok. Had a look on the source code and i was wondering how:

1) I get the player wages wrong since they come out ok and

2) how the expiry dates for staff work while there is the following for both player and staff:

 get
           {
               //TODO: Can't get it to work
               try {
                   int year = ProcessManager.ReadInt16(MemoryAddress + ContractOffsets.ContractExpiresYear);
                   int days = ProcessManager.ReadInt16(MemoryAddress + ContractOffsets.ContractExpiresDays);

                   DateTime bla = new DateTime(year, 1, 1);
                   bla.AddDays(days);

                   return bla;
               }
               catch { return new DateTime(1900,1,1); }

           }

Also why i can get the club under Team.Club and not under Contract.Club? Well the code is different there for a start!

Link to post
Share on other sites

DrBernhard

this works for me:

       public DateTime ContractExpiryDate
       {
           get
           {
              return ProcessManager.ReadDateTime(MemoryAddress + ContractOffsets.ContractExpires);
           }
           set
           {
               ProcessManager.WriteDateTime(value, MemoryAddress + ContractOffsets.ContractExpires);
           }
       }

       public DateTime ContractStarted
       {
           get
           {
               return ProcessManager.ReadDateTime(MemoryAddress + ContractOffsets.ContractStarted);
           }
           set
           {
               ProcessManager.WriteDateTime(value, MemoryAddress + ContractOffsets.ContractStarted);
           }
       }

where ContractOffsets.ContractExpires = 0x1c;

Also removed the try catch from public static DateTime FromFmDateTime(int date) as this was causing extreme slow down when was trying to set the contract date in a for loop.

Link to post
Share on other sites

Changelog:

Updates in SVN and in both the demo project and the assembly link

* Contract works as it's supposed to be

* Co-Contract and Loan-contract supported

* Added happiness and squad number (under Contract)

* Shortlist export in Interface.Common

* PositionalSkills.ToString() for directly seeing the pos. skills as a string value

* Added WSM as supported process, might help some steam WSM users

* Non-playing staff bug, shows now all the np staff in the game

Link to post
Share on other sites

I tried to find the place where you can change the build date of a new stadium. Don't want to wait 8 years before the stadium will be build :D But didn't find it :( Can't you change it? Someone who already found this?

Someone who can help me? ;)

Link to post
Share on other sites

btnFindclub ... etc etc..

{

IEnumerable<Club> clubs = fmDataContext.Clubs.Where(c => c.Name.Contains(txtClub.Text));

listBox1.Items.Add(clubs.ToString());

}

doesnt work. whats the code to search a club if a user types "man" and it outputs all clubs with the name "man" in them like Manchester. lol cant seem to figure out the basics :) its been awhile since i use c#..

Link to post
Share on other sites

btnFindclub ... etc etc..

{

IEnumerable<Club> clubs = fmDataContext.Clubs.Where(c => c.Name.Contains(txtClub.Text));

listBox1.Items.Add(clubs.ToString());

}

doesnt work. whats the code to search a club if a user types "man" and it outputs all clubs with the name "man" in them like Manchester. lol cant seem to figure out the basics :) its been awhile since i use c#..

private void button1_Click(object sender, EventArgs e)

{

string clubname = textBox1.Text;

Club agovv = fmDataContext.Clubs.Single(c => c.Name == clubname);

IEnumerable<Player> players = fmDataContext.Players.Where(p => p.Team.Club == agovv);

listBox1.Items.Add(clubname.ToString());

}

that work for me.. but when i enter man.. it crashes....

Link to post
Share on other sites

thanks..

i am now at the Find a club part.. having problems getting the right results..

like when i type "manchester", my listbox should display Manchester United, Manchester City.

Then from there, i choose one to edit the club.

but damn it im stuck doing the search filter :)

can we have a sneak peak at FM Agent source code? it would realllly help on the functions..

Link to post
Share on other sites

btnFindclub ... etc etc..

{

IEnumerable<Club> clubs = fmDataContext.Clubs.Where(c => c.Name.Contains(txtClub.Text));

listBox1.Items.Add(clubs.ToString());

}

doesnt work. whats the code to search a club if a user types "man" and it outputs all clubs with the name "man" in them like Manchester. lol cant seem to figure out the basics :) its been awhile since i use c#..

hi guys.. anyone got msn so we can all help eachother?

Link to post
Share on other sites

btnFindclub ... etc etc..

{

IEnumerable<Club> clubs = fmDataContext.Clubs.Where(c => c.Name.Contains(txtClub.Text));

listBox1.Items.Add(clubs.ToString());

}

doesnt work. whats the code to search a club if a user types "man" and it outputs all clubs with the name "man" in them like Manchester. lol cant seem to figure out the basics :) its been awhile since i use c#..

Something like this?

private static IEnumerable<Club> FindClub(string searchString)
{
  string pattern = "^" + searchString;
  return data.Clubs.Where(club => Regex.IsMatch(club.Name, pattern, RegexOptions.IgnoreCase));
}

Link to post
Share on other sites

i got it working..

button Search ...
{
IEnumerable<Club> allclubs = fmDataContext.Clubs.Where(p => p.Name.ToLower().Contains(txtClub.Text));

           foreach (Club club in allclubs)
           {

              listBox1.Items.Add(club.Name.ToString());

           }
}

Use this if you want to Search for a club.

For example on the textbox, you search "tott", it will produce Tottenham Hotspurs..

if i get from Players data, you can display players too which will result Totti.

Ok my next step.. how to select the club i searched for and display its data..

Link to post
Share on other sites

Just thought that I'd let you all know, that I am working on converting the c# source code that DrBernHard has done to VB.NET, as this is what I program in.

I have converted all the code, but I just need to test it all.

Once I am happy with it, I'll let you all know.

Link to post
Share on other sites

Ive come to a bit of a halt with mine at the moment, it was looking really well, but lost a bit of motivation due to the xmas rush. Will try get back into over the weekend. Having trouble with passing data from datagridview in form1 (search results) to form2, a row is double clicked to load form2 to display all player data, I've passed it using bindingsource but its very messy :/

Link to post
Share on other sites

That seems to give you the reputation

       public int CurrentPrestige
       {
           get { return ProcessManager.ReadInt16(MemoryAddress + PlayerOffsets.CurrentPrestige); }
           set { ProcessManager.WriteInt16(value, MemoryAddress + PlayerOffsets.CurrentPrestige); }
       }

       public int NationalPrestige
       {
           get { return ProcessManager.ReadInt16(MemoryAddress + PlayerOffsets.NationalPrestige); }
           set { ProcessManager.WriteInt16(value, MemoryAddress + PlayerOffsets.NationalPrestige); }
       }

       public int InternationalPrestige
       {
           get { return ProcessManager.ReadInt16(MemoryAddress + PlayerOffsets.InternationalPrestige); }
           set { ProcessManager.WriteInt16(value, MemoryAddress + PlayerOffsets.InternationalPrestige); }
       }

       public int CurrentPrestige
       {
           get { return ProcessManager.ReadInt16(MemoryAddress + StaffOffsets.CurrentPrestige); }
           set { ProcessManager.WriteInt16(value, MemoryAddress + StaffOffsets.CurrentPrestige); }
       }

       public int NationalPrestige
       {
           get { return ProcessManager.ReadInt16(MemoryAddress + StaffOffsets.NationalPrestige); }
           set { ProcessManager.WriteInt16(value, MemoryAddress + StaffOffsets.NationalPrestige); }
       }

       public int InternationalPrestige
       {
           get { return ProcessManager.ReadInt16(MemoryAddress + StaffOffsets.InternationalPrestige); }
           set { ProcessManager.WriteInt16(value, MemoryAddress + StaffOffsets.InternationalPrestige); }
       }

Link to post
Share on other sites

It doesn't work properly when I tried to list clubs from countries like Brazil, Germany and Argentina.

The relationship between clubs and countries does not exist.

Correct, is a known bug. You can see the current bug list on the google project page.

Link to post
Share on other sites

Will checkin new version with the following functions somewhere in the near future (worked on these closely with ruci)

* Changing nations (EU members, years to gain nationality, etc. all the new features ruci also has)

* Player transfer (that's actually all ruci's work)

* Prestiges (immuner)

* Search clubs by nation

Will wait until after ruci has released FMRTE new version.

Link to post
Share on other sites

thanks DrB

If I had

               IEnumerable<Player> filter = fmDataContext.Players;

               if (!string.IsNullOrEmpty(pNationalityCombo.Text)) 
               {
                   filter = filter.Where(p=>p.Nationality.Name == pNationalityCombo.Text);
               }
               if (!string.IsNullOrEmpty(continentSearchCombo.Text))
               {
                   filter = filter.Where(p => p.Nationality.Continent.Name == continentSearchCombo.Text);
               }
                   filter = filter.Where(p => p.Age >= minAge.Value);
                   filter = filter.Where(p => p.Age <= maxAge.Value);
                   filter = filter.Where(p => p.CurrentPlayingAbility >= caMin.Value);
                   filter = filter.Where(p => p.CurrentPlayingAbility <= caMax.Value);
                   filter = filter.Where(p => p.PotentialPlayingAbility >= paMin.Value);
                   filter = filter.Where(p => p.PotentialPlayingAbility <= paMax.Value);
                   filter = filter.Where(p => p.Value >= minValue.Value);
                   filter = filter.Where(p => p.Value <= maxValue.Value);
                   filter = filter.Where(p => p.SaleValue >= minSaleValue.Value);
                   filter = filter.Where(p => p.SaleValue <= maxSaleValue.Value);

Can I then LINQ query filter ... var searchquery = from p in filter select { Name = p.Name } ???

Link to post
Share on other sites

thanks DrB

If I had

               IEnumerable<Player> filter = fmDataContext.Players;

               if (!string.IsNullOrEmpty(pNationalityCombo.Text)) 
               {
                   filter = filter.Where(p=>p.Nationality.Name == pNationalityCombo.Text);
               }
               if (!string.IsNullOrEmpty(continentSearchCombo.Text))
               {
                   filter = filter.Where(p => p.Nationality.Continent.Name == continentSearchCombo.Text);
               }
                   filter = filter.Where(p => p.Age >= minAge.Value);
                   filter = filter.Where(p => p.Age <= maxAge.Value);
                   filter = filter.Where(p => p.CurrentPlayingAbility >= caMin.Value);
                   filter = filter.Where(p => p.CurrentPlayingAbility <= caMax.Value);
                   filter = filter.Where(p => p.PotentialPlayingAbility >= paMin.Value);
                   filter = filter.Where(p => p.PotentialPlayingAbility <= paMax.Value);
                   filter = filter.Where(p => p.Value >= minValue.Value);
                   filter = filter.Where(p => p.Value <= maxValue.Value);
                   filter = filter.Where(p => p.SaleValue >= minSaleValue.Value);
                   filter = filter.Where(p => p.SaleValue <= maxSaleValue.Value);

Can I then LINQ query filter ... var searchquery = from p in filter select { Name = p.Name } ???

Yup! _

Link to post
Share on other sites

Patch that adds clean sheet bonus and club job types for staff.

Index: Entities/InGame/Contract.cs
===================================================================
--- Entities/InGame/Contract.cs	(revision 5)
+++ Entities/InGame/Contract.cs	(working copy)
@@ -29,6 +29,18 @@
            }
        }

+        public int CleanSheetBonus
+        {
+            get
+            {
+                return ProcessManager.ReadInt32(MemoryAddress + ContractOffsets.CleanSheetBonus);
+            }
+            set
+            {
+                ProcessManager.WriteInt32(value, MemoryAddress + ContractOffsets.CleanSheetBonus);
+            }
+        }
+
        private int ClubPointer
        {
            get
@@ -87,6 +99,31 @@
            }
        }

+        public byte JobType
+        {
+            /*
+             * Contracts for directors etc. may have been removed.
+             * Club jobs values below. National jobs are different.
+             * 02 - 0000 0010   Coach
+             * 12 - 0000 1100   Physio
+             * 14 - 0000 1110   Scout
+             * 16 - 0001 0000   Manager
+             * 20 - 0001 0100   Ast Man
+             * 26 - 0001 1010   Fitness coach
+             * 34 - 0010 0010   Gk coach
+             * 48 - 0011 0000   Youth coach
+             * 54 - 0011 0110   1st Team coach
+             */
+            get
+            {
+                return ProcessManager.ReadByte(MemoryAddress + ContractOffsets.JobType);
+            }
+            set
+            {
+                ProcessManager.WriteByte(value, MemoryAddress + ContractOffsets.JobType);
+            }
+        }
+
        public int WagePerWeek
        {
            get
Index: Offsets/Contract.cs
===================================================================
--- Offsets/Contract.cs	(revision 5)
+++ Offsets/Contract.cs	(working copy)
@@ -7,10 +7,12 @@
    public sealed class ContractOffsets 
    {
        public static int AppearanceBonus = 0x48;
+        public static int CleanSheetBonus = 80;
        public static int ClubPointer = 8;
        public static int ContractExpires = 0x1c;
        public static int ContractStarted = 20;
        public static int GoalBonus = 0x4c;
+        public static int JobType = 69;
        public static int Wages = 12;
        public static int Happiness = 49;
        public static int SquadNumber = 50;

Link to post
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...