> For the complete documentation index, see [llms.txt](https://bros-development.gitbook.io/documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://bros-development.gitbook.io/documentation/scripts/brosdev-safezonecreator/exports-and-events.md).

# 📤 Exports & Events

**BrosDev-SafeZoneCreator includes a full export system that allows other resources to interact directly with the safe zone system.**\
These exports can be used for:

* Creating zones dynamically
* Checking player zone status
* Reading active restrictions
* Managing zone data programmatically
* Integrating safe zones into other scripts
* Building custom gameplay systems around zones

***

### 🖥️ Server-Side Exports

#### 📍 Create Zone

Create a new safe zone programmatically.

```lua
local zoneId = exports['BrosDev-SafeZoneCreator']:CreateZone(data)
```

**Example**

```lua
local zoneId = exports['BrosDev-SafeZoneCreator']:CreateZone({
    name = "Custom Zone",
    points = {
        vector2(100.0, 200.0),
        vector2(120.0, 220.0),
        vector2(140.0, 210.0),
    },
    minZ = 20.0,
    maxZ = 80.0,
    restrictions = {
        disablePvP = true,
        disableShooting = true,
    },
})
```

***

#### 🗑️ Delete Zone

Remove an existing safe zone.

```lua
local success = exports['BrosDev-SafeZoneCreator']:DeleteZone(zoneId)
```

***

#### ✏️ Update Zone

Update an existing zone’s configuration or data.

```lua
local success = exports['BrosDev-SafeZoneCreator']:UpdateZone(zoneId, data)
```

***

#### 📊 Get All Zones

Retrieve all zones from the database.

```lua
local zones = exports['BrosDev-SafeZoneCreator']:GetAllZones()
```

***

#### 👤 Check Player Inside Zone

Check if a player is inside a specific zone.

```lua
local inside = exports['BrosDev-SafeZoneCreator']:IsPlayerInZone(playerId, zoneId)
```

***

#### 📍 Get Player Current Zone

Get the zone a player is currently inside.

```lua
local zoneId = exports['BrosDev-SafeZoneCreator']:GetPlayerCurrentZone(playerId)
```

***

#### 🛡️ Check Zone Bypass

Check if a player is bypassing zone restrictions.

```lua
local bypass = exports['BrosDev-SafeZoneCreator']:ShouldPlayerBypass(playerId, zoneId)
```

***

### 🎮 Client-Side Exports

#### 📊 Check If Player Is In Any Zone

Returns whether the local player is inside a safe zone.

```lua
local inZone = exports['BrosDev-SafeZoneCreator']:IsPlayerInAnyZone()
```

***

#### 📍 Get Current Zone

Returns the current zone data.

```lua
local zone = exports['BrosDev-SafeZoneCreator']:GetCurrentZone()
```

***

#### 🚫 Check Specific Restriction

Check if a restriction is active.

```lua
local restricted = exports['BrosDev-SafeZoneCreator']:IsRestricted('disablePvP')
```

***

#### 📋 Get Active Restrictions

Returns all active restrictions in current zone.

```lua
local restrictions = exports['BrosDev-SafeZoneCreator']:GetActiveRestrictions()
```

***

#### ⏱️ Check Cooldown State

Check if player is under exit cooldown.

```lua
local cooldown = exports['BrosDev-SafeZoneCreator']:IsInCooldown()
```

***

#### 📍 Check Zone by ID

Check if player is inside a specific zone.

```lua
local inZone = exports['BrosDev-SafeZoneCreator']:IsInZone(zoneId)
```

***

#### 🧭 Open Admin Panel

Open the safe zone admin panel manually.

```lua
exports['BrosDev-SafeZoneCreator']:OpenAdminPanel()
```

***

### 🔄 Example Integrations

#### Open Admin Panel via Command

```lua
RegisterCommand('safezones', function()
    exports['BrosDev-SafeZoneCreator']:OpenAdminPanel()
end)
```

***

#### Check Player Zone on Spawn

```lua
AddEventHandler('playerSpawned', function()
    local zone = exports['BrosDev-SafeZoneCreator']:GetCurrentZone()

    if zone then
        print('Player spawned inside zone: ' .. zone.name)
    end
end)
```

***

#### Custom Safe Zone Logic

```lua
CreateThread(function()
    while true do
        Wait(5000)

        local zone = exports['BrosDev-SafeZoneCreator']:GetCurrentZone()

        if zone and zone.restrictions.disablePvP then
            print("PvP is disabled in current zone")
        end
    end
end)
```

***

### ⚠️ Notes

* Most exports are **server-side only unless specified**
* Zone IDs must be valid and exist in database
* Resource name must remain exactly:

  ```
  BrosDev-SafeZoneCreator
  ```
* Renaming the folder will break exports unless updated manually
* Always ensure `ox_lib` is running before using detection-based exports

***
