# Territories

> This script features a territory control system that uses points to determine which gang dominates a specific area. Points are gained or lost through various in-game events, you also have client exports you can trigger from your own scripts.

{% hint style="info" %}
You can find a list of default events that triggers the add/removal of zone points in `server/editable/_territories.lua` I don't list them here to prevent any possible metagaming.
{% endhint %}

<figure><img src="/files/T5F4vnvejp3QPonyWONL" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
You can hide the left leaderboard in `config/territories.lua`
{% endhint %}

### Territory Colors

> Gangs can set their own territory color in Settings tab > Gang Color, this option will also change the UI color to match their gang style.

<figure><img src="/files/X3Tx0qdy3RnByQE2r1hQ" alt=""><figcaption></figcaption></figure>

### Exports

{% tabs %}
{% tab title="Client" %}

### getZone()

> Retrieves the gang that controls the zone where player is standing.
>
> **returns**
>
> * **result**: `string | false` Gang name or false if the zone isn't controlled by any gang
>
> ```lua
> local controlled = exports['av_gangs']:getZone()
> print(controlled)
> ```

### myZone()

> Returns true if the current zone is controlled by the player gang or false.
>
> **returns**
>
> * **result**:`boolean`
>
> ```lua
> local myZone = exports['av_gangs']:myZone()
> print(myZone)
> ```

### addZoneXP(amount)

> Add the desired points to the zone where the player is standing.
>
> **params:**
>
> * **amount**:`number` Amount of points to add to zone.
>
> ```lua
> local toAdd = 10
> exports['av_gangs']:addZoneXP(toAdd) -- will add 10 points to current zone
> ```

### removeZoneXP(amount)

> Remove points to the zone where the player is standing.
>
> **params:**
>
> * **amount**:`number` Amount of points to remove from zone
>
> ```lua
> local toRemove = 5
> exports['av_gangs']:removeZoneXP(toRemove) -- will remove 5 points to zone
> ```

{% endtab %}

{% tab title="Server" %}
{% hint style="info" %}
Zone names can only be retrieved client side, here's a list of names: <https://docs.fivem.net/natives/?_0xCD90657D4C30E1CA>
{% endhint %}

### addZonePoints(gang,zone,amount)

> Add points for a gang to a specific zone.
>
> **params**:
>
> * **gang**:`string` Gang name
> * **zone**:`string` Zone name
> * **amount**:`number` Amount of points to add to territory
>
> **returns**
>
> * **result**:`boolean`
>
> ```lua
> local gang = 'lossantosvagos'
> local zone = 'DAVIS'
> local amount = 10
> local added = exports['av_gangs']:addZonePoints(gang,zone,amount)
> print('added?', added)
> ```

### removeZonePoints(gang,zone,amount)

> Remove gang points from a territory.
>
> **params:**
>
> * **gang**:`string` Gang name
> * **zone**:`string` Zone name
> * **amount**:`number` Amount of points to remove
>
> **returns:**
>
> * **result**:`boolean`
>
> ```lua
> local gang = "lossantosvagos"
> local zone = "DAVIS"
> local amount = 5
> local removed = exports['av_gangs']:removeZonePoints(gang,zone,amount)
> print('removed?', removed)
> ```

### getZoneGang(zone)

> Returns the gang with the most points in the zone.
>
> **params:**
>
> * **zone**:`string` Zone name
>
> **returns:**
>
> * **gang**:`null | string` Returns the gang name or null if zone does not exist or zone isn't controlled by anyone.
>
> ```lua
> local zone = "VINE"
> local topGang = exports['av_gangs']:getZoneGang(zone)
> print('topGang?', topGang)
> ```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.av-scripts.com/laptop-pack-v3/gangs/territories.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
