# Gang Garages

The resource offers built-in garage system for gang-members to use or you can use your own garage system.

## Configuration

1. Navigate to `t1ger_gangsystem/config.lua`.
2. Find the table/option called `GangMarkers`.
3. Go through and set the config options to your preferences (read the end-line text comments).&#x20;
4. Set `useBuiltInGarage = true` if you want to use the built in system or set to `false` and use your own garage system.

## Built In Garage

{% hint style="danger" %}
If you do not have any experience with FiveM/LUA coding, please do not engage in this. Seek help from experienced developers.
{% endhint %}

The built-in-garage is a very basic garage system that allows:

* Getting all player owned vehicles and spawn the selected one.
* Store the current vehicle player is using.

### &#x20;Get Player Vehicles

You may find it necessary to customize the built-in garage to fetch vehicles based on a few criteria such as stored/parked state and so on.&#x20;

1. Navigate to `t1ger_gangsystem/client/main.lua`.
2. Find the event named:&#x20;

   ```lua
   'gangsystem:client:getPlayerVehicles'
   ```
3. These are the keys you can use ***(make sure you have updated t1ger-lib with correct values for those keys. See*** [#player-owned-vehicles](https://docs.t1ger.net/t1ger-library#player-owned-vehicles "mention") ***for instructions)***:

   ```lua
   vehicle.plate -- plate of the vehicle
   vehicle.props -- vehicle properties
   vehicle.type -- vehicle type
   vehicle.job -- vehicle job
   vehicle.stored -- vehicle stored/state/parked state
   vehicle.garage -- garage of the vehicle
   vehicle.impound -- is vehicle in impound
   vehicle.sezied -- is vehicle seized?
   vehicle.model -- vehicle model
   vehicle.name -- vehicle name
   vehicle.category -- vehicle category
   vehicle.fuel -- fuel level of vehicle
   vehicle.egine -- engine level of vehicle
   vehicle.body -- body level of vehicle
   ```
4. Now inside the code for the event you can add checks. The checks have to be added as an if statement before the `table.insert()` function is called.
5. See my commented-out example inside the event (`data.marker.id` is a unique name created for each gang garage and you can use this for garage-specific systems).

   <figure><img src="https://2167335559-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MiDWIMbFBeXle-trOlk%2Fuploads%2F8Wg5jVxeMmURBDuLOfkI%2Fexample_spawn_vehicle_checks.png?alt=media&#x26;token=dfcc5e84-76d6-4cb5-ba71-6c412e02ba9f" alt=""><figcaption><p>Checks for garage, stored, type and job is used in this example.</p></figcaption></figure>

### Update Owned Vehicle

You may find it necessary to customize the event for updating a specific owned vehicle when the respective vehicle is either spawned from a garage or stored in a garage.&#x20;

By default the resource uses a `TriggerServerEvent` to T1GER Library to update stored, garage and props when a vehicle is spawned/stored. If you havent updated the function to your server settings, please refer to: [#update-owned-vehicle](https://docs.t1ger.net/t1ger-library#update-owned-vehicle "mention").

{% code title="The name of the TriggerServerEvent for updating owned vehicle:" %}

```lua
't1ger_lib:updateOwnedVehicle'
```

{% endcode %}

There are two entries of those in this resource. Navigate to: `t1ger_gangsystem/client/main.lua`.

The first looks like this:&#x20;

{% code title="Storing a vehicle into a gang garage:" %}

```lua
TriggerServerEvent('t1ger_lib:updateOwnedVehicle', true, marker.id, props)
-- true is the stored state, in this case vehicle is being stored into a garage.
-- marker.id (is the unique garage name of the gang).
-- props is the vehicle properties.
```

{% endcode %}

The second entry looks like this:&#x20;

{% code title="Spawning a vehicle from a gang garage:" %}

```lua
TriggerServerEvent('t1ger_lib:updateOwnedVehicle', false, nil, props)
-- false is the stored state, in this case vehicle is being såawned from the garage.
-- nil (garage), vehicle is no longer in any specific garage.
-- props is the vehicle properties.
```

{% endcode %}

You can change the `nil` value to `data.marker.id` if  you want to keep the garage of the vehicle when spawning it but logically it makes no sense. When vehicle is spawned the attached garage should be set to `nil`.

{% hint style="warning" %}
If your garage system / table column for stored/state/parked uses other value than a boolean, let's say an INT. Then update the true/false parameter in the TriggerServerEvent to an INT or whatever value it may be.&#x20;

Make sure to update the Lib.UpdateOwnedVehicle() function from T1GER Library accordingly, so it uses the parsed values instead of boolean. See [#update-owned-vehicle](https://docs.t1ger.net/t1ger-library#update-owned-vehicle "mention") to find the function in T1GER Library.
{% endhint %}
