Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Getting Started

kagikn edited this pageJan 7, 2025 ·28 revisions

Before you can start playing with ScriptHookVDotNet you need some prerequisites:

How to install ScriptHookVDotNet to your game

Note: seeUser Guides if you are not developing scripts for ScriptHookVDotNet(SHVDN).

  1. Download a pre-compiled set of binaries (.asi and .dll files) viathe main repository (stable versions) orthe nightly-release repository (nightly versions)
  2. CopyScriptHookVDotNet.asi andScriptHookVDotNet2/3.dll to your GTA V directory
  3. Create ascripts folder 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.

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 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).

Basic Knowledge

Every mod/script you write must inherit from theGTA.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 thescripts folder in your GTA V directory
  • Alt-tab back into the game
  • Open the console by pressingF4, 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.

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 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";}}}

Further Reading

Code Snippets

How-To Guides

Calling Native C++ Hash Functions


Now feel free to try out new things. There is so much powerful stuff to play with.

Clone this wiki locally

[8]ページ先頭

©2009-2025 Movatter.jp