# Events & Exports

## Server Events <a href="#server-events" id="server-events"></a>

**rm\_gangs:client:onGangMoneySet**

```lua
AddEventHandler('rm_gangs:client:onGangMoneySet', function(data)
    print(data.gangName)
    print(data.newAmount)
end)
```

| Key       | Type   | Description                               |
| --------- | ------ | ----------------------------------------- |
| gangName  | string | The name of the gang whose money was set. |
| newAmount | number | The updated amount of gang money.         |

**rm\_gangs:client:onGangMoneyAdded**

```lua
AddEventHandler('rm_gangs:client:onGangMoneyAdded', function(data)
    print(data.gangName)
    print(data.newAmount)
end)
```

| Key       | Type   | Description                               |
| --------- | ------ | ----------------------------------------- |
| gangName  | string | The name of the gang whose money was set. |
| newAmount | number | The updated amount of gang money.         |

**rm\_gangs:client:onGangMoneyRemoved**

```lua
AddEventHandler('rm_gangs:client:onGangMoneyRemoved', function(data)
    print(data.gangName)
    print(data.newAmount)
end)
```

| Key       | Type   | Description                               |
| --------- | ------ | ----------------------------------------- |
| gangName  | string | The name of the gang whose money was set. |
| newAmount | number | The updated amount of gang money.         |

**rm\_gangs:server:onTributeEventStarted**

```lua
AddEventHandler('rm_gangs:server:onTributeEventStarted', function(data)
    print(data.name)
    print(data.label)
    print(data.finishDate)
    print(data.paymentAmount)
    print(data.captureDuration)
    print(data.coords)
    print(json.encode(data.territory, {indent = true}))
    print(data.oldOwnerName)
    print(data.oldOwnerLabel)
end)
```

| Key             | Type          | Description                                                             |
| --------------- | ------------- | ----------------------------------------------------------------------- |
| name            | string        | Tribute zone name in cfg file                                           |
| label           | string        | Tribute zone label in cfg file                                          |
| finishDate      | number        | Timestamp of the event end date                                         |
| paymentAmount   | number        | Money that can be received during the time interval set in the cfg file |
| captureDuration | number        | Event duration in the cfg file                                          |
| coords          | vec4          | Coordinate of the tribute npc in the cfg file                           |
| territory       | table         | Tribute territory data in cfg file                                      |
| oldOwnerName    | string or nil | Name of the group that owned the tribute territory before the war       |
| oldOwnerLabel   | string or nil | Label of the group that owned the tribute territory before the war      |

**rm\_gangs:server:onTributeEventFinished**

```lua
AddEventHandler('rm_gangs:server:onTributeEventFinished', function(data)
    print(data.name)
    print(data.label)
    print(data.paymentAmount)
    print(data.captureDuration)
    print(data.coords)
    print(json.encode(data.territory, {indent = true}))
    print(data.ownerName)
    print(data.ownerLabel)
    print(data.captureDate)
    print(data.oldOwnerName)
    print(data.oldOwnerLabel)
end)
```

| Key             | Type          | Description                                                             |
| --------------- | ------------- | ----------------------------------------------------------------------- |
| name            | string        | Tribute zone name in cfg file                                           |
| label           | string        | Tribute zone label in cfg file                                          |
| paymentAmount   | number        | Money that can be received during the time interval set in the cfg file |
| captureDuration | number        | Event duration in the cfg file                                          |
| coords          | vec4          | Coordinate of the tribute npc in the cfg file                           |
| territory       | table         | Tribute territory data in cfg file                                      |
| ownerName       | string or nil | Name of the new owner of the zone                                       |
| ownerLabel      | string or nil | Label of the new owner of the zone                                      |
| captureDate     | number or nil | Timestamp of the claim date                                             |
| oldOwnerName    | string or nil | Name of the group that owned the tribute territory before the war       |
| oldOwnerLabel   | string or nil | Label of the group that owned the tribute territory before the war      |

**rm\_gangs:server:onTurfWarStarted**

```lua
AddEventHandler('rm_gangs:server:onTurfWarStarted', function(data)
    print(data.id)
    print(data.initiatorName)
    print(data.initiatorLabel)
    print(data.targetName)
    print(data.targetLabel)
    print(data.startDate)
    print(data.finishDate)
end)
```

| Key            | Type   | Description                              |
| -------------- | ------ | ---------------------------------------- |
| id             | number | Turf war id                              |
| initiatorName  | string | Name of the group that started turf war  |
| initiatorLabel | string | Label of the group that started turf war |
| targetName     | string | Name of the group that owns the turf     |
| targetLabel    | string | Label of the group that owns the turf    |
| startDate      | number | Timestamp of the start date of turf war  |
| finishDate     | number | Timestamp of the end date of turf war    |

**rm\_gangs:server:onTurfWarFinished**

```lua
AddEventHandler('rm_gangs:server:onTurfWarFinished', function(data)
    print(data.id)
    print(data.initiatorName)
    print(data.initiatorLabel)
    print(data.targetName)
    print(data.targetLabel)
    print(data.startDate)
    print(data.finishDate)
    print(data.initiatorNewLoyalty)
    print(data.initiatorPersonCount)
    print(data.targetNewLoyalty)
    print(data.targetPersonCount)
    print(data.successful)
end)
```

| Key                  | Type    | Description                                                                             |
| -------------------- | ------- | --------------------------------------------------------------------------------------- |
| id                   | number  | Turf war id                                                                             |
| initiatorName        | string  | Name of the group that started turf war                                                 |
| initiatorLabel       | string  | Label of the group that started turf war                                                |
| targetName           | string  | Name of the group that owns the turf                                                    |
| targetLabel          | string  | Label of the group that owns the turf                                                   |
| startDate            | number  | Timestamp of the start date of turf war                                                 |
| finishDate           | number  | Timestamp of the end date of turf war                                                   |
| initiatorNewLoyalty  | number  | New loyalty points for the group that started the turf war                              |
| initiatorPersonCount | number  | Number of people alive at the end of the battle for the group that started the turf war |
| targetNewLoyalty     | number  | Turf owner's new loyalty points                                                         |
| targetPersonCount    | number  | Turf owner's number of people alive at the end of the turf war                          |
| successful           | boolean | Winning status of the side that started the turf war                                    |

**rm\_gangs:server:onWarReplied**

```lua
AddEventHandler('rm_gangs:server:onWarReplied', function(data)
    print(data.id)
    print(data.initiatorName)
    print(data.initiatorLabel)
    print(data.initiatorIdentifier)
    print(data.initiatorScore)
    print(data.targetName)
    print(data.targetLabel)
    print(data.targetIdentifier)
    print(data.targetScore)
    print(data.killGoal)
    print(data.wager)
    print(data.declareDate)
    print(data.acceptRejectDate)
    if data.accepted then
        print('accepted')
    else
        print('rejected')
    end
end)
```

| Key                 | Type    | Description                                                    |
| ------------------- | ------- | -------------------------------------------------------------- |
| id                  | number  | War id                                                         |
| initiatorName       | string  | Name of the group that declared the war                        |
| initiatorLabel      | string  | Label of the group that started war                            |
| initiatorIdentifier | string  | Identifier of the leader of the group that started the war     |
| initiatorScore      | number  | Score of the group that started the war                        |
| targetName          | string  | Name of the group that is the target of the war declaration    |
| targetLabel         | string  | Label of the group being declared war on                       |
| targetIdentifier    | string  | Identifier of the leader of the group declared at war          |
| targetScore         | number  | Score of the declared war group                                |
| killGoal            | number  | The killing goal of war                                        |
| wager               | number  | The amount of money set as a wager                             |
| accepted            | boolean | Indicates whether the group declared upon has accepted the war |
| declareDate         | number  | Timestamp of the declare date of war                           |
| acceptRejectDate    | number  | Timestamp of the reply date of war                             |

**rm\_gangs:server:onWarFinished**

```lua
AddEventHandler('rm_gangs:server:onWarFinished', function(data)
    print(data.id)
    print(data.initiatorName)
    print(data.initiatorLabel)
    print(data.initiatorIdentifier)
    print(data.initiatorScore)
    print(data.initiatorNewLoyalty)
    print(data.targetName)
    print(data.targetLabel)
    print(data.targetIdentifier)
    print(data.targetScore)
    print(data.targetNewLoyalty)
    print(data.killGoal)
    print(data.wager)
    print(data.declareDate)
    print(data.acceptRejectDate)
    print(data.finishDate)
end)
```

| Key                 | Type   | Description                                                 |
| ------------------- | ------ | ----------------------------------------------------------- |
| id                  | number | War id                                                      |
| initiatorName       | string | Name of the group that declared the war                     |
| initiatorLabel      | string | Label of the group that started war                         |
| initiatorIdentifier | string | Identifier of the leader of the group that started the war  |
| initiatorScore      | number | Score of the group that started the war                     |
| initiatorNewLoyalty | number | New loyalty point of the group that started the war         |
| targetName          | string | Name of the group that is the target of the war declaration |
| targetLabel         | string | Label of the group being declared war on                    |
| targetIdentifier    | string | Identifier of the leader of the group declared at war       |
| targetScore         | number | Score of the declared war group                             |
| targetNewLoyalty    | number | New loyalty point of the declared war group                 |
| killGoal            | number | The killing goal of war                                     |
| wager               | number | The amount of money set as a wager                          |
| declareDate         | number | Timestamp of the declare date of war                        |
| acceptRejectDate    | number | Timestamp of the reply date of war                          |
| finishDate          | number | Timestamp of the date the war ended                         |

#### Client Events <a href="#client-events" id="client-events"></a>

**rm\_gangs:client:onTributeEventStarted**

```lua
RegisterNetEvent('rm_gangs:client:onTributeEventStarted', function(data)
    print(data.name)
    print(data.label)
    print(data.finishDate)
    print(data.paymentAmount)
    print(data.captureDuration)
    print(data.coords)
    print(json.encode(data.territory, {indent = true}))
    print(data.oldOwnerName)
    print(data.oldOwnerLabel)
end)
```

| Key             | Type          | Description                                                             |
| --------------- | ------------- | ----------------------------------------------------------------------- |
| name            | string        | Tribute zone name in cfg file                                           |
| label           | string        | Tribute zone label in cfg file                                          |
| finishDate      | number        | Timestamp of the event end date                                         |
| paymentAmount   | number        | Money that can be received during the time interval set in the cfg file |
| captureDuration | number        | Event duration in the cfg file                                          |
| coords          | vec4          | Coordinate of the tribute npc in the cfg file                           |
| territory       | table         | Tribute territory data in cfg file                                      |
| oldOwnerName    | string or nil | Name of the group that owned the tribute territory before the war       |
| oldOwnerLabel   | string or nil | Label of the group that owned the tribute territory before the war      |

**rm\_gangs:client:onTributeEventFinished**

```lua
RegisterNetEvent('rm_gangs:client:onTributeEventFinished', function(data)
    print(data.name)
    print(data.label)
    print(data.paymentAmount)
    print(data.captureDuration)
    print(data.coords)
    print(json.encode(data.territory, {indent = true}))
    print(data.ownerName)
    print(data.ownerLabel)
    print(data.captureDate)
    print(data.oldOwnerName)
    print(data.oldOwnerLabel)
end)
```

| Key             | Type          | Description                                                             |
| --------------- | ------------- | ----------------------------------------------------------------------- |
| name            | string        | Tribute zone name in cfg file                                           |
| label           | string        | Tribute zone label in cfg file                                          |
| paymentAmount   | number        | Money that can be received during the time interval set in the cfg file |
| captureDuration | number        | Event duration in the cfg file                                          |
| coords          | vec4          | Coordinate of the tribute npc in the cfg file                           |
| territory       | table         | Tribute territory data in cfg file                                      |
| ownerName       | string or nil | Name of the new owner of the zone                                       |
| ownerLabel      | string or nil | Label of the new owner of the zone                                      |
| captureDate     | number or nil | Timestamp of the claim date                                             |
| oldOwnerName    | string or nil | Name of the group that owned the tribute territory before the war       |
| oldOwnerLabel   | string or nil | Label of the group that owned the tribute territory before the war      |

**rm\_gangs:client:onTurfWarStarted**

```lua
RegisterNetEvent('rm_gangs:client:onTurfWarStarted', function(data)
    print(data.id)
    print(data.initiatorName)
    print(data.initiatorLabel)
    print(data.targetName)
    print(data.targetLabel)
    print(data.startDate)
    print(data.finishDate)
end)
```

| Key            | Type   | Description                              |
| -------------- | ------ | ---------------------------------------- |
| id             | number | Turf war id                              |
| initiatorName  | string | Name of the group that started turf war  |
| initiatorLabel | string | Label of the group that started turf war |
| targetName     | string | Name of the group that owns the turf     |
| targetLabel    | string | Label of the group that owns the turf    |
| startDate      | number | Timestamp of the start date of turf war  |
| finishDate     | number | Timestamp of the end date of turf war    |

**rm\_gangs:client:onTurfWarFinished**

```lua
RegisterNetEvent('rm_gangs:client:onTurfWarFinished', function(data)
    print(data.id)
    print(data.initiatorName)
    print(data.initiatorLabel)
    print(data.targetName)
    print(data.targetLabel)
    print(data.startDate)
    print(data.finishDate)
    print(data.initiatorNewLoyalty)
    print(data.initiatorPersonCount)
    print(data.targetNewLoyalty)
    print(data.targetPersonCount)
    print(data.successful)
end)
```

| Key                  | Type    | Description                                                                             |
| -------------------- | ------- | --------------------------------------------------------------------------------------- |
| id                   | number  | Turf war id                                                                             |
| initiatorName        | string  | Name of the group that started turf war                                                 |
| initiatorLabel       | string  | Label of the group that started turf war                                                |
| targetName           | string  | Name of the group that owns the turf                                                    |
| targetLabel          | string  | Label of the group that owns the turf                                                   |
| startDate            | number  | Timestamp of the start date of turf war                                                 |
| finishDate           | number  | Timestamp of the end date of turf war                                                   |
| initiatorNewLoyalty  | number  | New loyalty points for the group that started the turf war                              |
| initiatorPersonCount | number  | Number of people alive at the end of the battle for the group that started the turf war |
| targetNewLoyalty     | number  | Turf owner's new loyalty points                                                         |
| targetPersonCount    | number  | Turf owner's number of people alive at the end of the turf war                          |
| successful           | boolean | Winning status of the side that started the turf war                                    |

**rm\_gangs:client:onWarReplied**

```lua
RegisterNetEvent('rm_gangs:client:onWarReplied', function(data)
    print(data.id)
    print(data.initiatorName)
    print(data.initiatorLabel)
    print(data.initiatorIdentifier)
    print(data.initiatorScore)
    print(data.targetName)
    print(data.targetLabel)
    print(data.targetIdentifier)
    print(data.targetScore)
    print(data.killGoal)
    print(data.wager)
    print(data.declareDate)
    print(data.acceptRejectDate)
    if data.accepted then
        print('accepted')
    else
        print('rejected')
    end
end)
```

| Key                 | Type    | Description                                                    |
| ------------------- | ------- | -------------------------------------------------------------- |
| id                  | number  | War id                                                         |
| initiatorName       | string  | Name of the group that declared the war                        |
| initiatorLabel      | string  | Label of the group that started war                            |
| initiatorIdentifier | string  | Identifier of the leader of the group that started the war     |
| initiatorScore      | number  | Score of the group that started the war                        |
| targetName          | string  | Name of the group that is the target of the war declaration    |
| targetLabel         | string  | Label of the group being declared war on                       |
| targetIdentifier    | string  | Identifier of the leader of the group declared at war          |
| targetScore         | number  | Score of the declared war group                                |
| killGoal            | number  | The killing goal of war                                        |
| wager               | number  | The amount of money set as a wager                             |
| accepted            | boolean | Indicates whether the group declared upon has accepted the war |
| declareDate         | number  | Timestamp of the declare date of war                           |
| acceptRejectDate    | number  | Timestamp of the reply date of war                             |

**rm\_gangs:client:onWarFinished**

```lua
RegisterNetEvent('rm_gangs:client:onWarFinished', function(data)
    print(data.id)
    print(data.initiatorName)
    print(data.initiatorLabel)
    print(data.initiatorIdentifier)
    print(data.initiatorScore)
    print(data.initiatorNewLoyalty)
    print(data.targetName)
    print(data.targetLabel)
    print(data.targetIdentifier)
    print(data.targetScore)
    print(data.targetNewLoyalty)
    print(data.killGoal)
    print(data.wager)
    print(data.declareDate)
    print(data.acceptRejectDate)
    print(data.finishDate)
end)
```

| Key                 | Type   | Description                                                 |
| ------------------- | ------ | ----------------------------------------------------------- |
| id                  | number | War id                                                      |
| initiatorName       | string | Name of the group that declared the war                     |
| initiatorLabel      | string | Label of the group that started war                         |
| initiatorIdentifier | string | Identifier of the leader of the group that started the war  |
| initiatorScore      | number | Score of the group that started the war                     |
| initiatorNewLoyalty | number | New loyalty point of the group that started the war         |
| targetName          | string | Name of the group that is the target of the war declaration |
| targetLabel         | string | Label of the group being declared war on                    |
| targetIdentifier    | string | Identifier of the leader of the group declared at war       |
| targetScore         | number | Score of the declared war group                             |
| targetNewLoyalty    | number | New loyalty point of the declared war group                 |
| killGoal            | number | The killing goal of war                                     |
| wager               | number | The amount of money set as a wager                          |
| declareDate         | number | Timestamp of the declare date of war                        |
| acceptRejectDate    | number | Timestamp of the reply date of war                          |
| finishDate          | number | Timestamp of the date the war ended                         |

## Exports <a href="#exports" id="exports"></a>

### Client Exports <a href="#server-exports" id="server-exports"></a>

**getPlayerGangInfo**

```lua
exports.rm_gangs:getPlayerGangInfo()

--Example:
local playerGang = exports.rm_gangs:getPlayerGangInfo()
print(playerGang)
```

**getCurrentGangZone**

```lua
exports.rm_gangs:getCurrentGangZone()

--Example:
local zone = exports.rm_gangs:getCurrentGangZone()
if zone then
    print(zone.name)
    print(zone.label)
    print(zone.color)
    print(zone.loyalty)
    print(zone.territory)
    print(zone.logoURL)
else
    print('current gang zone is nil')
end
```

**getCurrentTributeZone**

```lua
exports.rm_gangs:getCurrentTributeZone()

--Example:
local tributeZone = exports.rm_gangs:getCurrentTributeZone()
if tributeZone then
    print(zone.name)
    print(zone.label)
    print(zone.paymentAmount)
    print(zone.territory)
    print(zone.owner)
    print(zone.captureDate)
    print(zone.captureTimerLabel)
    print(zone.paymentResetTime)
else
    print('current tribute zone is nil')
end
```

### Server Exports <a href="#server-exports" id="server-exports"></a>

**getGangTributeZones**

```lua
exports.rm_gangs:getGangTributeZones(gangName --[[string]])

--Example:
local ownedZones = exports.rm_gangs:getGangTributeZones('ballas')
if ownedZones then
   for i=1, #ownedZones do
        print(ownedZones[i].name)
        print(ownedZones[i].label)
        print(ownedZones[i].paymentAmount)
        print(ownedZones[i].territory)
        print(ownedZones[i].owner)
        print(ownedZones[i].captureDate)
    end
else
    print('no owned zone')
end
```

**addLoyalty**

```lua
exports.rm_gangs:addLoyalty(gangName --[[string]], amount --[[number]])
```

**removeLoyalty**

```lua
exports.rm_gangs:removeLoyalty(gangName --[[string]], amount --[[number]])
```

**cancelTributeEvent**

```lua
exports.rm_gangs:cancelTributeEvent(zoneName --[[string]])
```
