Project 01: Hello GTA
In Project 00, you proved that your game could load and reload an existing DLL. Now it is time to write code yourself. In Project 01, you create your very first operational C# mod: detect when your script enters the world, intercept a dedicated keypress, trigger a smooth weather transition across the Los Santos skyline, and provide immediate feedback on screen.
The mission
Build and deploy your first custom C# mod to fulfill four core objectives:
- Define a managed script class inheriting from
GTA.Script. - Display a welcome subtitle banner exactly once when the mod initializes in game.
- Listen for keyboard input (NumPad 5) to trigger a progressive weather transition to clear skies.
- Post a mini-map notification ticker confirming that the transition is underway.
Specifications, constraints
- Target framework: Target .NET Framework 4.8 referencing
ScriptHookVDotNet3.dll. - Single execution guard: The introductory subtitle must appear once on startup and must not spam the screen every frame.
- Smooth visual interpolation: Use a progressive timed weather crossfade rather than an abrupt visual pop.
- Clean compilation: The assembly must build with zero errors and zero warnings.
Implementation steps
- Create the script class: In your IDE, create a public class inheriting from
GTA.Script. - Wire lifecycle events: In the constructor, attach event handlers to
Tick,KeyDown, andAborted. - Add the one-time welcome banner: In your
Tickhandler, use a private boolean flag (_introduced) to display the welcome subtitle on the first frame, then return early on all subsequent ticks. - Intercept keyboard input: In your
KeyDownhandler, evaluatee.KeyCodeto detect when the player pressesKeys.NumPad5. - Implement weather transition: In a private helper method, call the engine method that interpolates the current sky to clear weather over 10 seconds, then post a notification ticker.
- Deploy and verify: Compile the solution, place the resulting DLL into
Grand Theft Auto V/scripts, and pressInsertin game to test the result.
APIs, tools to explore
GTA.Script: Base class required for all managed ScriptHookVDotNet scripts.GTA.World.TransitionToWeather(Weather weather, float duration): Smoothly transitions the game weather over a specified duration in seconds.GTA.Weather.Clear: Enumeration value representing cloudless, sunny skies.GTA.UI.Screen.ShowSubtitle(string message, int duration): Renders a high-visibility text banner at the bottom center of the screen.GTA.UI.Notification.PostTicker(string message, bool isImportant): Displays a notification feed entry directly above the radar mini-map.System.Windows.Forms.Keys: Enumeration containing standard keycodes for keyboard events.
Validation checklist
Your mod is validated when:
- Visual Studio compiles your DLL with zero errors and zero warnings.
- Pressing
Insertin game reloads the scripts without exceptions inScriptHookVDotNet.log. - The subtitle "Hello GTA ! Your first mini-mod is loaded." appears once for 4 seconds upon load.
- Pressing
NumPad 5smoothly transitions the weather over 10 seconds without visual hitching. - A notification ticker appears above the mini-map confirming clear skies ahead.
Solution, explanations
Partner
Verified solution and code explanations
The mission, specifications, and guided steps remain 100% free and open for everyone. The complete verified reference code and production explanations are reserved for Partner members.