Create your own Scout / Editor application for Football Manager 2010

Using the FM2010 ScoutFramework for .Net

First,

The application needs the Framework assemblies to get started, download them either via Google Code, or using the direct download in the SIGames topic.

Then fire up Visual Studio 2008, and add a reference to all of the assemblies (also the PostSharp and the Microsoft.Scripting DLL). (Right click your project, choose ‘Add references’, and locate the DLL’s).

Let’s get started

First, add references to the DLL in your form. Switch to code view and the following lines on top of your class.

using Young3.FMSearch.Interface;

using Young3.FMSearch.Core.Entities.InGame;

The application mainly uses the Interface classes. This interface contains a single ‘datacontext’ object, which allows you to talk to the Business layer. So switch to the code view of your new project, and add a new FMDataContext object!

    public partial class MainForm : Form

    {

        public FMContext fmDataContext;

 

        public MainForm()

        {

            InitializeComponent();

        }
      }

To tell the datacontext to start loading all the gamedata, we need to assign our object to a new datacontext. Go the the Form_Load function, and add the following code:

        private void MainForm_Load(object sender, EventArgs e)

        {

            fmDataContext = new FMDataContext();

            fmDataContext.LoadData();

        }

Now we’re ready to go!

Talking to the datacontext

Now we are ready to start off the real work. Add a listbox and a button to your form, and doubleclick the button to go to the code view.

Now we add the following code, to iterate through every player in the database:

            foreach (Player player in fmDataContext.Players)

            {

 

            }

Now think of something you want to know: for example, all the players with a Potential Ability of 190, and add them to the listbox. We can do so by just using a ‘if’ statement:

            foreach (Player player in fmDataContext.Players)

            {

                if (player.PotentialPlayingAbility >= 190)

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

            }

If you now start your application, you will see that the list populates when you click the button. Voila, all the (potential) superplayers from FM!

Changing player attributes

Changing the attributes of a player is pretty straightforward. First find the player you want to edit, and then assign a new value to one of his ability properties.

Add a new button to your form, and doubleclick it again to switch to code view. Then we’ll find the player in the database (using LINQ, use Google for more information), and edit his freekick stats. Note: stats range from 0 to 100!

            Player player = fmDataContext.Players.Single(p => p.FirstName == "Gijs" && p.LastName == "Cales");

            player.TechnicalSkills.Freekicks = (SByte)100;

When opening FM2009, you’ll see that his freekick ability is now 20!

Get all players from a club

If you want to give all your players a fitness of 100% for example, you can also query the database to just give you players from just one club (or nationality, or with a weekly salary of over 50.000, etc. etc. etc.). Add a new button, and throw in some new code:

1.       Search for the club

2.       Search in the players table for all players who play for this club

3.       Change the condition property for every player

            Club agovv = fmDataContext.Clubs.Single(c => c.Name == "AGOVV Apeldoorn");

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

            foreach (Player player in players)

            {

                player.Condition = 100;

            }

Want more information?

Download the sample application, and have a look at the functions! There are some pretty cool things there. Good luck!