Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Runtime.InteropServices;
- using InSimDotNet;
- using InSimDotNet.Packets;
- using InSimDotNet.Helpers;
- using System.Collections.Generic;
- using System.Threading;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Example_Application
- {
- class Program
- {
- static void Main(string[] args)
- {
- var program = new Application();
- program.Start();
- }
- }
- class Application
- {
- // DECLARE ANY VARIABLES HERE
- InSim insim = new InSim(); // This is saying that we are declaring a new application and calling it just 'insim'
- public void Start()
- {
- // Bind packet events - These will have their own Methods (voids) further below in the application
- insim.Bind<IS_BTC>(ButtonClick);
- // Start the insim application and define the settings
- insim.Initialize(new InSimSettings
- {
- Host = "127.0.0.1", // Host where LFS is runing
- Port = 29999, // Port to connect to LFS through
- Admin = String.Empty, // Optional game admin password - obviously this is empty, you dont really need to use it
- Interval = 250, // Depends how quick you want stuff to update, ie how quick your speed button updates etc
- 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
- IName = "CSR Application",
- });
- // Confirm connection to LFS with a simple message to LFS itself and the console window
- insim.Send("/echo ^3This application has connected to LFS"); // Sending text to LFS
- Console.WriteLine("This application has connected to LFS"); // Sending text to the console window - Both are totally optional
- // Create buttons to send to local player
- // -----------------------------------------------------------------------------------------------------------------------------------------------------------------------
- // CONTAINER
- insim.Send(new IS_BTN { Text = "", L = 0, T = 126, W = 30, H = 70, ReqI = 1, ClickID = 1, UCID = 0, BStyle = ButtonStyles.ISB_DARK });
- // AUTHOR DETAILS
- insim.Send(new IS_BTN { Text = "^1[TC]", L = 0, T = 176, W = 16, H = 10, ReqI = 2, ClickID = 2, UCID = 0, });
- insim.Send(new IS_BTN { Text = "^7CityDriving", L = 0, T = 185, W = 16, H = 3, ReqI = 3, ClickID = 3, UCID = 0, });
- // RESET
- insim.Send(new IS_BTN { Text = "^2RESET", L = 16, T = 185, W = 12, H = 8, ReqI = 4, ClickID = 4, UCID = 0, BStyle = ButtonStyles.ISB_CLICK | ButtonStyles.ISB_LIGHT });
- // AT SCENE
- insim.Send(new IS_BTN { Text = "^3AT SCENE", L = 16, T = 175, W = 12, H = 8, ReqI = 5, ClickID = 5, UCID = 0, BStyle = ButtonStyles.ISB_CLICK | ButtonStyles.ISB_LIGHT });
- // 999
- insim.Send(new IS_BTN { Text = "^4999", L = 16, T = 165, W = 12, H = 8, ReqI = 6, ClickID = 6, UCID = 0, BStyle = ButtonStyles.ISB_CLICK | ButtonStyles.ISB_LIGHT });
- // SIREN
- insim.Send(new IS_BTN { Text = "SIREN", L = 2, T = 165, W = 12, H = 8, ReqI = 7, ClickID = 7, UCID = 0, BStyle = ButtonStyles.ISB_CLICK | ButtonStyles.ISB_LIGHT });
- // 360 BLUES
- insim.Send(new IS_BTN { Text = "360", L = 2, T = 129, W = 8, H = 5, ReqI = 8, ClickID = 8, UCID = 0, }); // TOP TEXT
- insim.Send(new IS_BTN { Text = "BLUES", L = 2, T = 134, W = 8, H = 5, ReqI = 9, ClickID = 9, UCID = 0, }); // BOTTOM TEXT
- insim.Send(new IS_BTN { Text = "", L = 2, T = 129, W = 8, H = 10, ReqI = 10, ClickID = 10, UCID = 0, BStyle = ButtonStyles.ISB_CLICK | ButtonStyles.ISB_LIGHT });
- // 360 LEDS
- insim.Send(new IS_BTN { Text = "360", L = 11, T = 129, W = 8, H = 5, ReqI = 11, ClickID = 11, UCID = 0, }); // TOP TEXT
- insim.Send(new IS_BTN { Text = "LEDS", L = 11, T = 134, W = 8, H = 5, ReqI = 12, ClickID = 12, UCID = 0, }); // BOTTOM TEXT
- insim.Send(new IS_BTN { Text = "", L = 11, T = 129, W = 8, H = 10, ReqI = 13, ClickID = 13, UCID = 0, BStyle = ButtonStyles.ISB_CLICK | ButtonStyles.ISB_LIGHT });
- // 360 REDS
- insim.Send(new IS_BTN { Text = "360", L = 20, T = 129, W = 8, H = 5, ReqI = 14, ClickID = 14, UCID = 0, }); // TOP TEXT
- insim.Send(new IS_BTN { Text = "REDS", L = 20, T = 134, W = 8, H = 5, ReqI = 15, ClickID = 15, UCID = 0, }); // BOTTOM TEXT
- insim.Send(new IS_BTN { Text = "", L = 20, T = 129, W = 8, H = 10, ReqI = 16, ClickID = 16, UCID = 0, BStyle = ButtonStyles.ISB_CLICK | ButtonStyles.ISB_LIGHT });
- // REAR REDS
- insim.Send(new IS_BTN { Text = "REAR", L = 20, T = 141, W = 8, H = 5, ReqI = 17, ClickID = 17, UCID = 0, }); // TOP TEXT
- insim.Send(new IS_BTN { Text = "REDS", L = 20, T = 146, W = 8, H = 5, ReqI = 18, ClickID = 18, UCID = 0, }); // BOTTOM TEXT
- insim.Send(new IS_BTN { Text = "", L = 20, T = 141, W = 8, H = 10, ReqI = 19, ClickID = 19, UCID = 0, BStyle = ButtonStyles.ISB_CLICK | ButtonStyles.ISB_LIGHT });
- // HEADLAMP FLASH
- insim.Send(new IS_BTN { Text = "H/L", L = 11, T = 141, W = 8, H = 5, ReqI = 20, ClickID = 20, UCID = 0, }); // TOP TEXT
- insim.Send(new IS_BTN { Text = "FLASH", L = 11, T = 146, W = 8, H = 5, ReqI = 21, ClickID = 21, UCID = 0, }); // BOTTOM TEXT
- insim.Send(new IS_BTN { Text = "", L = 11, T = 141, W = 8, H = 10, ReqI = 22, ClickID = 22, UCID = 0, BStyle = ButtonStyles.ISB_CLICK | ButtonStyles.ISB_LIGHT });
- // HEADLAMP AND REAR FLASH
- insim.Send(new IS_BTN { Text = "F/R", L = 2, T = 141, W = 8, H = 5, ReqI = 23, ClickID = 23, UCID = 0, }); // TOP TEXT
- insim.Send(new IS_BTN { Text = "FLASH", L = 2, T = 146, W = 8, H = 5, ReqI = 24, ClickID = 24, UCID = 0, }); // BOTTOM TEXT
- insim.Send(new IS_BTN { Text = "", L = 2, T = 141, W = 8, H = 10, ReqI = 25, ClickID = 25, UCID = 0, BStyle = ButtonStyles.ISB_CLICK | ButtonStyles.ISB_LIGHT });
- // BLANK
- insim.Send(new IS_BTN { Text = "", L = 2, T = 153, W = 8, H = 5, ReqI = 26, ClickID = 26, UCID = 0, }); // TOP TEXT
- insim.Send(new IS_BTN { Text = "", L = 2, T = 158, W = 8, H = 5, ReqI = 27, ClickID = 27, UCID = 0, }); // BOTTOM TEXT
- insim.Send(new IS_BTN { Text = "", L = 2, T = 153, W = 8, H = 10, ReqI = 28, ClickID = 28, UCID = 0, BStyle = ButtonStyles.ISB_CLICK | ButtonStyles.ISB_LIGHT });
- // REAR MATRIX
- insim.Send(new IS_BTN { Text = "REAR", L = 11, T = 153, W = 8, H = 5, ReqI = 29, ClickID = 29, UCID = 0, }); // TOP TEXT
- insim.Send(new IS_BTN { Text = "MATRIX", L = 11, T = 158, W = 8, H = 5, ReqI = 30, ClickID = 30, UCID = 0, }); // BOTTOM TEXT
- insim.Send(new IS_BTN { Text = "", L = 11, T = 153, W = 8, H = 10, ReqI = 31, ClickID = 31, UCID = 0, BStyle = ButtonStyles.ISB_CLICK | ButtonStyles.ISB_LIGHT });
- // BLANK
- insim.Send(new IS_BTN { Text = "", L = 20, T = 153, W = 8, H = 5, ReqI = 32, ClickID = 32, UCID = 0, }); // TOP TEXT
- insim.Send(new IS_BTN { Text = "", L = 20, T = 158, W = 8, H = 5, ReqI = 33, ClickID = 33, UCID = 0, }); // BOTTOM TEXT
- insim.Send(new IS_BTN { Text = "", L = 20, T = 153, W = 8, H = 10, ReqI = 34, ClickID = 34, UCID = 0, BStyle = ButtonStyles.ISB_CLICK | ButtonStyles.ISB_LIGHT });
- // Stop the application from loosing connection by adding a loop - This should be at the end of your first Starting void/method, so everything before it loads properly
- while (insim.IsConnected)
- {
- Thread.Sleep(200);
- }
- }
- public void ButtonClick(InSim insim, IS_BTC btc)
- {
- // Deal with button clicks here
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement