Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork630
Getting Started
Before you can start playing with ScriptHookVDotNet you need some prerequisites:
Note: seeUser Guides if you are not developing scripts for ScriptHookVDotNet(SHVDN).
- Download a pre-compiled set of binaries (.asi and .dll files) viathe main repository (stable versions) orthe nightly-release repository (nightly versions)
- Until the stable v3.7.0 is released, you will have to use install the nightly version
v3.6.0-nightly.89or later, or downgrade the game to v1.0.3179.0 or earlier.v3.6.0andv3.5.1havea compatibility issue with the game version v1.0.3258.0 and later game versions.
- Until the stable v3.7.0 is released, you will have to use install the nightly version
- Copy
ScriptHookVDotNet.asiandScriptHookVDotNet2/3.dllto your GTA V directory - Create a
scriptsfolder in your GTA V directory
Hint: ScriptHookVDotNet supports compiled assemblies as well as C# or VB source files placed in thescripts 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 likescript.3.cs as more features are available in the v3 API and it can have better performance. If the source file name is likescript.cs orscript.2.cs, the script will be executed using the v2 API.
- 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.
- Add a reference to astable version of SHVDN. You can also useour SHVDN3 nugget package 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).
Every mod/script you write must inherit from theGTA.Script class. This class provides 3 events:
TickKeyUpKeyDown
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.
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
scriptsfolder in your GTA V directory - Alt-tab back into the game
- Open the console by pressing
F4, enterReload()and hitEnter
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 yourscripts folder automatically.
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 pressingNumpad1.
Note:This script is using the SHVDN v3 API.
usingSystem;usingSystem.Drawing;usingSystem.Windows.Forms;usingGTA;publicclassCreateVehicle:Script{publicCreateVehicle(){Tick+=OnTick;KeyUp+=OnKeyUp;KeyDown+=OnKeyDown;}privatevoidOnTick(objectsender,EventArgse){}privatevoidOnKeyDown(objectsender,KeyEventArgse){}privatevoidOnKeyUp(objectsender,KeyEventArgse){if(e.KeyCode==Keys.NumPad1){Vehiclevehicle=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";}}}
Calling Native C++ Hash Functions
Now feel free to try out new things. There is so much powerful stuff to play with.