Beispiel #1
0
        void RunInSim()
        {
            // Bind packet events.
            insim.Bind <IS_NCN>(NewConnection);
            insim.Bind <IS_NPL>(NewPlayer);
            insim.Bind <IS_MSO>(MessageReceived);
            insim.Bind <IS_MCI>(MultiCarInfo);
            insim.Bind <IS_CNL>(ConnectionLeave);
            insim.Bind <IS_CPR>(ClientRenames);
            insim.Bind <IS_PLL>(PlayerLeave);
            insim.Bind <IS_STA>(OnStateChange);
            insim.Bind <IS_BTC>(ButtonClicked);
            insim.Bind <IS_BFN>(ClearButtons);
            insim.Bind <IS_VTN>(VoteNotify);
            insim.Bind <IS_AXI>(AutocrossInformation);

            // Initialize InSim
            insim.Initialize(new InSimSettings
            {
                Host   = "127.0.0.1", // 93.190.143.115
                Port   = 29999,
                Admin  = "2910",
                Prefix = '!',
                Flags  = InSimFlags.ISF_MCI | InSimFlags.ISF_MSO_COLS,

                Interval = 1000
            });

            insim.Send(new[]
            {
                new IS_TINY {
                    SubT = TinyType.TINY_NCN, ReqI = 255
                },
                new IS_TINY {
                    SubT = TinyType.TINY_NPL, ReqI = 255
                },
                new IS_TINY {
                    SubT = TinyType.TINY_ISM, ReqI = 255
                },
                new IS_TINY {
                    SubT = TinyType.TINY_SST, ReqI = 255
                },
                new IS_TINY {
                    SubT = TinyType.TINY_MCI, ReqI = 255
                },
                new IS_TINY {
                    SubT = TinyType.TINY_NCI, ReqI = 255
                },
                new IS_TINY {
                    SubT = TinyType.TINY_AXI, ReqI = 255
                },
                new IS_TINY {
                    SubT = TinyType.TINY_SST, ReqI = 255
                },
            });

            insim.Send(255, 0, "^3NOTE: ^8InSim connected with version ^2" + InSimVersion);
        }
Beispiel #2
0
        public CruiseEngine()
        {
            _inSim = new InSim();
            _time  = new TimeManagement();

            allCars    = new AllCars();
            buttons    = new Buttons();
            chat       = new String[100];
            chatBuffer = new String[100];
            count      = 0;
            players    = new PlayerInfo();

            parameters      = new Parameters();
            commands        = new Commands();
            calculations    = new Calculations();
            drag            = new Events.Drag();
            carAheadWarning = new Systems.CarAhead();

            activePLID  = -1;
            activePLID2 = -1;
            active      = true;

            lastCrashNameA = "";
            lastCrashNameB = "";

            avgSpeeds = new double[5];

            _inSim.Bind <IS_MSO>(MessageOut);
            _inSim.Bind <IS_MCI>(CarDataIn);
            _inSim.Bind <IS_STA>(PlayerInfo);
            _inSim.Bind <IS_NPL>(NewPlayer);
            _inSim.Bind <IS_NCN>(NewConnection);
            _inSim.Bind <IS_CNL>(Disconnected);
            _inSim.Bind <IS_PLP>(PlayerPits);
            _inSim.Bind <IS_PLL>(PlayerSpectates);
            _inSim.Bind <IS_CRS>(CarReset);
            _inSim.Bind <IS_PIT>(PITStop);
            _inSim.Bind <IS_PSF>(PITFInished);
            _inSim.Bind <IS_CON>(Crash);
            _inSim.Bind <IS_TOC>(CarTakeOver);
            _inSim.Bind <IS_BTC>(ButtonPressed);
            _inSim.Bind <IS_BTT>(ButtonText);

            // Initialize InSim
            _inSim.Initialize(new InSimSettings
            {
                Host     = "127.0.0.1",
                Port     = 29999,
                Admin    = "ed",
                Interval = 250,
                Flags    = InSimFlags.ISF_MCI + (int)InSimFlags.ISF_LOCAL + (int)InSimFlags.ISF_CON
            });

            // For now, this will give enough time to make a connection without trying to run any inSim commands
            Thread.Sleep(500);
            run();
        }
Beispiel #3
0
        private void Form1_Load(object sender, EventArgs e)
        {
            InSim insim = new InSim();

            // Initialize InSim
            insim.Initialize(new InSimSettings
            {
                Host     = "127.0.0.1",
                Port     = 29999,
                Admin    = "123123",
                Flags    = InSimFlags.ISF_MCI | InSimFlags.ISF_CON,
                Interval = 1000,
                IName    = "EmirhanPala",
            });

            // Send message to LFS
            insim.Send("/msg Canlı button, InSim-EmirhanPala!");
            insim.Bind <IS_MCI>(ButtonGorunumu);
        }
Beispiel #4
0
        public void connect_Click(object sender, EventArgs e)
        {
            insim.Bind <IS_MSO>(MessageOut);
            string value = textBox1.Text;

            textBox2.Text  += "Insim Connected";
            connect.Text    = "Connected!";
            connect.Enabled = false;

            //     insim.Bind<IS_MSO>(Comma);


            //  string[] StrMsg = Msg.Split(' ');

            // Initailize InSim
            insim.Initialize(new InSimSettings
            {
                Host  = "127.0.0.1", // Host where LFS is runing
                Port  = 30000,       // Port to connect to LFS through
                Admin = "2910",      // Optional game admin password
            });
        }
Beispiel #5
0
        public static void Main(string[] args)
        {
            string IP             = INI.Read("config.ini", "IP");
            ushort Port           = ushort.Parse(INI.Read("config.ini", "Port"));
            string Admin_Password = INI.Read("config.ini", "Admin_Password");

            while (true)
            {
                if (!insim.IsConnected)
                {
                    insim.Bind <IS_ISM>(InSim_Multi.ISM);
                    insim.Bind <IS_NCN>(New_Connection.NCN);
                    insim.Bind <IS_NCI>(New_Connection_Identification.NCI);
                    insim.Bind <IS_CNL>(Connection_Leave.CNL);
                    insim.Bind <IS_NPL>(Leave_Pit.NPL);
                    insim.Bind <IS_PLP>(Goes_To_Pit.PLP);
                    insim.Bind <IS_PLL>(Goes_To_Spectator.PLL);
                    insim.Bind <IS_MCI>(Message_Car_Information.MCI);
                    insim.Bind <IS_MSO>(Message_Output.MSO);

                    insim.Initialize(new InSimSettings
                    {
                        Host     = IP,
                        Port     = Port,
                        Admin    = Admin_Password,
                        Flags    = InSimFlags.ISF_MSO_COLS | InSimFlags.ISF_MCI,
                        Interval = 1000,
                        Prefix   = '!',
                        IName    = "^0L^7I^0B"
                    });

                    insim.Send(new IS_TINY {
                        ReqI = 2, SubT = TinyType.TINY_ISM
                    });

                    Logger.Info($"InSim Base - InSim\nInitialized with success, in {IP}:{Port}", Logger.Types.Initialize);
                }
            }
        }
Beispiel #6
0
        void RunInSim()
        {
            // Bind packet events.
            insim.Bind <IS_NCN>(NewConnection);
            insim.Bind <IS_NPL>(NewPlayer);
            insim.Bind <IS_MSO>(MessageReceived);
            insim.Bind <IS_MCI>(MultiCarInfo);
            insim.Bind <IS_CNL>(ConnectionLeave);
            insim.Bind <IS_CPR>(ClientRenames);
            // insim.Bind<IS_PLL>(PlayerLeave);
            insim.Bind <IS_STA>(OnStateChange);
            // insim.Bind<IS_BTC>(ButtonClicked);
            insim.Bind <IS_BFN>(ClearButtons);
            // insim.Bind<IS_VTN>(VoteNotify);
            insim.Bind <IS_AXI>(OnAutocrossInformation);
            // insim.Bind<IS_TINY>(OnTinyReceived);
            // insim.Bind<IS_CON>(CarCOntact);
            insim.Bind <IS_BTT>(ButtonType);
            insim.Bind <IS_LAP>(Laps);
            insim.Bind <IS_RES>(Res);
            insim.Bind <IS_PIT>(Pitstop);
            insim.Bind <IS_HLV>(HotLapValidity);
            insim.Bind <IS_RES>(Result);

            // Initialize InSim
            insim.Initialize(new InSimSettings
            {
                Host   = "51.254.134.112", // 51.254.134.112         192.168.3.10
                Port   = 29999,
                Admin  = "2910693997",
                Prefix = '!',
                Flags  = InSimFlags.ISF_MCI | InSimFlags.ISF_MSO_COLS | InSimFlags.ISF_CON | InSimFlags.ISF_RES_0 | InSimFlags.ISF_RES_1 | InSimFlags.ISF_NLP | InSimFlags.ISF_HLV,

                Interval = 500
            });

            insim.Send(new[]
            {
                new IS_TINY {
                    SubT = TinyType.TINY_NCN, ReqI = 255
                },
                new IS_TINY {
                    SubT = TinyType.TINY_NPL, ReqI = 255
                },
                new IS_TINY {
                    SubT = TinyType.TINY_ISM, ReqI = 255
                },
                new IS_TINY {
                    SubT = TinyType.TINY_SST, ReqI = 255
                },
                new IS_TINY {
                    SubT = TinyType.TINY_MCI, ReqI = 255
                },
                new IS_TINY {
                    SubT = TinyType.TINY_NCI, ReqI = 255
                },
                new IS_TINY {
                    SubT = TinyType.TINY_AXI, ReqI = 255
                },
            });

            // insim.Send("/cars " + AVAILABLE_CARS);
            insim.Send(255, "^8InSim connected with version ^2" + InSim_Version);

            ConnectedToSQL = SqlInfo.StartUp(SQLIPAddress, SQLDatabase, SQLUsername, SQLPassword);
            if (!ConnectedToSQL)
            {
                insim.Send(255, "SQL connect attempt failed! Attempting to reconnect in ^310 ^8seconds!");
                SQLReconnectTimer.Start();
                SaveTimer.Start();
            }
            else
            {
                insim.Send(255, "^2Loaded userdata from database");
            }
        }
Beispiel #7
0
        private void button1_Click(object sender, EventArgs e)
        {
            joystick = new vGen();
            insim    = new InSim();

            insim.Initialized += (o, ec) =>
            {
                insim.Send(new IS_BTN()
                {
                    ReqI    = 5,
                    L       = 40,
                    T       = 20,
                    H       = 5,
                    W       = 40,
                    BStyle  = ButtonStyles.ISB_CLICK,
                    ClickID = 66,
                    Text    = "Control mode: 0",
                    UCID    = 0
                });

                foreach (var p in paths.paths)
                {
                    MSL("^3Path: ^7" + p.Name);
                }
                DrawClickables();
            };

            insim.Bind(PacketType.ISP_BTC, (ins, bb) =>
            {
                var bt = (IS_BTC)bb;
                if (bt.ClickID == 66)
                {
                    control = (control + 1) % 2;
                }
                else if (bt.ClickID == 67)
                {
                    initPhase = true;
                }
                else if (bt.ClickID >= PATH_CLICKID)
                {
                    var p       = paths.paths[bt.ClickID - PATH_CLICKID];
                    currentPath = p.Waypoints;
                    MSL("^7Selected path: ^3" + p.Name);
                    initPhase = true;
                }


                DrawClickables();
            });

            insim.Bind(PacketType.ISP_BTT, (ins, bb) =>
            {
                var bt = (IS_BTT)bb;

                if (bt.ClickID == 67)
                {
                    speedmod = int.Parse(bt.Text);
                    MSL("^3Speedmod set to ^7" + speedmod + "%");
                }

                DrawClickables();
            });

            insim.Initialize(new InSimSettings()
            {
                IName    = "^7Afto^1Piliet",
                Host     = "127.0.0.1",
                Port     = 29997,
                Interval = 100,
                Prefix   = '!',
                Flags    = InSimFlags.ISF_LOCAL
            });

            outsim           = new OutSim(10000);
            outsim.TimedOut += (a, b) => { insim.Send(new InSimDotNet.Packets.IS_MSL()
                {
                    Msg = "TimeOut..", ReqI = 10, Sound = MessageSound.SND_MESSAGE
                }); };
            outsim.PacketReceived += Outsim_PacketReceived;

            outsim.Connect("127.0.0.1", 30000);



            joystick.AcquireDev(1, DevType.vJoy, ref hDev);
            //joystick.SetDevAxis(hDev, 1, (float)100.0);
            //timer = new System.Timers.Timer(100);
            //timer.Elapsed += (o, ee) => {
            //    //joystick.SetDevAxis(hDev, 1, (float)DateTime.Now.Millisecond*0.1f);
            //    var cpos = Cursor.Position;

            //    joystick.SetDevAxis(hDev, 1, cpos.X / 19.2f);
            //    joystick.SetDevAxis(hDev, 2, cpos.Y / 10.8f);
            //};
            //timer.Start();
        }
Beispiel #8
0
        static void Main(string[] args)
        {
            StreamReader configReader = new StreamReader("config.cfg");

            string line = String.Empty;

            string username = "******", password = "******", channel = "channel";

            while ((line = configReader.ReadLine()) != null)
            {
                if (line.StartsWith("user"))
                {
                    username = line.Substring(line.IndexOf("=") + 1).Trim();
                }
                else if (line.StartsWith("pass"))
                {
                    password = line.Substring(line.IndexOf("=") + 1).Trim();
                }
                else if (line.StartsWith("channel"))
                {
                    channel = line.Substring(line.IndexOf("=") + 1).Trim();
                }
            }

            IrcClient client = new IrcClient("irc.twitch.tv", 6667, username, password, channel);

            InSim insim = new InSim();

            insim.Initialize(new InSimSettings
            {
                Host     = "127.0.0.1",
                Port     = 29999,
                Admin    = String.Empty,
                Flags    = InSimFlags.ISF_LOCAL,
                IName    = "Twitch Chat",
                Interval = 250
            });

            insim.Bind <IS_MSO>(InSimMessageHandler);

            while (true)
            {
                var message = client.ReadMessage();

                if (!message.StartsWith("PING"))
                {
                    var formattedMessage = message;
                    try { formattedMessage = message.Substring(1, message.IndexOf("!") - 1) + " : " + message.Substring(message.IndexOf(":", 1) + 1); } catch { }

                    Console.WriteLine($"{message}");

                    string[] tempArray = chatMessages;

                    tempArray[6] = tempArray[5];
                    tempArray[5] = tempArray[4];
                    tempArray[4] = tempArray[3];
                    tempArray[3] = tempArray[2];
                    tempArray[2] = tempArray[1];
                    tempArray[1] = tempArray[0];

                    tempArray[0] = formattedMessage;

                    for (int index = 0; index < tempArray.Length; index++)
                    {
                        insim.Send(new IS_BTN
                        {
                            ClickID = (byte)(index + 1),
                            ReqI    = 1,
                            BStyle  = ButtonStyles.ISB_DARK,
                            Text    = tempArray[index],
                            H       = 6,
                            L       = 0,
                            T       = (byte)(120 - index * 6),
                            W       = 50,
                            UCID    = 0
                        });
                    }

                    insim.Send(new IS_BTN
                    {
                        ClickID = 8,
                        ReqI    = 1,
                        Text    = "© gxszu.co.uk",
                        H       = 4,
                        L       = 0,
                        T       = 126,
                        W       = 10,
                        UCID    = 0,
                        BStyle  = ButtonStyles.ISB_LEFT | ButtonStyles.ISB_DARK
                    });

                    chatMessages = tempArray;
                }
            }
        }