> For the complete documentation index, see [llms.txt](https://docs.otherplanet.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.otherplanet.dev/scripts/op-gangs/exports/server-side.md).

# Server Side

{% hint style="warning" %}
If you're looking for Other Data then listed Here and in Client-Side Exports - Feel free to contact us on our [Discord Server](https://discord.gg/otherplanet)!
{% endhint %}

## addMapBlip

Add blip to all gang members into Crime Tablet

```lua
exports['op-crime']:addMapBlip(blipUniqueName, data)
```

#### Parameters

* `blipUniqueName: string`
* `data: table`

Example usage:

```lua
local ok, err = exports['op-crime']:addMapBlip("my_blip", {
    label       = "Drug Dealer",
    description = "Sells everything from coke to fentanyl",
    coords      = vec3(123.4, 567.8, 30.0),
    icon        = "skull",          -- Google Icons
    color       = "#ff4b3a",        -- Blip Color
})
```

## removeMapBlip

Removes blip from Crime Tablet by unique id

```lua
exports['op-crime']:removeMapBlip(blipUniqueName)
```

#### Parameters

* `blipUniqueName: string`

Example usage:

```lua
exports['op-crime']:removeMapBlip("my_blip")
```

## CreateGang

Create new organisation/gang and return created organisation index.

```lua
exports['op-crime']:CreateGang(data, cb)
```

#### Parameters

* `data: table`
* `cb: function`

***

### Data Object

* `orgLabel: string`
* `rankName: string`
* `color: string`
* `graffitiUrl: string`
* `shellValue: string|number`
* `isInteriorMode: shell | ipl | mlo`
* `garageCoords: table`
  * `x: number`
  * `y: number`
  * `z: number`
  * `w: number`
* `entranceCoords: table`
  * `x: number`
  * `y: number`
  * `z: number`
  * `w: number`
* `bossmenuCoords: table`
  * `x: number`
  * `y: number`
  * `z: number`
* `stashCoords: table`
  * `x: number`
  * `y: number`
  * `z: number`
* `cloakRoomCoords: table`
  * `x: number`
  * `y: number`
  * `z: number`
* `newOwner: table`
  * `identificator: string`

***

### Callback Response

* `status: boolean`
* `jobIndex: number`
* `message: string?`

***

### Example Usage

```lua
exports['op-crime']:CreateGang({
    orgLabel = "Ballas",
    rankName = "Boss",
    color = "#7d3cff",
    graffitiUrl = "https://your-image-url.com/graffiti.png",
    shellValue = "shell_highend",
    isInteriorMode = "shell", -- shell / ipl / mlo
    garageCoords = {
        x = 124.25,
        y = -1942.11,
        z = 20.75,
        w = 180.0
    },

    entranceCoords = {
        x = 118.91,
        y = -1961.22,
        z = 20.75,
        w = 92.0
    },

    bossmenuCoords = {
        x = 112.40,
        y = -1955.10,
        z = 20.75
    },

    stashCoords = {
        x = 110.20,
        y = -1953.30,
        z = 20.75
    },

    cloakRoomCoords = {
        x = 114.70,
        y = -1951.60,
        z = 20.75
    },

    newOwner = {
        identificator = "license:123456789abcdef"
    }
}, function(response)
    if response.status then
        print("Organisation created with index:", response.jobIndex)
    else
        print("Failed to create organisation:", response.message or "unknown_error")
    end
end)
```

***

### Notes

* Export returns `jobIndex` immediately after organisation creation.
* Owner assignment and additional sync actions are processed in background.
* This export can be safely used by external resources.

### EditGang

***

Edit existing organisation/gang and return edited organisation index.

* data: `table`
* cb: `function`

Data Object:

* editOrgIndex: `number|string`
* orgLabel: `string`
* rankName: `string`
* color: `string`
* graffitiUrl: `string`
* shellValue: `string|number`
* isInteriorMode: `string` — shell / ipl / mlo
* garageCoords: `table`
* entranceCoords: `table`
* bossmenuCoords: `table`
* stashCoords: `table`
* cloakRoomCoords: `table`
* oldOwner: `table` optional
* newOwner: `table` optional

Callback Response:

* status: `boolean`
* jobIndex: `number`
* message: `string` optional

Example usage:

```lua
exports['op-crime']:EditGang({
    editOrgIndex = 1,
    orgLabel = "Ballas",
    rankName = "Boss",
    color = "#7d3cff",
    graffitiUrl = "https://your-image-url.com/graffiti.png",
    shellValue = "shell_highend",
    isInteriorMode = "shell",

    garageCoords = {
        x = 124.25,
        y = -1942.11,
        z = 20.75,
        w = 180.0
    },
    entranceCoords = {
        x = 118.91,
        y = -1961.22,
        z = 20.75,
        w = 92.0
    },
    bossmenuCoords = {
        x = 112.40,
        y = -1955.10,
        z = 20.75
    },
    stashCoords = {
        x = 110.20,
        y = -1953.30,
        z = 20.75
    },
    cloakRoomCoords = {
        x = 114.70,
        y = -1951.60,
        z = 20.75
    },
    oldOwner = {
        identificator = "license:oldowneridentifier"
    },
    newOwner = {
        identificator = "license:newowneridentifier"
    }
}, function(response)
    if response.status then
        print("Organisation edited with index:", response.jobIndex)
    else
        print("Failed to edit organisation:", response.message or "unknown_error")
    end
end)
```

Notes:

* If `oldOwner` and `newOwner` are provided and their identifiers are different, the owner will be changed automatically.
* If `oldOwner` or `newOwner` is not provided, owner change will be skipped.
* Online members of the edited organisation will be synced automatically.
* This export can be safely used by external resources.

## getOrganisationsList

***

Return object

* identifier: `number`
* label: `string`

```lua
exports['op-crime']:getOrganisationsList()
```

## isTurfZoneInRivalry

***

Return false or true.

```lua
exports['op-crime']:isTurfZoneInRivalry(turfId)
```

## isPlayerTurfOwner

***

Return false or true.

```lua
exports['op-crime']:isPlayerTurfOwner(playerId, turfId)
```

## getPlayerTurfZone

***

Return index of player turf zone or nil. Useful for drugs selling script integrations.

```lua
exports['op-crime']:getPlayerTurfZone(source)
```

## getPlayerOrganisation

***

Return player organisation data object.

```lua
exports['op-crime']:getPlayerOrganisation(identifier)
```

* identifier: `string`<br>

Data Object:

* orgIndex: `number`
* player: `table`
  * identifier: `string`
  * totalTime: `string`
  * rank: `string`
  * status: `string`
* orgData: `table`

## getOrganisation

***

Return organisation object.

```lua
exports['op-crime']:getOrganisation(id)
```

* id: `number`

***

## Server Side Events:

Add Organisation EXP

```lua
op-crime:addOrganisationEXP
```

Data:

* `orgId`: number;
* `amount`: number;

Example usage:

```lua
TriggerEvent('op-crime:addOrganisationEXP', 5, 250)
```

***

Add Organisation Money

```
op-crime:addOrganisationMoney
```

Data:

* `orgId`: number;
* `amount`: number;
* `account`: string; (balance/dirtymoney)

Example usage:

```lua
TriggerEvent('op-crime:addOrganisationMoney', 5, 100000, "dirtymoney")
```

***

Remove Organisation Money

```
op-crime:removeOrganisationMoney
```

Data:

* `orgId`: number;
* `amount`: number;
* `account`: string; (balance/dirtymoney)

Example usage:

```lua
TriggerEvent('op-crime:removeOrganisationMoney', 5, 50000, "balance")
```

***

Add Organisation Missions Done

```
op-crime:addOrgMissionsDone
```

Data:

* `orgId`: number;
* `amount`: number;

Example usage:

```lua
TriggerEvent('op-crime:addOrgMissionsDone', 5, 15)
```

***

Add Organisation Zones Captured

```
op-crime:addZonesCaptured
```

Data:

* `orgId`: number;
* `amount`: number;

Example usage:

```lua
TriggerEvent('op-crime:addZonesCaptured', 5, 8)
```

***

## Zone Captured Event

`AddEventHandler('op-crime:zoneCaptured', newOrgId, oldOrgId, ZoneConfig)`

This is server-side event which is called when PVP zone is properly captured.

## decreaseSelected

***

Decrease Selected gang loyality in selected turf zone

```lua
exports['op-crime']:decreaseSelected(jobId, decreaseAmount, turfIndex)
```

* jobId: `string`
* decreaseAmount: `number`
* turfIndex: `string`<br>

## increaseSelected

***

Increase Selected gang loyality in selected turf zone

```lua
exports['op-crime']:increaseSelected(jobId, amount, turfIndex)
```

* jobId: `string`
* amount: `number`
* turfIndex: `string`<br>

## increaseZoneLoyality

***

Increase Selected gang loyality in selected turf zone and decrease every other gang loyality in this zone

```lua
exports['op-crime']:increaseZoneLoyality(jobId, amount, turfIndex, decreaseAmount)
```

* jobId: `string`
* amount: `number`
* turfIndex: `string`
* decreaseAmount: `number`<br>
