Jump to content

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


DrBernhard

Recommended Posts

  • Replies 331
  • Created
  • Last Reply
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());

           }
       }

   }

}

How would I populate a datagridview with the returned list? listing things such as club, value etc..?

Link to post
Share on other sites

Crosspost about sale value

Sale value seems to be a problem in all the editors and scouts, contrary to earlier versions SI has changed the way they handle Sale Value from a solid value (e.g. the sale value is saved in the memory), to a dynamic value: all because of the new transfer system. That way it is (at this point) impossible to read a proper sale value from the memory.

I might run some tests in the next couple of days to see whether there could be an improvement.

Link to post
Share on other sites

How would I populate a datagridview with the returned list? listing things such as club, value etc..?

This will give you a list of all players with name, club and value. (assume you already have added a DataGridView with the name DataGridView1).

       private void button1_Click(object sender, EventArgs e)
       {
           DataGridView1.AutoGenerateColumns = true;
           DataGridView1.DataSource = (from p in fmDataContext.Players where p.PotentialPlayingAbility >= 190 orderby p.PotentialPlayingAbility select new { Name = p.ToString(), Club = p.Team.Club.Name, Value = p.Value }).ToList();
       }

Link to post
Share on other sites

           foreach (Player player in fmDataContext.Players)
           {
               int playerMinPA = int.Parse(paMin.Text);
               int playerMaxPA = int.Parse(paMax.Text);
               if (player.PotentialPlayingAbility > playerMinPA && player.PotentialPlayingAbility < playerMaxPA)
               {
                   dataGridView2.AutoGenerateColumns = true;
                   dataGridView2.DataSource = (from p in fmDataContext.Players orderby p.PotentialPlayingAbility select new { Name = p.ToString(), Club = p.Team.Club.Name, Value = p.Value }).ToList();
               }
           }

I cant get this to work, it just stalls the application.

Link to post
Share on other sites

managed to get it working, the foreach was looping indefinately causing it to stall.

The 'from p....' is already a loop, just written differently. You tried to populate the datagridview with (no. of players)^(no. of players), which is quite alot to process ;-)

Link to post
Share on other sites

Not implemented, if you have VS 2008 available, you can grab the Framework's source and add a property to the Entities.Ingame.Player object, which makes a call to the Prestige offset.

Thanks. Just wanted to be sure before I think about changing the framework.

Link to post
Share on other sites

Best way would through the Positional skills attribute, there is no ToString method available at this point but you might want to do something like this

string outp = "";

if (player.PositionalSkills.GoalKeeper > 15) outp += "GK ";

if (player.PositionalSkills.Defender > 15)

{

outp += "D/";

if(player.PositionalSkills.Left > 15) outp += "L";

if(player.PositionalSkills.Center > 15) outp += "C";

if(player.PositionalSkills.Right > 15) outp += "R";

outp += " ";

}

and so on.

Link to post
Share on other sites

Best way would through the Positional skills attribute, there is no ToString method available at this point but you might want to do something like this

string outp = "";

if (player.PositionalSkills.GoalKeeper > 15) outp += "GK ";

if (player.PositionalSkills.Defender > 15)

{

outp += "D/";

if(player.PositionalSkills.Left > 15) outp += "L";

if(player.PositionalSkills.Center > 15) outp += "C";

if(player.PositionalSkills.Right > 15) outp += "R";

outp += " ";

}

and so on.

thank you DrB, not sure how i'll implement this but I'll figure it out. thank again, and for the shortlists too!

Link to post
Share on other sites

thank you DrB, not sure how i'll implement this but I'll figure it out. thank again, and for the shortlists too!

Best way would be creating a function like 'public string GetPosition(Player player) {}' and then in your 'from p in fmDataC...' change your select clause to something like:

select new { Name = player.ToString(), Position = GetPosition(player) }

Link to post
Share on other sites

so..

public string GetPosition (Player player) {
string outp = "";
if (player.PositionalSkills.GoalKeeper > 15) outp += "GK ";
if (player.PositionalSkills.Defender > 15)
{
outp += "D/";
if(player.PositionalSkills.Left > 15) outp += "L";
if(player.PositionalSkills.Center > 15) outp += "C";
if(player.PositionalSkills.Right > 15) outp += "R";
outp += " ";
}
}

from p in fmDataContext.Player 
where p.PotentialPlayingAbility > "190"
select new { Name = player.ToString(), Position = GetPosition(p) }

that would work? Sorry I'm in work so I cant try it, not that Ive done any work since you actually released this framework.

Link to post
Share on other sites

so..

public string GetPosition (Player player) {
string outp = "";
if (player.PositionalSkills.GoalKeeper > 15) outp += "GK ";
if (player.PositionalSkills.Defender > 15)
{
outp += "D/";
if(player.PositionalSkills.Left > 15) outp += "L";
if(player.PositionalSkills.Center > 15) outp += "C";
if(player.PositionalSkills.Right > 15) outp += "R";
outp += " ";
}
}

from p in fmDataContext.Player 
where p.PotentialPlayingAbility > "190"
select new { Name = player.ToString(), Position = GetPosition(p) }

that would work? Sorry I'm in work so I cant try it, not that Ive done any work since you actually released this framework.

As long as public string GetPosition is outside your 'protected void button1_click' then yes.

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.

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

           String[] JoueurActif = ((Player)fmDataContext.ActiveObject).ToString().Split(' ');
           lbl_NomJoueur.Text = JoueurActif[0].ToString() + " " + JoueurActif[1].ToString();

           Player Joueurs = fmDataContext.Players.Single(cl => cl.LastName.ToLower() == JoueurActif[1].ToLower() && cl.FirstName.ToLower() == JoueurActif[0].ToLower());

           Contract Contrat = Joueurs.Contract;
           lbl_FinContrat.Text = Contrat.ContractExpiryDate.ToShortDateString();
       }

Other question ?

How can I do to update automatically information on my application when I change player in FM09 ?

Thanks all in advance.

P.S. : sorry for my bad english.

Link to post
Share on other sites

I have tried returning to main menu and reloading the game and then the fmDataContext cannot get initialized.

Also, I am not sure whether the players list and the nonplaying staff list contains all the available players and staff in the game. For example, I cannot find my own name and my players.

Link to post
Share on other sites

Is there way to change staff contract club? :D

I've tried to assign Contract.Club but it's read-only, tried to assign MemoryAddress but that doesn't work. :p So is there such possibility?

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.

Link to post
Share on other sites

no doubt there will now be loads of scout tools available to us FMers... regardless I am going to start on my own version tonight :-)

Positional ratings and importing shortlist please. Main feature I look for and none have this yet :-)

Link to post
Share on other sites

is it possible to create a search function such as public string searchQuery { };

then use

from p in fmDataContext.Players
where 
searchQuery(p)
select { blah blah blah }

ive tried but my function says "Cannot implicitly convert type 'String' to 'bool'"

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.

Link to post
Share on other sites

Hi, DrBernhard I've been playing with your framework and it looks great;)

but i think that I've found a bug in your BaseObject != opperator,

if you compare to null objects, a != b (a = null and b = null) it will return true but they are both null so it should return false ;)

       public static bool operator !=(BaseObject a, BaseObject b)
       {
           if (!System.Object.ReferenceEquals(a, b))
               return true;

           if (((object)a == null) || ((object)b == null))
               return true;

           if (a.MemoryAddress != b.MemoryAddress)
               return true;
           else
               return false;
       }

Link to post
Share on other sites

How can I get stats /20 ?

Like Dragutinovic Aggression :

Ingame he is 18/20

and with this

TextBox2.Text = player.MentalSkills.Aggression

I have 90

almost every player attribute is stored in memory as a 1-100 attribute, so if you want them to be displayed in 1-20 range, is easy,

just divide them by 5..ex 90/5 you will have the 18 that you have in game..

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