Garage eXtender

Index

What is Garage eXtender

Garage eXtender (GRGX) is a plugin for GTA San Andreas that adds more options and more garage slots into the game.

San Andreas have 50 slots for garages, but those slots are already used by default, so no mapper can create custom garages for their maps, that's sad...
This plugin solves this and also add more possibilites into garage system, like parking garages (as in GTA IV), new door movement styles, more garage opcodes...

Feel free to use this plugin within your mods to be capable of adding more garages into the game, I suggest you to add a link in the readme file into the GTA Forums topic, the mediafire link or the gta garage link, so if I need to update this plugin sometime you're not distributing a old version. But that's your choice, what do you think about it? ;)


Usage

There's two ways to create a GRGX. The first one is using a IPL file and the second way is by script (SCM, CLEO...), I wanted to give both (mappers and scripters) the hability to create garages, but of course scripters will have a higher liberty to do whatever he wants to.

Let's talk about the two ways of creating a garage.

Creating a GRGX by IPL

The task to create a GRGX by IPL is extremely simple, it's almost like creating a normal garage but with additional parameters.

You should put the garage creation line inside a grge section (like a normal garage) and then we're done.
The difference from the regular garage line and the grgx line is that grgx have more params, let's compare:

Regular garage line:
x1, y1, z1, x2, y2, x3, y3, z3, flags, type, name

GRGX garage line:
x1, y1, z1, x2, y2, x3, y3, z3, flags, unused, name, num_cars, grgx_type, door_style

As you can see, we just added some additional params, in that way we detect if it is a regular garage or a grgx garage being readed from the IPL!
Right, now you should ask the meaning of those params, let me explain.

CounterIdentifierTypeDescription
1,2,3Position 1 (Pos1)float[3]The garage rear bottom right coordinates
4,5Position 2 (Depth)float[2]The garage front coordinates
6,7,8Position 3 (Pos2)float[3]The garage rear upper left coordinates
9Garage flagsintegerThe garage flags (see below)
10UnusedintegerThis value is unused. it was the regular garage type. Please use -1 here!
11Namechar[8]A string which is used to manipulate the behaviour of garages through a script.
The maximum number of characters for the garage name is 7!!!
12Num CarsintegerThe maximum number of cars that this garage can store.
Use -1 for unlimited number of vehicles.
This value is ignored if the garage can't store vehicles
13GRGX TypeintegerThe garage type. GRGX type is different from regular garage types, (see here)
14Door Style FlagsintegerDoor style flags. (see below)

Garage Flags

FlagDescription
1Door opens up and rotates (ignored by GRGX, see door style flags)
4Door goes in (ignored by GRGX, see door style flags)
8Camera follows player
As you can see, you are only able to use flag 8 within GRGX.

Door style flags

FlagDescription
1Door opens up
2Door rotates
4Door goes in
8Door opens slow
16Door opens to side
Sum the flags to get the flag you want. (e.g. 1+2+8 = 11)

Final notes
Click here to see a example of a garage created by IPL, the garage is at grove street!
Remember, the garage door only opens if it's really a garage door, see more here


Creating a GRGX by script

If you didn't read the Setting it up topic yet, read it first!!!

Creating garages by script is also very simple, it uses the method used by III\VC to create garages (CREATE_GARAGE).
Just put this line where you want to create the garage: (don't duplicate the garage, the garage must be created only once!)
0219: create_garage xyz1 2497.3 -1677.37 12.1 xy2 2497.3 -1670.07 xyz3 2504.08 -1677.37 16.3375 type GRGX_HIDEOUT_GARAGE name 'TEST'

Note 1: Remember to include grgx.txt!!!
Note 2: You can also use "CREATE_GARAGE" instead of "0219: create_garage"
Note 3: The garage name must have a maximum number of 7 characteres"

This garage is at grove street, remember: you need a door!
Of course the garage name must be different for each garage, 'TEST' is just a example!
If you're asking yourself what's that 3 coordinates, type and name, please take a look at the IPL params table, it will give you a good explanation, note that type is grgx_type and not a regular type!
Now, you must be asking, how to do those cool stuff, like change the way the door movement? See the next topic, Using the garage by script.

WARNING: If you're going to create garages in a CLEO Script, please look at the topic "WARNING FOR CLEO SCRIPTS"


Using the garage by script


Setting it up

Before anything, you should setup your sanny builder files to work within the new garage opcodes. Follow these steps:

  1. Open your Sanny Builder root folder, data folder and then sa folder (example: "C:\Program Files (x86)\Sanny Builder 3\data\sa")
  2. Open opcodes.txt file and add the following lines:

    0219: create_garage xyz1 2497.3 -1677.37 12.1 2497.3 xy2 -1670.07 2504.08 xyz3 -1677.37 16.3375 type GRGX_RESPRAY_GARAGE name 'TEST'
    021C: is_car_in_mission_garage 'TEST'
    02FA: grgx_command 'TEST' DESTROY_THIS_GARAGE
    0329: has_respray_happened_on_garage 'TEST'
    03BB: set_garage 'TEST' door_to_rotate
    03DA: set_garage 'TEST' camera_follows_player
    057A: set_garage 'TEST' max_cars_to 1


  3. Open sascm.ini file and add the following lines: (before insertting those lines check if any of the opcodes are already registered, if yes, remove it and then continue)

    0219=10,create_garage xyz1 %1d% %2d% %3d% xy2 %4d% %5d% xyz3 %6d% %7d% %8d% type %9d% name %10d%
    021c=1, is_car_in_mission_garage %1d%
    0329=1,has_respray_happened %1d%
    03bb=1,set_garage %1d% door_to_rotate
    03da=1, set_garage %1d% camera_follows_player
    057a=2,set_garage %1d% max_cars_to %2d%


  4. [OPTIONAL] Open keywords.txt and add the following lines:

    0219=CREATE_GARAGE
    021C=IS_CAR_IN_MISSION_GARAGE
    02FA=GRGX_COMMAND
    0329=HAS_RESPRAY_HAPPENED
    03BB=SET_GARAGE_DOOR_TO_ROTATE
    03DA=SET_GARAGE_CAMERA_FOLLOWS_PLAYER
    057A=SET_GARAGE_MAX_CARS


  5. Copy the file grgx.txt into the Sanny Builder\data\sa folder

    0219=CREATE_GARAGE
    021C=IS_CAR_IN_MISSION_GARAGE
    02FA=GRGX_COMMAND
    0329=HAS_RESPRAY_HAPPENED
    03BB=SET_GARAGE_DOOR_TO_ROTATE
    03DA=SET_GARAGE_CAMERA_FOLLOWS_PLAYER
    057A=SET_GARAGE_MAX_CARS


  6. You are done. Now whenever you use GRGX on your project, include the file grgx.txt by putting the following line at the top of the code:
    {$INCLUDE grgx.txt}


Garage Opcodes

With a script you can control during run-time a couple of garage aspects, like if the garage is activated, change the garage type and other stuffs.
We have new opcodes for garage management, opcodes removeds in SA but were in III\VC.

Here we are going to have a format like this: [OPCODE] COMMAND_NAME (params)

[0299] ACTIVATE_GARAGE (string)

This commands enables the garage, so the garage can open and close normally. By default the garage is activated.

[02B9] DEACTIVATE_GARAGE (string)

This commands disables the garage, so the garage can't open anymore. To enable the garage again use the above command
For parking garages this command disables the possibility to save the car in that area.

[02FA] CHANGE_GARAGE_TYPE (string, int)

This command changes the garage type, see the list of grgx garage types
Doesn't work with parking garages created by IPL!

[0360] OPEN_GARAGE (string)

Opens the garage door

[0361] CLOSE_GARAGE (string)

Closes the garage door

[03B0] IS_GARAGE_OPEN (string)

Checks if the garage door is open

[03B1] IS_GARAGE_CLOSED (string)

Checks if the garage door is closed

[021B] SET_TARGET_CAR_FOR_MISSION_GARAGE (string, int)

Sets the garage to accept only the specified vehicle. Send -1 instead of the vehicle handle to unregister the target car.
Note that GRGX only supports one garage with the ability to have a target car, see the list of grgx garage types.


The following opcodes are grgx specific, caught from III\VC

[021C] IS_CAR_IN_MISSION_GARAGE (string)

Checks if the target car (set with 021B) is inside the garage.

[02FA] GRGX_COMMAND (string, int)

Sends a command to a grgx garage. See a list of grgx commands here
. Note that this is the same as [02FA] CHANGE_GARAGE_TYPE, but behaves different because the value sent is a command constant and not a garage type.

[0329] HAS_RESPRAY_HAPPENED_ON_GARAGE (string)

Checks if the player has painted it's car on this garage.

[03BB] SET_GARAGE_DOOR_TO_ROTATE (string)

Makes the garage door to opens up and rotate.
This is the same as sending the grgx commands GARAGE_STYLE_OPENS_UP and GARAGE_STYLE_ROTATE

[03DA] SET_GARAGE_CAMERA_FOLLOWS_PLAYER (string)

Makes the camera to follows the player when inside the garage

[057A] SET_GARAGE_MAX_CARS_TO (string, int)

Sets the maximum number of cars that the garage can store. Use -1 for unlimited number of cars.
Has no effect for garages that can't store vehicles

[0219] CREATE_GARAGE

See here


GRGX Commands

The following commands can be used with 02FA to change the behaviour of the garage or do something:

IdentifierDescription
DESTROY_THIS_GARAGERemoves the garage from the game.
IS_GARAGE_CREATED_BY_SCRIPTChecks if the garage has been created by a script
DOES_THIS_GARAGE_CAN_STORE_VEHICLESChecks if the garage can store vehicles
IS_PLAYER_ENTIRELY_INSIDE_GARAGEChecks if the player ie ntirely inside the garage
IS_ANY_CAR_BLOCKING_GARAGE_DOORChecks if there's any car blocking the garage door
REMOVE_CARS_BLOCKING_GARAGE_DOOR_NOT_INSIDERemoves any car blocking the garage door
GARAGE_PUSH_OUT_VEHICLESPush out all vehicles trying to enter the garage
GARAGE_PUSH_OUT_VEHICLES_BUT_NOT_TARGETPush out all vehicles trying to enter the garage, but not the target.
IS_NOT_ANYTHING_TOUCHING_GARAGEChecks if nothing is touching the garage
IS_ANY_CAR_TOUCHING_GARAGEChecks if there's any car touching the garage
IS_ANY_PED_TOUCHING_GARAGEChecks if there's any ped touching the garage
IS_ANY_CAR_TOUCHING_GARAGE_BUT_NOT_TARGETChecks if there's any car touching the garage, but not the target
IS_ANY_PED_TOUCHING_GARAGE_BUT_NOT_PLAYERChecks if there's any ped touching the garage, but not the player
IS_STATIC_PLAYER_CAR_ENTIRELY_INSIDE_GARAGEChecks if the player car is inside the garage
IS_GARAGE_A_HIDEOUTChecks if the garage is a hideout (e.g. a save garage)
CLEAR_STORED_CARS_IN_THIS_GARAGEClear all cars stored in this garage
TIDY_UP_GARAGE
TIDY_UP_GARAGE_CLOSE
GARAGE_STYLE_OPENS_UPMakes the garage door to open up
GARAGE_STYLE_ROTATEMakes the garage door to rotate
GARAGE_STYLE_GOES_INMakes the garage door to go in
GARAGE_STYLE_OPENS_SLOWMakes the garage door to open slow
GARAGE_STYLE_OPENS_TOSIDEMakes the garage door to open to side
DOES_GARAGE_EXISTSChecks if the garage exist
SET_GARAGE_DEPPENDS_ON_THIS_THREADMakes the garage deppends on the script that sent this command!
If the script that called this doesn't exist anymore, the garage will be destroyed. Works after a load game too!
The script must have a fixed name (set with 03A4)
SET_GARAGE_DONT_SAVEThe garage won't be saved in a save-game

Note that you can use the rule of the not flag to not a command, e.g. if you use GARAGE_STYLE_OPENS_UP without the not flag the garage is going to open up, if you use with the not flag the garage is NOT going to open up, but open down.

Examples:
82FA: grgx_command 'TEST' GARAGE_STYLE_OPENS_UP // The garage door will NOT open up (will open down), see the NOT (8 instead of 0 in the front of the opcode).
02FA: grgx_command 'TEST' GARAGE_STYLE_ROTATE // The garage door will rotate
02FA: grgx_command 'TEST' GARAGE_PUSH_OUT_VEHICLES // Will push out any vehicle trying to enter the garage (must be in a loop to work properly)


Warning for CLEO scripts

After a garage is created by a script, it is saved in a save game and all that stuff, like a create_object. So we came into a problem:
What if the user deletes your script? The garage will be lost in the save-game!!!
But we can solve this easilly by using SET_GARAGE_DEPPENDS_ON_THIS_THREAD or even SET_GARAGE_DONT_SAVE

We have another warning related with the scripter logic, when the user loads the game your script is restarted from the beggining (not if you use 0A95!), so if you came to the begging of your script again, make sure you are not going to duplicate (create again) the garage. Use 0A95 or DOES_GARAGE_EXISTS before creating the garage.


GRGX Garage Types

Here is a table showing the GRGX garage types, you should use the constant name if using in a script or the id if using in a IPL.

IDNameDescription
0GRGX_NULL_GARAGEThis garage does nothing
1GRGX_SCRIPT_GARAGEScript controlled garage, the script should open and close it.
3GRGX_HIDEOUT_GARAGENormal Save Garage
4GRGX_PARKING_GARAGEPark Save Garage
5GRGX_IMPOUND_GARAGEImpound Lot, not working very well
6GRGX_RESPRAY_GARAGEPay n' spray garage
7GRGX_BOMBSHOP1_GARAGEBomb shop with timed detonator
8GRGX_BOMBSHOP2_GARAGEBomb shop with engine ignition detonation
9GRGX_BOMBSHOP3_GARAGEBomb shop with remote-control detonator
10GRGX_BURGALY_GARAGEBurgaly. Must be opened by a script and is closed automatically.
11GRGX_WHEEL_ARCH_ANGELOnly accepts vehicles with STREET_RACER flag
12GRGX_LOCO_LOW_COOnly accepts vehicles with LOW_RIDER flag
13GRGX_TRANSFENDERAccepts vehicles that aren't STREET_RACER neither LOW_RIDER
14GRGX_ANYCAR_TUNNING_SHOPAccepts every car
15GRGX_OPENCLOSE_GARAGEThis garage does nothing but only opens and closes.
This is the only garage on GRGX that accepts a target car, if a target car is set (using 021B) the garage will only open for the target car.


Garage Door Note

Notes taken from: http://www.gtamodding.com/index.php?title=GRGE


Save Files

Garage eXtender doesn't store their garages on the default San Andreas save files, there's many reason behid it but the main one is to not corrupt the save file.
The save files for grgx are stored in "GTA San Andreas User Files/grgx/%d.sav", where %d is the save slot.


Credits and Contact

This plugin was created by LINK/2012 <dma_2012@hotmail.com>
Visit also Brazillian Modding Studio

Please report if you find any bug!!

Thanks :)