Before you can start playing with ScriptHookVDotNet you need some prerequisites: * GTA V * [ScriptHookV](http://www.dev-c.com/gtav/scripthookv/) * [ScriptHookVDotNet SDK](https://github.com/scripthookvdotnet/scripthookvdotnet/releases) # How to install ScriptHookVDotNet to your game Note: see [[User Guides]] if you are not developing scripts for ScriptHookVDotNet(SHVDN). 1. Download a pre-compiled set of binaries (.asi and .dll files) via [the main repository (stable versions)](https://github.com/scripthookvdotnet/scripthookvdotnet-nightly/releases) or [the nightly-release repository (nightly versions)](https://github.com/scripthookvdotnet/scripthookvdotnet-nightly/releases) - Until the stable v3.7.0 is released, you will have to use install the nightly version `v3.6.0-nightly.89` or later, or downgrade the game to v1.0.3179.0 or earlier. `v3.6.0` and `v3.5.1` have [a compatibility issue with the game version v1.0.3258.0 and later game versions](https://github.com/scripthookvdotnet/scripthookvdotnet/issues/1451). 2. Copy `ScriptHookVDotNet.asi` and `ScriptHookVDotNet2/3.dll` to your GTA V directory 3. Create a `scripts` folder in your GTA V directory **Hint**: ScriptHookVDotNet supports compiled assemblies as well as C# or VB source files placed in the `scripts` folder in your GTA V directory. If you plan to create new source scripts, you should specify the latest scripting API version by naming the file like `script.3.cs` as more features are available in the v3 API and it can have better performance. If the source file name is like `script.cs` or `script.2.cs`, the script will be executed using the v2 API. # How to Create a Script Project for ScriptHookVDotNet (using Visual Studio) 1. Create a new project with "Class Library **(.NET Framework)**" in Visual C# tab - You cannot create scripts using "Class Library", as such variant is for .NET 5+ and .NET Core, which SHVDN does not support. 2. Add a reference to a **stable** version of SHVDN. You can also use [our SHVDN3 nugget package](https://www.nuget.org/packages/scripthookvdotnet3) to add one, as well as manually adding a refecence to a local binary of ScriptHookVDotNet3.dll. - Do not use a nightly version to compile scripts against unless you are testing nightly-only features, because the compatibities of them are not guaranteed. We do not offer compatibility support for nightly-only features (suggestions to improve design or bug reports are still welcomed for them). # Basic Knowledge Every mod/script you write must inherit from the `GTA.Script` class. This class provides 3 events: * `Tick` * `KeyUp` * `KeyDown` Those 3 events provides the basic work area you can then work with. **Important note**: you should build your scripts against a stable version unless you want to test nightly features that are not in any stable versions (e.g. to give the developer(s) of SHVDN feedback). The SHVDN dev(s) can change some of them so that the binary compatibilities won't be kept without publishing (loud) notice. # Speeding up Development To avoid needing to constantly exit and launch GTA V, you can reload scripts within ScriptHookVDotNet. * Start GTA * Test out your scripts * Alt-tab back to your development environment (Visual Studio) * Make some changes * Build the script again * Copy the DLL file into the `scripts` folder in your GTA V directory * Alt-tab back into the game * Open the console by pressing `F4`, enter `Reload()` and hit `Enter` **Note**: _This also works with .cs or .vb source files_ You may also want to set up a post build event in Visual Studio to copy the compiled DLL to your `scripts` folder automatically. # Code Example Below you can find a basic example mod that creates a vehicle in front of the own character with a 90° heading to the character when pressing **Numpad1**. **Note**: _This script is using the SHVDN v3 API._ ```cs using System; using System.Drawing; using System.Windows.Forms; using GTA; public class CreateVehicle : Script { public CreateVehicle() { Tick += OnTick; KeyUp += OnKeyUp; KeyDown += OnKeyDown; } private void OnTick(object sender, EventArgs e) { } private void OnKeyDown(object sender, KeyEventArgs e) { } private void OnKeyUp(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.NumPad1) { Vehicle vehicle = World.CreateVehicle(VehicleHash.Zentorno, Game.Player.Character.Position + Game.Player.Character.ForwardVector * 3.0f, Game.Player.Character.Heading + 90); vehicle.CanTiresBurst = false; vehicle.Mods.CustomPrimaryColor = Color.FromArgb(38, 38, 38); vehicle.Mods.CustomSecondaryColor = Color.DarkOrange; vehicle.PlaceOnGround(); vehicle.Mods.LicensePlate = "SHVDN"; } } } ``` # Further Reading [Code Snippets](https://github.com/crosire/scripthookvdotnet/wiki/Code-Snippets) [How-To Guides](https://github.com/crosire/scripthookvdotnet/wiki/How-Tos) [Calling Native C++ Hash Functions](https://github.com/crosire/scripthookvdotnet/wiki/How-Tos#calling-native-functions) *** Now feel free to try out new things. There is so much powerful stuff to play with.