Just a suggestion... not sure if it already have been suggested - I don´t want to read the whole thread...
First of all - we don´t use that AIRW PB thing with clean laps etc... just the "normal" LFSW PBs and the included Airio stats. Path check etc. is disabled in our Airio config.
Would it be possible to add a function to automatically delete impossible server PBs that are way faster than the current WR or a near WR time from a guy without any experience??? - perhaps these impossible PMs could be stored in the Airio message system and as soon an admin connects, he has to prove that PBs - else they will be deleted...
Well at home all worked well - but today at work I am getting that error messages again with the same source (carried it with an USB stick)...
I am using the German version - so my error message translated from me in to English might differ...
I am getting error messages about missing Spark.. - Spark cannot be found - although it´s there and addet... (see attachments)
However... could you give a hint, how to print out splits too with example4? I also would like to only log the driver specified by license name in a config file. But the LAP package only provides PName to compare - and not UName. I tried to bind the NCN and CNL packages too and to store them in a dictionary too - but I did not find a way to store the PName in a variable from the UName taken from the config file...
Here is what I - and a team mate did so far:
using System; using System.IO; using System.Collections.Generic; using Spark; using Spark.Helpers; using Spark.Packets; using System.Xml;
namespace Spark.Example4 { /// <summary> /// Example 4: Helpers. Connects to InSim, requests all players to be sent, the prints out /// the time of each player that completes a lap. /// </summary> class Program { // We store the players in a dictionary with the PLID as the key. // also store connections in a dict with UCID as the key. static InSim _insim; static int c = 0; static string pname; static string lname; static string port; static string logfile; static Dictionary<int, IS_NPL> _players = new Dictionary<int, IS_NPL>(); static Dictionary<int, IS_NCN> _conns = new Dictionary<int, IS_NCN>();
static void Main() {
//specify the config file XmlReader reader = XmlReader.Create("config.xml");
//openeing the main instance reader.ReadStartElement("config");
//reading the needed values in to a variable and closing the element reader.ReadStartElement("name"); lname = reader.ReadString(); reader.ReadEndElement();
reader.ReadStartElement("port"); int port = Convert.ToInt32(reader.ReadString()); reader.ReadEndElement();
//closing the main instance reader.ReadEndElement();
// Create new InSim object. using (_insim = new InSim()) { // Bind handlers. _insim.Bind<IS_ISM>(MultiPlayerInfo); _insim.Bind<IS_NPL>(NewPlayer); _insim.Bind<IS_PLL>(PlayerLeft); _insim.Bind<IS_LAP>(Lap); _insim.Bind<IS_NCN>(NewConn); //added to get a package with UName _insim.Bind<IS_CNL>(ConnLeft); //added to get a package with UName
// Establish the InSim connection. _insim.Connect("127.0.0.1", port);
// Initialize InSim. // Read racer name from file //first attampt to specify a single racer (me) only //StreamReader streamReader = new StreamReader("name.txt"); //lname = streamReader.ReadToEnd(); //pname = _conns[lname.UCID]; //tried to set pname from _conns Dictionary - but does not work //streamReader.Close();
static void MultiPlayerInfo(IS_ISM ism) { // When joined multiplayer request for all players to be sent. _insim.Send(new IS_TINY { ReqI = 255, SubT = TinyType.TINY_NPL }); _insim.Send(new IS_TINY { SubT = TinyType.TINY_NCN, ReqI = 255 }); //not sure if needed when binding NCN package }
static void NewPlayer(IS_NPL npl) { if (_players.ContainsKey(npl.PLID)) { // Leaving pits, just update NPL object. _players[npl.PLID] = npl; } else { // Add new player. _players.Add(npl.PLID, npl); } }
static void PlayerLeft(IS_PLL pll) { // Remove player. _players.Remove(pll.PLID); }
static void Lap(IS_LAP lap) { // Get the player who has completed the lap. var npl = _players[lap.PLID]; // Get lap number. var done = lap.LapsDone; // Get lap time string. var ltime = StringHelper.TimeString(lap.LTime); DateTime dt = DateTime.Now; // Print to console. //if (npl.PName == pname) //deactivated because using PName is not easy to type in name.txt and UName is not available in LAP package { Console.WriteLine("{0} | lap#: {1} | Laptime: {2}", npl.PName, done, ltime); //just activated for debugging using (System.IO.StreamWriter file = new System.IO.StreamWriter(@logfile, true)) { file.WriteLine("{0} | lap#: {1} | Laptime: {2}", npl.PName, done, ltime); } } }
//counting c - but no need any more I guess static int counter() { c++; return (c); } } }
Well... I am the biggest .NET / c# ever I guess...
I have just downloaded and installt MS Visual Studio 2010 for C#.
But I even cannot get Example1 working... What do I have to do with the spark.dll?? Where do I have to copy it and how do I activate it?
In my first attempt I just unzipped it right on the desktop, started a new project, copy/pasted your example code, rightclicked on the project and clicked "Add Reference" then I selected the spark.dll in the "seach" tab.
But when I start the project (F5) I am getting error messages.
I got it working, but there is one problem and two suggestion:
Problem: After ending the logging with the stop command and then closing your app, it takes quite a long time until the file is written completely (around a minute or so). I guess there is no "close file" command and Windows closes the file itself after a while.
Suggestion 1: Is it possible to only log my own times, instead of all connected racers?
Suggestion 2: Would it be possible to create an exe file of your app once it reaches final status?