Sanny Builder
In English
In English
  • Introduction
  • Credits
  • Version History
  • Language
    • Data Types
      • Constants
      • Variables
      • Arrays
    • Instructions
      • Opcodes
      • Keywords
      • Classes
      • Expressions
      • Built-in Commands
      • HEX..END
    • Control Flow
      • Labels
      • Conditions
      • Loops
      • Switch
    • Functions
    • Import/Export
    • Directives
    • Comments
  • Edit Modes
    • CustomLabels.ini
    • Code Templates
    • Enums.txt
    • Extensions
    • Opcodes List (SCM.INI)
  • Editor
    • Features
    • Options
      • General
      • Formats
      • Editor
      • Theme Editor
      • Hotkeys
      • Debugger
      • Edit modes
    • Console
    • Hotkeys
    • Opcode Search Tool
    • Command Line Interface
    • Language Service
    • SCM Debugger
  • SCM Documentation
    • GTA Limits
    • GTA III
      • Ped Types
      • Radar Icons
    • Vice City
      • Button IDs
      • Gang IDs
      • Garage IDs
      • Interiors
      • Ped Types
      • Radar Icons
      • Weapon IDs
    • San Andreas
      • Button IDs
      • Gang IDs
      • Garage IDs
      • Haircuts
      • Interiors
      • Particle Effects
      • Ped Types
      • Player Clothes
      • Player Body Parts
      • Special Actors
      • Statistics ID
      • Tattoos
      • Train Types
      • Vehicle Variations
      • Weapon IDs
      • Weather IDs
      • Zones
    • Liberty City Stories
      • Gang IDs
      • Model IDs
      • Player Clothes
      • Special Actors
      • Weapon IDs
      • Weather IDs
    • Vice City Stories
      • Gang IDs
      • Player Clothes
      • Weather IDs
  • Troubleshooting
    • Error Messages
      • 0001: INI file not found
      • 0002: Unknown array type
      • 0003: Error reading script.img
      • 0004: Unknown parameter type
      • 0005: Invalid edit mode
      • 0006: Unknown file header
      • 0007: File not found
      • 0008: Error reading opcodes list
      • 0009: Opcodes list not found
      • 0010: Unknown opcode
      • 0011: Unknown opcode
      • 0012: Incorrect jump instruction
      • 0013: Unknown directive
      • 0014: Incorrect expression
      • 0016: Script not found
      • 0017: Unknown type of variable
      • 0018: Invalid array size
      • 0019: Unknown array type
      • 0020: Variable is not declared as array
      • 0021: Incorrect variable name
      • 0022: Loop counter is not a variable
      • 0023: Unexpected instruction
      • 0024: Error reading integer number
      • 0025: Incorrect counter range
      • 0026: Error reading floating-point number
      • 0027: String is too long
      • 0028: Unterminated string
      • 0029: Invalid debug script ID
      • 0031: Invalid total number of elements
      • 0032: Invalid value in the header
      • 0033: Invalid local variable name
      • 0034: Local variable is out of range
      • 0035: Expected word
      • 0036: Local mission variable is out of range
      • 0037: Debug script not found
      • 0038: Unknown type of array
      • 0039: Invalid element definition
      • 0040: Constant name or value not found
      • 0041: Invalid mission id
      • 0042: Duplicate external script name
      • 0043: Invalid array index
      • 0044: Invalid array name
      • 0045: Invalid array syntax: variable name is missing
      • 0046: Invalid array syntax
      • 0047: Invalid array size
      • 0048: Error reading array size
      • 0049: Not enough parameters for opcode
      • 0050: Not enough parameters for command
      • 0051: Error writing script.img header
      • 0052: Error writing script.img
      • 0053: Recursive include
      • 0054: Label not found
      • 0055: Identifier not found
      • 0056: Label redeclared
      • 0057: Internal label not found
      • 0058: Invalid parameter
      • 0059: Invalid opcode definition
      • 0060: No input file
      • 0061: Empty source
      • 0062: IDE file not found
      • 0063: Mission label expected
      • 0064: Mission label not found
      • 0065: External script label not found
      • 0067: Forbidden character in external script name
      • 0068: Forbidden character in identifier
      • 0069: Forbidden character in object name
      • 0071: Incorrect number of conditions
      • 0072: Missing logical operator
      • 0073: Redundant logical operator
      • 0074: Disabled option
      • 0075: Incorrect hexadecimal value
      • 0076: Condition expected
      • 0079: Invalid parameter in Alloc command
      • 0080: Non-negative integer number expected
      • 0081: Too many actual parameters
      • 0082: Invalid syntax
      • 0083: Unknown model ID
      • 0084: Jump to offset 0
      • 0086: Invalid array index
      • 0087: Invalid variable
      • 0088: Global variable is out of range
      • 0089: Opcode not found
      • 0090: Duplicate constant
      • 0091: Not enough memory to allocate a local variable
      • 0092: Incorrect export symbol
      • 0093: Only headless scripts can export code
      • 0094: Duplicate export name
      • 0095: Incorrect import name
      • 0096: Incorrect import path
      • 0097: Too many actual parameters
      • 0098: Unknown operator
      • 0099: Left-hand side of the assignment must be a variable
      • 0100: Invalid operator
      • 0101: Variable is not a class instance
      • 0102: Switch statement needs a variable
      • 0103: Expected a switch case
      • 0104: Expected a value for the switch case
      • 0105: Expected a function argument name
      • 0106: Expected a function argument type
      • 0107: Expected function return type
      • 0108: Unsupported argument type
      • 0109: Expected variables to store function result
      • 0110: Function must return N values
      • 0111: Function not found in current scope
      • 0113: Duplicate function declaration
      • 0115: Invalid variable name. Name is reserved by another class or function
      • 0116: Invalid variable name
      • 0117: Invalid function name
      • 0118: Unexpected value to return
      • 0119: Unsupported type of argument
      • 0120: Expected calling convention type
      • 0121: Expected function's static address
      • 0122: A non-static function can't be called by name
      • 0123: A 'thiscall' function requires a pointer
      • 0124: Foreign functions can't return more than one value
      • 0125: Unexpected return type in function
      • 0126: Can't export a foreign function definition
      • 0127: Unexpected mission label in function
Powered by GitBook
On this page
  • General Syntax
  • Conditions
  • Methods
  • Properties
  • Class Instances
  • Declaring a class instance
  • The Model Class
  • Class constants
  1. Language
  2. Instructions

Classes

PreviousKeywordsNextExpressions

Last updated 1 year ago

A class is a group of commands applied to the in-game entities: player, peds, objects, etc. For example, the Player class groups the commands performed over the player character.

General Syntax

Syntax: <Class name>.<Class member>(parameters)

Class name - the name of a group of commands defined in the classes.db file for this edit mode Class member - one of the commands included in the class Parameters - 0 or more comma-delimited

Player.SetMinWantedLevel($PLAYER_CHAR, 2)

Player - class name SetMinWantedLevel - class member $PLAYER_CHAR, 2 - two parameters for SetMinWantedLevel

There are three types of class members:

  • conditions

  • methods

  • properties

Conditions

The list that appears when you press Ctrl+Space marks conditional commands with the word Check. They are used in :

if
    Player.Defined($PLAYER_CHAR)
jf @anywhere

Methods

Methods are regular commands used to complete a single in-game action, e.g. moving an object, destroying a vehicle, etc.:

Object.PutAt($crate, 10.0, -25.5, 12.2)
Car.Destroy($car)

They are marked with the work proc in the list of class members.

A special kind of methods is a constructor. A constructor creates a new instance of a class and stores its handle to a variable.

In Sanny Builder the constructor can be written in two equivalent ways:

Player.Create($PLAYER_CHAR, #NULL, 2488.5601, -1666.84, 13.38)
$PLAYER_CHAR = Player.Create(#NULL, 2488.5601, -1666.84, 13.38)

Properties

Property allows you to access class attributes and/or modify them.

For example, the .Money property of the Player class allows to operate with the amount of money of the player:

Player($PLAYER_CHAR).Money += 1000000 // add more money
Player($PLAYER_CHAR).Money > 461@ // check the amount
4@ = Player($PLAYER_CHAR).Money // read the amount and store in variable
0@ = File.Open("file name","wb")

will be compiled as:

0@ = File.Open("filename","wb")

Class Instances

Almost all class members take a variable as the first parameter. This variable holds a handle of the class instance which is a concrete in-game entity the command is applied to:

Player.Build($PLAYER_CHAR)

$PLAYER_CHAR - the class instance.

For some in-game entities there is only one instance to exist. An example of that would be the camera that controls what the player can see. The members of classes for such entities do not require a variable with the class instance:

Camera.SetBehindPlayer()

Declaring a class instance

var
    $PLAYER_CHAR: Player
end

It instructs the compiler that $PLAYER_CHAR holds an instance of the class Player. This variable can serve as an alias to the class name:

if
    $PLAYER_CHAR.Defined
jf @anywhere

If a variable substitutes a class name, the compiler also makes it the first parameter, hence no need to use it again in the list of parameters:

$PLAYER_CHAR.SetClothes("PLAYER_FACE", "HEAD", Head)

is equivalent to:

Player.SetClothes($PLAYER_CHAR, "PLAYER_FACE", "HEAD", Head)

Variables declared as instances of a class can be redeclared with another type.

The Model Class

#AK47.Load
  
:loop
wait 0
if
  #AK47.Available
jf @loop

It is equivalent to:

Model.Load(#AK47)

:loop
wait 0
if
    Model.Available(#AK47)
jf @loop

Class constants

Player.SetClothes($PLAYER_CHAR, "VEST", "VEST", BodyPart.Torso)

The last parameter (BodyPart.Torso) is a member of the BodyPart enum substituted with 0 during compilation. The enums and values are defined in the enums.txt file.

Extended parameters (deprecated)

Sanny Builder prior to v3.6 defined special constants for class members in the file classes.db . These parameters were called extended. This solution only allowed for one extended parameter per class member.

Since v3.6 class members use enum names as their types and may have any number of enumerated parameters.

For backward compatibility Sanny Builder still supports old extended parameters during compilation. classes.db keeps them under the DEPRECATED_ENUMS section.

In the current version the compiler ignores whitespace characters in used in property parameters:

Variables can be using a class name as the type:

are always instances of the Model class:

Class parameters can be assigned to an . It makes the source code more readable:

parameters
conditional expressions
enumerated type
declared
string literals
Model names