Installing and settings

Installing

Installation as such is not required. You only need to create any project in Visual Studio with C# support. For this example, I'll create a regular console application. The name can be absolutely anything. Please note that the project must use the .Net Framework template:

Next, add a link to the library using the References-> Add reference menu:

After that, click on the Browse button and specify the path to GTA.III.dll, GTA.VC.dll, GTA.SA.dll, GTA.III.CLEO.dll, GTA.VC.CLEO.dll or GTA.SA.CLEO.dll.

Then click OK in the References Manager window:

Settings

After successfully completing these steps, you can start writing code. Let's open the created project and set up the generator in the Main method:

using GTA.Core; // hook up the generator namespace
using System; // only needed to access the standard "Console" class
namespace demo_app {
class Program {
static void Main( string[] args ) {
Console.ReadKey(); // set a console delay to allow the generator to finish working
}
}
}

Now we are interested in how to start the generator. We need to create a class called MAIN (CTRL + ALT + C or via the menu). First, let's include the namespaces that are needed to generate the script:

using GTA; // we connect data types and commands that are used in GTA. They depend on the selected library
public partial class MAIN : Thread { // use "partial" is desirable
public override void START( LabelJump label ) { // this method is the starting point of the script
}
}

The MAIN class must inherit from the Thread class. This class contains functions that have the same names as the opcodes in Sanny Builder.

Since the START method is abstract, we need to write it manually or using the Visual Studio hints (position the cursor on the class name and wait until the button with the lightbulb menu appears Implement abstract class):

Now we go back to the console project and run the generator by specifying the class (which we created earlier) between the symbols < and >:

using GTA.Core;
using System;
namespace demo_app {
class Program {
static void Main( string[] args ) {
Generator.Start<MAIN>( true ); // start the generator!
Console.ReadKey();
}
}
}

In the method to start the generator, I used the parameter true, which, after generating the code, will open the result in a text editor. This parameter is optional. If the file does not need to be opened, specify false. In CLEO mode this parameter is always ignored!

Compiling scripts

The generator does not know how to compile scripts on its own, but there is support for using the Sanny Builder compiler. To do this, instead of the Generator.Start method, use the Generator.Compile function:

namespace demo_app {
class Program {
static void Main( string[] args ) {
// Where to save FXT files?
Generator.SetFXTFolder( @"D:\Programm\GTA_SA Career v2.0\modloader\wmysterio\cleo\cleo_text" );
// Where to save SCM and IMG files?
Generator.SetMainSCMFolder( @"D:\Programm\GTA_SA Career v2.0\modloader\wmysterio\data\script" );
// For CLEO, you must use the path to the game!
//Generator.SetGTAFolder( @"D:\Programm\GTA_SA" );
// Path to "sanny.exe"
Generator.SetSannyBuidlerFolder( @"D:\Programm\Sanny Builder 3" );
Generator.Compile<MAIN>( false );
Console.ReadKey();
}
}
}

Before compiling, you need to specify the paths where the generated files will be moved. Everything else will be done automatically. The Compile method accepts an optional parameter that will open Sanny Builder after compilation. In CLEO mode, the SetMainSCMFolder method is not used. Instead, you need to specify the path to the game through the SetGTAFolder method.

Settings for Sanny Builder

The generator only works with Sanny Builder version 3.5.1! To avoid possible conflicts, we need to configure Sanny Builder itself and make sure that everything is ready to run it. In the formatting settings, set the value As is:

The preparation for creating the first script is complete!