plugin-sdk

repository·master·Indexed 20 days ago

https://github.com/dk22pac/plugin-sdk

A development kit for creating plugins for Grand Theft Auto titles, including GTA2, GTA3, Vice City, San Andreas, and GTA:IV. The SDK provides tools for memory pattern scanning, custom decision-making logic for pedestrians, and rendering UI elements via DirectX. It includes examples for implementing vehicle spawners, GPS navigation, and input-driven game actions.

Tokens
3.3K
Snippets
12
Records
25
Agent score
70%

What's inside plugin-sdk

  1. Getting started with plugin-sdk

    master

    plugin-sdk is a development kit used to create plugins for the Grand Theft Auto series, specifically for GTA2, GTA3, GTA: Vice City, GTA: San Andreas, and GTA:IV.

    To begin developing with plugin-sdk, follow these high-level steps:

    1. Install a development environment (IDE): Set up your preferred C++ development environment.
    2. Set up plugin-sdk: Copy the SDK to your local machine and configure it for your project.
    3. Create your first plugin: Follow the project's workflow to initialize and build a new plugin.

    For detailed, step-by-step instructions on each phase, refer to the project's official Wiki guides.

  2. Use appropriate drawing methods for ASI plugins

    master

    When developing ASI plugins for GTA SA, GTA VC, or GTA 3, do not use the SDK's script draws related variables for general UI or rendering tasks. Instead, use established methods for drawing windows or text to ensure correctness and stability.

    Recommended methods:

    • Use CMenuManager::DrawWindow for drawing windows.
    • Use CFont::PrintString for printing strings/text.
  3. Fix compilation errors after v.1004 enum refactor

    master

    In version 1004, enum files were moved to a new enums\ directory. If you encounter compilation errors related to missing enums, you must update your project's include paths.

    Manual Fix: Go to Project properties > C++ > Additional Include Directories and add the new directory path following the pattern used for the rw directory, for example: $(PLUGIN_SDK_DIR)\Plugin_SA\game_sa\enums

    Automated Fix: You can regenerate your project with the correct configuration using the PSDK installer app.

  4. Use the TimeNotTouchingPadOpcode in SannyBuilder

    master

    The TimeNotTouchingPadOpcode is a custom opcode for the CLEO library (written with CLEO SDK) that retrieves the amount of time (in milliseconds) since the player last touched the controller pad. This opcode is specifically designed for GTASA.

    Opcode Signature: 1A00: %0@ = get_player %1@ time_not_touching_pad

    • %0@: The variable where the resulting time (in ms) is stored.
    • %1@: The player ID.
    {$CLEO}
    {$OPCODE 1A00=2,%2d% = get_player %1d% time_not_touching_pad}
    
    thread 'TimeTch'
    
    while true
        wait 0
        1A00: 0@ = get_player 0 time_not_touching_pad
        if
            0@ > 2000
        then
            0AD1: show_formatted_text_highpriority "You didn't touch the pad for %d ms" time 100 0@
        end
    end
  5. Create and assign a custom DecisionMaker

    master

    The DecisionMaker example demonstrates how to implement a custom decision-making logic for a pedestrian (ped) within the plugin SDK. This involves creating a class that inherits from the DecisionMaker base class and then assigning an instance of that class to a pedestrian object.

    // Shows how to create custom DecisionMaker and assign it to ped.
  6. Draw text using ID3DXFont in DXFont example

    master

    The DXFont example demonstrates how to render text in a DirectX environment using the ID3DXFont interface. This is a common pattern for displaying UI elements, debug information, or game text within a DirectX application.

    // Note: This is a conceptual representation of the ID3DXFont usage demonstrated in the example.
    // The actual implementation uses the ID3DXFont interface to draw text to the screen.
  7. Use the Ped Spawner example to browse ped models

    master

    The Ped Spawner is a showcase tool used to browse and spawn non-cutscene ped models. It allows you to cycle through available model IDs, including new models added via limit adjusters.

    Use the following keyboard controls to navigate the model list and spawn characters:

    <  : Find previous ped model ID and spawn it
    >  : Find next ped model ID and spawn it
    SHIFT: Hold to browse through models faster
  8. Use Full Nitrous Control keyboard shortcuts

    master

    The Full Nitrous Control example demonstrates how to implement nitro installation and removal using specific keyboard combinations. The control scheme uses the N key as a modifier combined with numeric or symbol keys to set the nitro multiplier or remove it entirely.

    #### Additional Controls (keyboard)
    * `N` + `1` - Install 1X nitro
    * `N` + `2` - Install 2X nitro
    * `N` + `3` - Install 3X nitro
    * `N` + `4` - Install 4X nitro
    * `N` + `5` - Install 5X nitro
    * `N` + `6` - Install 6X nitro
    * `N` + `7` - Install 7X nitro
    * `N` + `8` - Install 8X nitro
    * `N` + `9` - Install 9X nitro
    * `N` + `0` - Install 10X nitro
    * `N` + `-` - Remove nitro
    * `N` + `=` - Install infinite nitro
  9. Use pattern scanning to find and extract data

    master

    The hook::pattern utility allows you to search for specific byte sequences (patterns) within memory. Once a pattern is found, you can use the .get<T>(offset) method to extract data of a specific type (such as char, int, etc.) from the matched location.

    To ensure a pattern is valid before accessing it, use .count_hint(n) to check if at least n occurrences exist.

    #include "stdafx.h"
    #include <windows.h>
    #include "Hooking.Patterns.h"
    
    int main()
    {
        // Define a pattern as a hex string
        auto pattern = hook::pattern("54 68 69 73 20 70 72 6F 67 72");
        
        // Check if at least 1 occurrence is found
        if (!pattern.count_hint(1).empty())
        {
            // Get the first match (index 0) and extract the data as a char at offset 0
            auto text = pattern.get(0).get<char>(0);
            MessageBoxA(0, text, text, 0);
        }
        return 0;
    }