# Exports

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

#### Get Player Gang

```lua
-- returns nil if not a gang member or a table with the gang and player info
local gang = exports['av_gangs']:getGang()
if gang then
    print(json.encode(gang, {indent = true})
end
```

#### Get Current Zone

> Returns the gang that owns a determinated zone or false, if not a controlled/valid zone.
>
> **params:**
>
> * **coords?:**`table x|y|z` Coords to scan for gang or empty to use current player coords.
>
> **returns:**
>
> * **gang:**`string|nil` Returns the gang name controlling the territory, or `nil` if nobody owns it.
> * **points:**`number` Amount of points held by the controlling gang, or `0` if unowned.

```lua
local gang, points = exports['av_gangs']:getZone()
print(gang, points)
local coords = {x = 100.0, y = 100.0, z = 100.0}
local gang2, points2 = exports['av_gangs']:getZone(coords)
print(gang2, points2)
```

#### Is Player Zone

```lua
-- returns true if the current zone belongs to his gang or false
local myZone = exports['av_gangs']:myZone()
if myZone then 
    print("Is my territory")
else
    print("Territory belongs to a rival gang or isn't taken")
end
```

#### Get Permissions

```lua
-- returns a table with the player permissions or false if not a gang member
local permissions = exports['av_gangs']:getPermissions()
if permissions then
    print(json.encode(permissions, {indent = true})
end
```

#### Get Interior Info

```lua
-- If the player is inside a property it will return a table with the property info, returns nill if is outside
local propertyInfo = exports['av_gangs']:getInterior()
if propertyInfo then
    print(json.encode(propertyInfo, {indent = true}))
end
```

{% endtab %}

{% tab title="Server" %}

### addToGang(playerId, gang)

> Add a player to a gang.
>
> **params:**
>
> * **playerId**:`number` Player server id
> * **gang**:`string` Gang name
>
> **returns**
>
> * **result**: `boolean`
>
> ```lua
> local playerId = 1 -- Player server id
> local gang = "lossantosvagos" -- gang name (NOT label)
> -- returns true/false
> local added = exports['av_gangs']:addToGang(playerId, gang)
> print("added?", added)
> ```

### removeFromGang(identifier)

> Remove a player from his current gang.
>
> **params:**
>
> * **identifier**:`string` Player Framework identifier
>
> **returns:**
>
> * **result**:`boolean`
>
> ```lua
> local identifier = exports['av_laptop']:getIdentifier(playerId)
> local removed = exports['av_gangs']:removeFromGang(identifier)
> -- returns true/false
> print("removed?", removed)
> ```

### getGang(playerId)

> Returns a table with all player gang info or false if not an active member.
>
> **params:**
>
> * **playerId**:`number` Player server id
>
> **returns:**
>
> * **result**:`table|false` Gang info or false

```lua
-- returns a table with gang and player info or null if not a gang member
local src = source
local myGang = exports['av_gangs']:getGang(src)
if myGang then
    print(json.encode(myGang, {indent = true}))
    --[[
        myGang = {
            "name": gang name
            "label": gang label
            "xp": gang XP
            "level": gang level
            "playerName": player name
            "isBoss": 1 for boss 0 for member
            "alias": player alias or an empty string
            "identifier": player identifier
            "permissions": a table with player permissions
        }
    ]]--
end
```

### getPermissions(playerId)

> Get all gang permissions from the player.
>
> **params:**
>
> * **playerId**:`number` Player server id
>
> **returns**:
>
> * **permissions**:`table`
>
> ```lua
> local permissions = exports['av_gangs']:getPermissions(playerId)
> print(json.encode(permissions, {indent = true}))
> --[[
>     permissions is a table with permissions as index keys
>     permissions = {
>         "isBoss": true,
>         "members": true
>     }
> ]]--
> ```

### getGangByName(gang)

> Get a table with all gang info.
>
> **params:**
>
> * **gang**:`string` Gang name or label
>
> **returns:**
>
> * **result**:`table|false` Gang info or false if gang doesn't exist

```lua
-- Returns a table with the gang main info or false if doesn't exists
local gang = "Los Santos Vagos"
local info = exports['av_gangs']:getGangByName(gang)
if info then
    print(json.encode(info, {indent = true}))
    --[[
        info = {
            "logo": gang logo url
            "strain": gang strain name
            "name": gang name
            "label: gang label
            "level": gang XP
            "
        }
    ]]--
end
```

### registerGang(label,playerId)

> Register a new gang from an external resource.
>
> **params:**
>
> * **label**:`string` Gang label
> * **playerId?**:`number` Server id from boss player
>
> **returns**
>
> * **registered**:`boolean`

```lua
-- Returns false if the gang already exists or true to confirm it was created.
-- boss is the player id to set as boss or send false
local name = "Los Santos Vagos"
local boss = source
local res = exports['av_gangs']:registerGang(name,source)
if res then
    print("Gang registered!")
end
```

### setBoss(gang,playerId)

> Set a player as gang boss
>
> **params:**
>
> * **gang**:`string` Gang name (not label)
> * **playerId**:`number` Player server id

```lua
-- returns true or false
local src = source
local gang = "Los Santos Vagos"
local res = exports['av_gangs']:setBoss(gang,src)
if res then
    print("added as boss!")
end
```

### getGangNames()

> Return a table with all gang names.

```lua
-- Returns a table with all gang names (NOT labels)
local allGangs = exports['av_gangs']:getGangNames()
print(json.encode(allGangs, {indent = true}))
```

### getGraffitis(gang)

> Get a table with all gang graffitis.
>
> **params:**&#x20;
>
> * **gang**:`string` Gang name
>
> **returns**
>
> * **graffitis**:`Table`

```lua
-- Returns the amount of gang graffitis
local gang = "Los Santos Vagos"
local graffitis = exports['av_gangs']:getGraffitis(gang)
print(graffitis)
```

### addXP(gang,amount,skipDaily)

> Add XP to a gang (this is NOT for territories but for gang level)
>
> **params:**
>
> * **gang**:`string` Gang name
> * **amount**:`number` Amount to add
> * **skipDaily**?:`boolean` Skip the daily max for gang XP

```lua
-- Adds XP to the gang
-- You can skip the daily limit if you send true as 3rd argument
local gang = "Los Santos Vagos"
local toAdd = 500
local skipDaily = true
local added = exports['av_gangs']:addXP(gang,toAdd,skipDaily)
if added then
    print("XP added")
else
    print("Gang doesn't exist")
end
```

### removeXP(gang,amount)

> Remove XP from a gang (level XP not from territories system).
>
> **params:**
>
> * **gang**:`string` Gang name
> * **amount**:`number` Amount to remove

```lua
-- Removes XP to the gang
local gang = "Los Santos Vagos"
local toRemove = 200
local removed = exports['av_gangs']:removeXP(gang,toRemove)
if removed then
    print("XP Removed")
else
    print("Gang doesn't exist")
end
```

### getGangXP(gang)

> Get the gang current XP (not level)
>
> **params:**
>
> * **gang**:`string` Gang name
>
> **returns:**
>
> * **xp**:`number`

<pre class="language-lua"><code class="lang-lua">local gang = "Los Santos Vagos"
local xp = exports['av_gangs']:getGangXP(gang)
<strong>print(xp)
</strong></code></pre>

### getGangLevel(gang)

> Get gang XP / Config.LevelXP
>
> **params:**
>
> * **gang**:`string` Gang name
>
> **returns:**
>
> * **level**:`number`
>
> ```lua
> local gang = "Los Santos Vagos"
> local level = exports['av_gangs']:getLevel(gang)
> print(level)
> ```

### getMembers(gang)

> Get a list with all gang members.
>
> **params:**
>
> * **gang**:`string` Gang name

```lua
-- Returns a table with all players info from a gang or false
local gang = "Los Santos Vagos"
local members = exports['av_gangs']:getMembers(gang)
if members then
    print(json.encode(members, {indent = true}))
end
```

### getMembersOnline(gang)

> Get a list with all online players from a gang.
>
> **params:**
>
> * **gang**:`string` Gang name
>
> **returns**
>
> * **members**:`table`
>
> ```lua
> local online = exports['av_gangs']:getMembersOnline('ballas')
> print(#online) -- will print the amount of online members
> print(json.encode(online, {indent = true})) -- prints the full list
>
> --[[
>     every member is a table with the following data:
>     {
>       "isBoss": 0 for member or 1 for boss
>       "name": gang name
>       "playerName": player name
>       "joined": date
>       "identifier": player framework identifier
>       "permissions": table
>       "serverId": player server id
>     }
> ]]--
> ```

### getMembersCount(gang)

> Returns the gang members count, including online and offline members.
>
> **params:**
>
> * **gang**:`string` Gang name
>
> **returns**:
>
> * **count**:`number`
>
> ```lua
> local members = exports['av_gangs']:getMembersCount('ballas')
> print(members)
> ```

### sendSpray(playerId,gang)

> Send a spray item to a specific player.
>
> **params:**
>
> * **playerId**:`number` Player server id
> * **gang**:`string` Gang name
>
> **returns**
>
> * **result**:`boolean`
>
> ```lua
> local playerId = 1
> local gang = "lossantosvagos"
> local received = exports['av_gangs']:sendSpray(playerId, gang)
> print('received?', received)
> ```

### addReputation(playerId,amount)

> Add reputation to player
>
> **parameters:**
>
> * **playerId**:`number` Player server id
> * **amount**:`number` Amount to add
>
> **returns:**
>
> * **added**:`boolean`
>
> ```lua
> local added = exports['av_gangs']:addReputation(playerId,amount)
> print('added?', added)
> ```

### removeReputation(playerId,amount)

> Remove reputation to player.
>
> parameters:
>
> * playerId:number Player server id
> * amount:number Amount to remove
>
> returns
>
> * removed:boolean
>
> ```lua
> local removed = exports['av_gangs']:removeReputation(playerId,amount)
> print('removed?',removed)
> ```

### getReputation(playerId)

> Get player gang reputation
>
> **parameters:**
>
> * **playerId**:`number` Player server id
>
> **returns:**
>
> * **reputation**:`number`
>
> ```lua
> local rep = exports['av_gangs']:getReputation(playerId)
> print(rep)
> ```

### setCustomDaily(gang,xp)

> Sets a custom daily limit XP for a gang, this will override the default limit in the config for that gang.
>
> **parameters**:
>
> * **name**:`string` Gang name
> * **xp**:`number` Daily XP limit for that gang
>
> {% code title="" %}
>
> ```lua
> local gang = "ballas"
> local max = 10000
> local success = exports['av_gangs']:setCustomDaily(gang,max)
> print(success) -- true or false
> ```
>
> {% endcode %}

#### getDaily(gang)

> Retrieves the current XP earned by a gang in the day.
>
> **parameters:**
>
> * **gang:**`string` Gang name
>
> returns:
>
> * **xp:**`number`
>
> {% code title="" %}
>
> ```lua
> local gang = "ballas"
> local amount = exports['av_gangs']:getDaily(gang)
> print(amount)
> ```
>
> {% endcode %}
> {% 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/exports.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.
