> For the complete documentation index, see [llms.txt](https://documentation.rcore.cz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://documentation.rcore.cz/paid-resources/rcore_gangs/api/api-server.md).

# Server

## Events (General)

List of general events.

### Increase Loyalty

{% hint style="info" %}
**SERVER SIDE**
{% endhint %}

This event increases loyalty in the zone based on a specified action for the gang the specified player is a member of.

#### Example code

{% code title="server.lua" overflow="wrap" lineNumbers="true" %}

```lua
TriggerEvent('rcore_gangs:server:increase_loyalty', src, action, modifier)
```

{% endcode %}

Parameter:

* src: `number`
  * `number`: The source of the player (server identifier)
* action: `string`
  * `string`: The action that occurred (defined in Config.IncreaseMultipliers)
* modifier: `number`
  * `number`: The modifier that additionally changes how much loyalty is added

### Decrease Loyalty

{% hint style="info" %}
**SERVER SIDE**
{% endhint %}

This event decreases loyalty in the zone based on a specified action for the gang the specified player is a member of.

#### Example code

{% code title="server.lua" overflow="wrap" lineNumbers="true" %}

```lua
TriggerEvent('rcore_gangs:server:decrease_loyalty', src, action, modifier)
```

{% endcode %}

Parameter:

* src: `number`
  * `number`: The source of the player (server identifier)
* action: `string`
  * `string`: The action that occurred (defined in Config.DecreaseMultipliers)
* modifier: `number`
  * `number`: The modifier that additionally changes how much loyalty is removed

## Exports (General)

List of general exports.

### GetPlayerGang

{% hint style="info" %}
**SHARED SIDE**
{% endhint %}

This export returns the gang the specified player is a member of.

#### Example code

{% code title="server.lua" overflow="wrap" lineNumbers="true" %}

```lua
exports['rcore_gangs']:GetPlayerGang(src)
```

{% endcode %}

Parameter:

* src: `number`
  * `number`: The source of the player (server identifier)

Return:

* gang?: `table`
  * id: `number`
    * `number`: The id of the gang
  * tag: `string`
    * `string`: The gang tag
  * name: `string`
    * `string`: The gang name
  * color: `string`
    * `string`: The gang color
  * identifier: `number` or `string`
    * `number`: The identifier of the gang leader
    * `string`: The identifier of the gang leader
  * members: `table[]`
    * `table`: The list of all gang members
      * name: `string`
        * `string`: The ingame character name of the gang member
      * rank: `string`
        * `string`: The rank of the gang member
      * access: `boolean`
        * `boolean`: Whether or not the gang member has priviliged rank
      * identifier: `number` or `string`
        * `number`: The identifier of the gang member
        * `string`: The identifier of the gang member
  * vehicles: `table[]`
    * `table`: The list of all gang vehicles
      * model: `number`
        * `number`: The model hash of the gang vehicle
      * color: `number`
        * `number`: The color index of the gang vehicle
  * garage?: `vec3`
    * `vec3`: The position of the gang garage
  * storage?: `vec3`
    * `vec3`: The position of the gang storage
  * rank: `string`
    * `string`: The rank of the specified player in the gang
  * access: `boolean`
    * `boolean`: Whether or not the specified player has priviliged rank
  * superaccess: `boolean`
    * `boolean`: Whether or not the specified player is the leader of the gang

### GetGangAtZone

{% hint style="info" %}
**SERVER SIDE**
{% endhint %}

This export returns the gang which controls the specified zone.

#### Example code

{% code title="server.lua" overflow="wrap" lineNumbers="true" %}

```lua
exports['rcore_gangs']:GetGangAtZone(zone)
```

{% endcode %}

Parameter:

* zone: `table`
  * `table`: The zone object obtained by using `GetZoneAtPosition` export

Return:

* gang?: `table`
  * id: `number`
    * `number`: The id of the gang
  * tag: `string`
    * `string`: The gang tag
  * name: `string`
    * `string`: The gang name
  * color: `string`
    * `string`: The gang color
  * identifier: `number` or `string`
    * `number`: The identifier of the gang leader
    * `string`: The identifier of the gang leader
  * members: `table[]`
    * `table`: The list of all gang members
      * name: `string`
        * `string`: The ingame character name of the gang member
      * rank: `string`
        * `string`: The rank of the gang member
      * access: `boolean`
        * `boolean`: Whether or not the gang member has priviliged rank
      * identifier: `number` or `string`
        * `number`: The identifier of the gang member
        * `string`: The identifier of the gang member
  * vehicles: `table[]`
    * `table`: The list of all gang vehicles
      * model: `number`
        * `number`: The model hash of the gang vehicle
      * color: `number`
        * `number`: The color index of the gang vehicle
  * garage?: `vec3`
    * `vec3`: The position of the gang garage
  * storage?: `vec3`
    * `vec3`: The position of the gang storage

### GetZoneAtPosition

{% hint style="info" %}
**SHARED SIDE**
{% endhint %}

This export returns the gang zone located in the specified position.

#### Example code

{% code title="server.lua" overflow="wrap" lineNumbers="true" %}

```lua
exports['rcore_gangs']:GetZoneAtPosition(position)
```

{% endcode %}

Parameter:

* position: `vec3`
  * `vec3`: The position of the zone

Return:

* zone?: `table`
  * name: `string`
    * `string`: The name of the zone
  * label: `string`
    * `string`: The label of the zone
  * neighbors: `table[]`
    * `table`: The list of all the neighboring zones
  * drugPreference: `table`
    * `table`: The multipliers for each drug category in the zone
      * CATEGORY\_LOW: `number`:
        * `number`: The multiplier for low drug category
      * CATEGORY\_MED: `number`:
        * `number`: The multiplier for medium drug category
      * CATEGORY\_HIGH: `number`:
        * `number`: The multiplier for high drug category

### IsPlayerBagged

{% hint style="info" %}
**SHARED SIDE**
{% endhint %}

This export returns whether the specified player has paper bag on or not.

#### Example code

{% code title="server.lua" overflow="wrap" lineNumbers="true" %}

```lua
exports['rcore_gangs']:IsPlayerBagged(src)
```

{% endcode %}

Parameter:

* src: `number`
  * `number`: The source of the player (server identifier)

Return:

* check: `boolean`
  * `boolean`: Whether or not the player has paper bag on

### IsPlayerRestrained

{% hint style="info" %}
**SHARED SIDE**
{% endhint %}

This export returns whether the specified player has zip ties on or not.

#### Example code

{% code title="server.lua" overflow="wrap" lineNumbers="true" %}

```lua
exports['rcore_gangs']:IsPlayerRestrained(src)
```

{% endcode %}

Parameter:

* src: `number`
  * `number`: The source of the player (server identifier)

Return:

* check: `boolean`
  * `boolean`: Whether or not the player has zip ties on

### IsPlayerEscorted

{% hint style="info" %}
**SHARED SIDE**
{% endhint %}

This export returns whether the specified player is being escorted or not.

#### Example code

{% code title="server.lua" overflow="wrap" lineNumbers="true" %}

```lua
exports['rcore_gangs']:IsPlayerEscorted(src)
```

{% endcode %}

Parameter:

* src: `number`
  * `number`: The source of the player (server identifier)

Return:

* check: `boolean`
  * `boolean`: Whether or not the player is being escorted

## Exports (Management)

List of management exports.

### CreateGang

{% hint style="info" %}
**SERVER SIDE**
{% endhint %}

This export creates a new gang based on the specified parameters.

#### Example code

{% code title="server.lua" overflow="wrap" lineNumbers="true" %}

```lua
exports['rcore_gangs']:CreateGang(playerId, colorId, group, tag, name)
```

{% endcode %}

Parameter:

* playerId: `number` or `string`
  * `number`: The source of the player (server identifier)
  * `string`: The identifier of the player (server database)
* colorId: `string`
  * `string`: The color of the gang
* group: `string`
  * `string`: The rank group of the gang
* tag: `string`
  * `string`: The tag of the gang
* name: `string`
  * `string`: The name of the gang

Return:

* message?: `string`
  * `string`: The error message if the export failed

### DeleteGang

{% hint style="info" %}
**SERVER SIDE**
{% endhint %}

This export deletes an existing gang based on the specified parameters.

#### Example code

{% code title="server.lua" overflow="wrap" lineNumbers="true" %}

```lua
exports['rcore_gangs']:DeleteGang(gangId)
```

{% endcode %}

Parameter:

* gangId: `number` or `string`
  * `number`: The id of the gang
  * `string`: The tag/name of the gang

Return:

* message?: `string`
  * `string`: The error message if the export failed

### AddMember

{% hint style="info" %}
**SERVER SIDE**
{% endhint %}

This export adds a new member to an existing gang based on the specified parameters.

#### Example code

{% code title="server.lua" overflow="wrap" lineNumbers="true" %}

```lua
exports['rcore_gangs']:AddMember(playerId, gangId)
```

{% endcode %}

Parameter:

* playerId: `number` or `string`
  * `number`: The source of the player (server identifier)
  * `string`: The identifier of the player (server database)
* gangId: `number` or `string`
  * `number`: The id of the gang
  * `string`: The tag/name of the gang

Return:

* message?: `string`
  * `string`: The error message if the export failed

### KickMember

{% hint style="info" %}
**SERVER SIDE**
{% endhint %}

This export kicks a member from an existing gang based on the specified parameters.

#### Example code

{% code title="server.lua" overflow="wrap" lineNumbers="true" %}

```lua
exports['rcore_gangs']:KickMember(playerId, gangId)
```

{% endcode %}

Parameter:

* playerId: `number` or `string`
  * `number`: The source of the player (server identifier)
  * `string`: The identifier of the player (server database)
* gangId: `number` or `string`
  * `number`: The id of the gang
  * `string`: The tag/name of the gang

Return:

* message?: `string`
  * `string`: The error message if the export failed

### SetMemberRank

{% hint style="info" %}
**SERVER SIDE**
{% endhint %}

This export changes the rank of a member from an existing gang based on the specified parameters.

#### Example code

{% code title="server.lua" overflow="wrap" lineNumbers="true" %}

```lua
exports['rcore_gangs']:SetMemberRank(playerId, rank, gangId)
```

{% endcode %}

Parameter:

* playerId: `number` or `string`
  * `number`: The source of the player (server identifier)
  * `string`: The identifier of the player (server database)
* rank: `number` or `string`
  * `number`: The table index of the rank (defined in Config.GangRanks)
  * `string`: The name of the rank (defined in Config.GangRanks)
* gangId: `number` or `string`
  * `number`: The id of the gang
  * `string`: The tag/name of the gang

Return:

* message?: `string`
  * `string`: The error message if the export failed

### SetMemberLeader

{% hint style="info" %}
**SERVER SIDE**
{% endhint %}

This export transfers the leadership from the leader to a member from an existing gang based on the specified parameters.

#### Example code

{% code title="server.lua" overflow="wrap" lineNumbers="true" %}

```lua
exports['rcore_gangs']:SetMemberLeader(playerId, gangId)
```

{% endcode %}

Parameter:

* playerId: `number` or `string`
  * `number`: The source of the player (server identifier)
  * `string`: The identifier of the player (server database)
* gangId: `number` or `string`
  * `number`: The id of the gang
  * `string`: The tag/name of the gang

Return:

* message?: `string`
  * `string`: The error message if the export failed

### LeaveGang

{% hint style="info" %}
**SERVER SIDE**
{% endhint %}

This export makes a member leave an existing gang based on the specified parameters.

#### Example code

{% code title="server.lua" overflow="wrap" lineNumbers="true" %}

```lua
exports['rcore_gangs']:LeaveGang(playerId, gangId)
```

{% endcode %}

Parameter:

* playerId: `number` or `string`
  * `number`: The source of the player (server identifier)
  * `string`: The identifier of the player (server database)
* gangId: `number` or `string`
  * `number`: The id of the gang
  * `string`: The tag/name of the gang

Return:

* message?: `string`
  * `string`: The error message if the export failed

### DisbandGang

{% hint style="info" %}
**SERVER SIDE**
{% endhint %}

This export makes the leader disband an existing gang based on the specified parameters.

#### Example code

{% code title="server.lua" overflow="wrap" lineNumbers="true" %}

```lua
exports['rcore_gangs']:DisbandGang(playerId, gangId)
```

{% endcode %}

Parameter:

* playerId: `number` or `string`
  * `number`: The source of the player (server identifier)
  * `string`: The identifier of the player (server database)
* gangId: `number` or `string`
  * `number`: The id of the gang
  * `string`: The tag/name of the gang

Return:

* message?: `string`
  * `string`: The error message if the export failed

### AddCheckpoint

{% hint style="info" %}
**SERVER SIDE**
{% endhint %}

This export adds a new checkpoint to an existing gang based on the specified parameters.

#### Example code

{% code title="server.lua" overflow="wrap" lineNumbers="true" %}

```lua
exports['rcore_gangs']:AddCheckpoint(checkpoint, position, gangId)
```

{% endcode %}

Parameter:

* checkpoint: `string`
  * `string`: The checkpoint type to add `GARAGE` or `STORAGE`
* position: `vec3`
  * `vec3`: The position of the checkpoint
* gangId: `number` or `string`
  * `number`: The id of the gang
  * `string`: The tag/name of the gang

Return:

* message?: `string`
  * `string`: The error message if the export failed

### RemoveCheckpoint

{% hint style="info" %}
**SERVER SIDE**
{% endhint %}

This export removes an existing checkpoint from an existing gang based on the specified parameters.

#### Example code

{% code title="server.lua" overflow="wrap" lineNumbers="true" %}

```lua
exports['rcore_gangs']:RemoveCheckpoint(checkpoint, gangId)
```

{% endcode %}

Parameter:

* checkpoint: `string`
  * `string`: The checkpoint type to remove `GARAGE` or `STORAGE`
* gangId: `number` or `string`
  * `number`: The id of the gang
  * `string`: The tag/name of the gang

Return:

* message?: `string`
  * `string`: The error message if the export failed

### AddVehicle

{% hint style="info" %}
**SERVER SIDE**
{% endhint %}

This export adds a new vehicle to an existing gang garage based on the specified parameters.

#### Example code

{% code title="server.lua" overflow="wrap" lineNumbers="true" %}

```lua
exports['rcore_gangs']:AddVehicle(model, color, gangId)
```

{% endcode %}

Parameter:

* model: `number` or `string`
  * `number`: The model hash of the vehicle
  * `string`: The model name of the vehicle
* color: `number`
  * `number`: The color index of the vehicle (defined in Config.VehicleColors)
* gangId: `number` or `string`
  * `number`: The id of the gang
  * `string`: The tag/name of the gang

Return:

* message?: `string`
  * `string`: The error message if the export failed

### RemoveVehicle

{% hint style="info" %}
**SERVER SIDE**
{% endhint %}

This export removes an existing vehicle from an existing gang garage based on the specified parameters.

#### Example code

{% code title="server.lua" overflow="wrap" lineNumbers="true" %}

```lua
exports['rcore_gangs']:RemoveVehicle(model, color, gangId)
```

{% endcode %}

Parameter:

* model: `number` or `string`
  * `number`: The model hash of the vehicle
  * `string`: The model name of the vehicle
* color: `number`
  * `number`: The color index of the vehicle (defined in Config.VehicleColors)
* gangId: `number` or `string`
  * `number`: The id of the gang
  * `string`: The tag/name of the gang

Return:

* message?: `string`
  * `string`: The error message if the export failed

### AddBalance

{% hint style="info" %}
**SERVER SIDE**
{% endhint %}

This export adds money to an existing gang reserve based on the specified parameters.

#### Example code

{% code title="server.lua" overflow="wrap" lineNumbers="true" %}

```lua
exports['rcore_gangs']:AddBalance(amount, gangId)
```

{% endcode %}

Parameter:

* amount: `number`
  * `number`: The amount to be added
* gangId: `number` or `string`
  * `number`: The id of the gang
  * `string`: The tag/name of the gang

Return:

* message?: `string`
  * `string`: The error message if the export failed

### RemoveBalance

{% hint style="info" %}
**SERVER SIDE**
{% endhint %}

This export removes money from an existing gang reserve based on the specified parameters.

#### Example code

{% code title="server.lua" overflow="wrap" lineNumbers="true" %}

```lua
exports['rcore_gangs']:RemoveBalance(amount, gangId)
```

{% endcode %}

Parameter:

* amount: `number`
  * `number`: The amount to be removed
* gangId: `number` or `string`
  * `number`: The id of the gang
  * `string`: The tag/name of the gang

Return:

* message?: `string`
  * `string`: The error message if the export failed
