Advertisement
Guest User

Untitled

a guest
Apr 30th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.17 KB | None | 0 0
  1. using System;
  2. using System.Runtime.InteropServices;
  3. using InSimDotNet;
  4. using InSimDotNet.Packets;
  5. using InSimDotNet.Helpers;
  6. using System.Collections.Generic;
  7. using System.Threading;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11.  
  12. namespace Example_Application
  13. {
  14.     class Program
  15.     {
  16.         static void Main(string[] args)
  17.         {
  18.             var program = new Application();
  19.             program.Start();
  20.         }
  21.     }
  22.  
  23.     class Application
  24.     {
  25.         // DECLARE ANY VARIABLES HERE
  26.         InSim insim = new InSim(); // This is saying that we are declaring a new application and calling it just 'insim'
  27.  
  28.         public void Start()
  29.         {
  30.             // Bind packet events - These will have their own Methods (voids) further below in the application
  31.             // insim.Bind<IS_BTC>(ButtonClick);
  32.             // insim.Bind<IS_MCI>(MultiCarInfo);
  33.  
  34.             // Start the insim application and define the settings
  35.             insim.Initialize(new InSimSettings
  36.             {
  37.                 Host = "127.0.0.1", // Host where LFS is runing
  38.                 Port = 29999, // Port to connect to LFS through
  39.                 Admin = String.Empty, // Optional game admin password - obviously this is empty, you dont really need to use it
  40.                 Interval = 250, // Depends how quick you want stuff to update, ie how quick your speed button updates etc
  41.                 Flags = InSimFlags.ISF_LOCAL | InSimFlags.ISF_MCI, // This needs to be set. ISF_LOCAL stops interfering with server side insims, ISF_MCI gives you car update packets
  42.                 IName = "CSR Application",
  43.             });
  44.  
  45.             // Confirm connection to LFS with a simple message to LFS itself and the console window
  46.             insim.Send("/echo ^3This application has connected to LFS"); // Sending text to LFS
  47.             Console.WriteLine("This application has connected to LFS"); // Sending text to the console window - Both are totally optional
  48.  
  49.             // Stop the application from loosing connection by adding a loop
  50.             while(insim.IsConnected)
  51.             {
  52.                 Thread.Sleep(200);
  53.             }
  54.         }
  55.     }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement