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

# EXPORTS

#### 4.1 Bridge editable

`bridge/server.lua` y `bridge/client.lua` están en `escrow_ignore` (editables sin desencriptar).

**Server**

| Función           | Descripción                                            |
| ----------------- | ------------------------------------------------------ |
| `PV_IsAdmin(src)` | ACE `pv_safezones.admin` o pertenencia a `AdminGroups` |

**Client**

| Función                | Descripción                     |
| ---------------------- | ------------------------------- |
| `PV_Notify(msg, kind)` | Notificación uniforme (ox\_lib) |

#### 4.2 Exports

**Servidor**

| Export                             | Descripción                |
| ---------------------------------- | -------------------------- |
| `exports.pv_safezones:GetZones()`  | Devuelve `{ [id] = zone }` |
| `exports.pv_safezones:GetZone(id)` | Una zona por id            |

**Cliente**

| Export                                    | Descripción                           |
| ----------------------------------------- | ------------------------------------- |
| `exports.pv_safezones:OpenAdmin()`        | Abre `/safezoneadmin`                 |
| `exports.pv_safezones:CurrentZoneId()`    | id de la zona en la que estás (o nil) |
| `exports.pv_safezones:IsInsideSafezone()` | bool rápido                           |

#### 4.3 Ejemplos

**Bloquear el uso de un item si el player está en zona segura**

```lua
-- server
exports.ox_inventory:registerHook('usingItem', function(payload)
    -- consulta al cliente si está dentro
    -- (opción rápida: pásalo por statebag o expone un callback en tu propio bridge)
end)
```

**Contar cuántos players hay dentro de una zona (cliente)**

```lua
-- client (aprox, usando GetActivePlayers y el export CurrentZoneId de cada player si sincronizas)
-- variante simple: solo el jugador local sabe si está dentro
if exports.pv_safezones:IsInsideSafezone() then
    print('Estoy en zona segura #' .. exports.pv_safezones:CurrentZoneId())
end
```

**Añadir tu propia regla custom**

1. En `config.lua`, añade a `PVConfig.RuleTypes`:

   ```lua
   { key = 'noRadio', label = 'Sin radio', icon = 'walkie-talkie', desc = 'Bloquea el pulsador de radio' },
   ```
2. En `PVConfig.DefaultRules = { ..., noRadio = false }`.
3. En `client/main.lua`, dentro de `applyRulesTick(zone)`:

   ```lua
   if r.noRadio then DisableControlAction(0, 249, true) end  -- push-to-talk
   ```

Se guarda solo en el JSON `rules`, sin migración SQL.

#### 4.4 Formato de la tabla `pv_safezones`

| Columna        | Tipo        | Descripción                                                                          |
| -------------- | ----------- | ------------------------------------------------------------------------------------ |
| `id`           | INT PK      | auto                                                                                 |
| `label`        | VARCHAR     | Nombre                                                                               |
| `description`  | TEXT        | Descripción libre                                                                    |
| `active`       | TINYINT     | 1 = enabled                                                                          |
| `shape_type`   | VARCHAR     | `circle` \| `polygon`                                                                |
| `center_x/y/z` | FLOAT       | Centro (o centroide en polígono, calculado auto)                                     |
| `radius`       | FLOAT       | Radio si es círculo                                                                  |
| `vertices`     | TEXT (JSON) | `[{x,y,z}]` si polígono                                                              |
| `rules`        | TEXT (JSON) | `{noWeapons:true, ...}`                                                              |
| `display`      | TEXT (JSON) | `{color, hudText, hudIcon, hudPosition, showBlip, blipSprite, blipColor, areaAlpha}` |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.privalo.dev/scripts/essentials/safe-zones-creator/exports.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
