Sanny Builder
Search…
Classes
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 parameters
1
Player.SetMinWantedLevel($PLAYER_CHAR, 2)
Copied!
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 conditional expressions:
1
if
2
Player.Defined($PLAYER_CHAR)
3
jf @anywhere
Copied!

Methods

Methods are regular commands used to complete a single in-game action, e.g. moving an object, destroying a vehicle, etc.:
1
Object.PutAt($crate, 10.0, -25.5, 12.2)
2
Car.Destroy($car)
Copied!
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:
1
Player.Create($PLAYER_CHAR, #NULL, 2488.5601, -1666.84, 13.38)
2
Copied!
1
$PLAYER_CHAR = Player.Create(#NULL, 2488.5601, -1666.84, 13.38)
Copied!

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:
1
Player($PLAYER_CHAR).Money += 1000000 // add more money
2
Player($PLAYER_CHAR).Money > [email protected] // check the amount
3
[email protected] = Player($PLAYER_CHAR).Money // read the amount and store in variable
Copied!
In the current version the compiler ignores whitespace characters in string literals used in property parameters:
1
[email protected] = File.Open("file name","wb")
Copied!
will be compiled as:
1
[email protected] = File.Open("filename","wb")
Copied!

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:
1
Player.Build($PLAYER_CHAR)
Copied!
$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:
1
Camera.SetBehindPlayer()
Copied!

Declaring a class instance

Variables can be declared using a class name as the type:
1
var
2
$PLAYER_CHAR: Player
3
end
Copied!
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:
1
if
2
$PLAYER_CHAR.Defined
3
jf @anywhere
Copied!
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:
1
$PLAYER_CHAR.SetClothes("PLAYER_FACE", "HEAD", Head)
Copied!
is equivalent to:
1
Player.SetClothes($PLAYER_CHAR, "PLAYER_FACE", "HEAD", Head)
Copied!
Variables declared as instances of a class can be redeclared with another type.

The Model Class

Model names are always instances of the Model class:
1
#AK47.Load
2
3
:loop
4
wait 0
5
if
6
#AK47.Available
7
jf @loop
Copied!
It is equivalent to:
1
Model.Load(#AK47)
2
3
:loop
4
wait 0
5
if
6
Model.Available(#AK47)
7
jf @loop
Copied!

Class constants

Class parameters can be assigned to an enumerated type. It makes the source code more readable:
1
Player.SetClothes($PLAYER_CHAR, "VEST", "VEST", BodyPart.Torso)
Copied!
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.
Last modified 1yr ago