Jump to content

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


DrBernhard

Recommended Posts

Last update: 2008/12/02

Source code (checkout via SVN): http://code.google.com/p/fm2009scoutframework/

Sample application (including assemblies): http://www.100procentjan.nl/fm2009/FMScoutFrameworkSample.zip

Assemblies only: http://www.100procentjan.nl/fm2009/FrameworkAssemblies.zip

----------------------------------------------------------------------------------------------------------

Ever wanted to build your own FMScout, FMRTE? Ever wanted to do crazy stuff to the ingame database, but no button in FMEditor which provided the function? Now you can build everything you want on your own!

Today, the very first version of the FM 2009 Scout/Editor Framework is released! A ready-to-use assembly, which can be included in any .Net project (both Visual Basic and C#). The Framework gives you the ability to query the database using LinQ, make changes to the game's objects, and produce your own personalized editor!

Main features

* Query the ingame database

* Find players, clubs, staff, cities, continents, stadiums, teams, etc.

* Make realtime changes to the database

* Create complex filters

* Get the active player, and show his stats immediately

* Perform batch operations on a whole bunch of players

* Open source!

Wanted to get started

First of all, if you just want to get started, grab the SampleApplication from SVN or use the direct download link (above), open the (C#) project in VS2008, and hit the compile button.

If you want a little tutorial, click http://www.100procentjan.nl/fm2009/tutorial.htm

Feel free to contribute

Just join on Google Code, make cool additions to the framework (or solve some issues ;-)) and check your code back in!

Donations?

Please don't! Buy yourself a beer!

--------------

Last changes:

* 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

  • Replies 331
  • Created
  • Last Reply
Im not totally inexperienced btw Im just not sure how the whole framework works as I never used a Microsoft Visual Dev suite before (Y)

Fire up Visual Studio, Add references to the project (as shown in the tutorial), and create a FMDataContext object. Add a DataGridView to your form, and a button, doubleclick the button, and add the following code:

DataGridView1.AutoGenerateColumns = true;

Club club = fmDataContext.Clubs.Single(c=>c.Name=="Your club name");

DataGridView1.DataSource = (from p in fmDataContext.Players where p.Team != null && p.Team.Club == club select new { Name = p.FirstName + " " + p.LastName, CA = p.CurrentPlayingAbility, PA = p.PotentialPlayingAbility }).ToList();

The grid will now populate with all your players, including columns for their CA and PA.

Link to post
Share on other sites

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Young3.FMSearch.Interface;
using Young3.FMSearch.Business.Entities.InGame;
using System.Reflection;

namespace SampleApplication
{
   public partial class MainForm : Form
   {
       public FMDataContext fmDataContext;

       public MainForm()
       {
           InitializeComponent();
       }

       private void MainForm_Load(object sender, EventArgs e)
       {
           fmDataContext = new FMDataContext();
           {
               this.ClubsComboBox.DataSource = fmDataContext.Clubs.OrderBy(c => c.Name).ToList();
           }
       }

       private void button1_Click(object sender, EventArgs e)
       {
           DataGridView1.AutoGenerateColumns = true;
Club club = fmDataContext.Clubs.Single(c=>c.Name=="Aberdeen");
DataGridView1.DataSource = (from p in fmDataContext.Players where p.Team != null && p.Team.Club == club select new { Name = p.FirstName + " " + p.LastName, CA = p.CurrentPlayingAbility, PA = p.PotentialPlayingAbility }).ToList();
       }


       }
   }
}

Link to post
Share on other sites

Error 1 'SampleApplication.MainForm' does not contain a definition for 'ClubsComboBox' and no extension method 'ClubsComboBox' accepting a first argument of type 'SampleApplication.MainForm' could be found (are you missing a using directive or an assembly reference?) C:\Users\****\AppData\Local\Temporary Projects\WindowsFormsApplication1\Form1.cs 28 22 WindowsFormsApplication1

Error 2 The name 'DataGridView1' does not exist in the current context C:\Users\****\AppData\Local\Temporary Projects\WindowsFormsApplication1\Form1.cs 34 13 WindowsFormsApplication1

Error 3 The name 'DataGridView1' does not exist in the current context C:\Users\****\AppData\Local\Temporary Projects\WindowsFormsApplication1\Form1.cs 36 13 WindowsFormsApplication1

Error 4 The type or namespace name 'Form1' could not be found (are you missing a using directive or an assembly reference?) C:\Users\****\AppData\Local\Temporary Projects\WindowsFormsApplication1\Program.cs 18 33 WindowsFormsApplication1

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Young3.FMSearch.Interface;
using Young3.FMSearch.Business.Entities.InGame;
using System.Reflection;

namespace SampleApplication
{
   public partial class MainForm : Form
   {
       public FMDataContext fmDataContext;

       public MainForm()
       {
           InitializeComponent();
       }

       private void MainForm_Load(object sender, EventArgs e)
       {
           fmDataContext = new FMDataContext();
           {
               this.ClubsComboBox.DataSource = fmDataContext.Clubs.OrderBy(c => c.Name).ToList();
           }
       }

       private void button1_Click(object sender, EventArgs e)
       {
           DataGridView1.AutoGenerateColumns = true;
           Club club = fmDataContext.Clubs.Single(c => c.Name == "Aberdeen");
           DataGridView1.DataSource = (from p in fmDataContext.Players where p.Team != null && p.Team.Club == club select new { Name = p.FirstName + " " + p.LastName, CA = p.CurrentPlayingAbility, PA = p.PotentialPlayingAbility }).ToList();
       }


   }
}

Im sorry for the trouble and I am very grateful for your help I am able to make an application look fairly nice but getting it to work is the problem ;)

Link to post
Share on other sites

You have to delete the following code:

this.ClubsComboBox.DataSource = fmDataContext.Clubs.OrderBy(c => c.Name).ToList();

Then you have to add a DataGridView to your form (in Design View), with the name 'DataGridView1'.

If this doesn't work, rename 'public partial class MainForm' to 'public partial class Form1'. If this still doesn't work, please ZIP your complete folder, and upload it, so I can have a look.

Link to post
Share on other sites

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Reflection;
using System.Windows.Forms;
using Young3.FMSearch.Interface;
using Young3.FMSearch.Business.Entities.InGame;

namespace WindowsFormsApplication1
{
   public partial class Form1 : Form
   {
       public FMDataContext fmDataContext;

       public Form1()
       {
           InitializeComponent();
       }
       private void Form1_Load(object sender, EventArgs e)
       {
           fmDataContext = new FMDataContext();
       }

       private void button1_Click(object sender, EventArgs e)
       {
           foreach (Player player in fmDataContext.Players)
           {
               if (player.PotentialPlayingAbility >= 190)
               listBox1.Items.Add(player.ToString());

           }
       }

   }

}

Whenever I run this and press the button, it gives an error saying "Object reference not set to an instance of an object."

fmDataContext is null, any help would be appreciated.

Link to post
Share on other sites

foreach (Player player in fmDataContext.Players)

this line was giving the error, NullReferenceException was unhandled - Object reference was not set to an instance of an object

Can you verify that:

- FM2009 is running

- That you have version 9.01

- That your process is called fm

- That your code reaches the fmDataContext = new FMDataContext();

When I'm using a LINQ with Player.Age with criteria, it will flow an exception

var PlayerCollection =

from p in GlobalVar.FMDataContext.Players.AsEnumerable()

where p.Age >= 18 && p.Age <= 24

and ...................

select p;

Was a bug in the datetime parsing, have fixed it, new assembly available through SVN or via the Sample Application download link.

Link to post
Share on other sites

PM'd you the link with the zipped up folder of the project thank you again

Open your project in Visual C# 2008, click once on the form, and go in the right properties screen to the icon showed below, go to 'Load' and select 'MainForm_Load':

help01.png

Then click on the 'Aberdeen' button, choose 'Click' and select 'button1_click':

help02.png

Link to post
Share on other sites

FM2009 is running, version is 9.01 and the process is fm.exe, I assumed the code was reaching that point to give the error.

Would I be best validating it with

if (fmDataContext != null) { }

or something?

Well, if your application reaches your form_load then everything is fine, and there won't be any check necessary. Do you also have problems running the SampleApplication ?

Link to post
Share on other sites

Capture-17.jpg

Ive tried the club name as well as the ID im so close and so grateful for your help. If/After I get this working I will touch it up graphically and release it with full credits to you of course.

You need to have the complete full name of the club, or you can try something like this if you are for example looking for 'AGOVV Apeldoorn':

fmDataContext.Clubs.Single(c=>c.Name.ToLower().StartsWith("agovv"));

Link to post
Share on other sites

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Young3.FMSearch.Interface;
using Young3.FMSearch.Business.Entities.InGame;
using System.Reflection;

namespace SampleApplication
{
   public partial class Form1 : Form
   {
       public FMDataContext fmDataContext;

       public Form1()
       {
           InitializeComponent();
       }

       private void MainForm_Load(object sender, EventArgs e)
       {
           fmDataContext = new FMDataContext();
           {

           }
       }

       private void button1_Click(object sender, EventArgs e)
       {
           dataGridView1.AutoGenerateColumns = true;
           Club club = fmDataContext.Clubs.Single(c=>c.Name.ToLower().StartsWith("Aberdeen"));
           dataGridView1.DataSource = (from p in fmDataContext.Players where p.Team != null && p.Team.Club == club select new { Name = p.FirstName + " " + p.LastName, CA = p.CurrentPlayingAbility, PA = p.PotentialPlayingAbility }).ToList();
       }

       private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
       {

       }


   }
}

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...