> 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/comunitarias/exports.md).

# EXPORTS

#### 4.1 Bridge multi-framework

`shared/bridge.lua` autodetecta ESX / QB / QBox. Expone:

**Server**

| Función                              | Descripción                                              |
| ------------------------------------ | -------------------------------------------------------- |
| `Bridge.GetPlayer(src)`              | `{ source, citizenid, charname, group }`                 |
| `Bridge.GetPlayers()`                | Lista unificada de todos los conectados                  |
| `Bridge.GetSourceFromCitizenId(cid)` | Source si está online, `nil` si no                       |
| `Bridge.GetOfflineByCitizenId(cid)`  | Lookup en BD del framework (QB: `players`, ESX: `users`) |
| `Bridge.IsAdmin(src)`                | Comprueba `Config.AdminGroup` en el framework activo     |
| `Bridge.Notify(src, data)`           | `ox_lib:notify` uniforme                                 |

**Client**

| Función                     | Descripción                                                    |
| --------------------------- | -------------------------------------------------------------- |
| `Bridge.OnPlayerLoaded(cb)` | Wrapper de `QBCore:Client:OnPlayerLoaded` / `esx:playerLoaded` |
| `Bridge.Notify(data)`       | `lib.notify`                                                   |

#### 4.2 Locales

`shared/locale.lua` expone la función global `L('key', ...)`. Cargas por defecto:

```lua
Locales['es'] = { condena_iniciada = 'Condena iniciada', … }
Locales['en'] = { condena_iniciada = 'Sentence started', … }
```

Añadir un idioma: crea `locales/xx.lua`, define `Locales['xx'] = { … }` y pon `Config.Locale = 'xx'`.

#### 4.3 Eventos

| Evento                            | Lado   | Payload            | Descripción                 |
| --------------------------------- | ------ | ------------------ | --------------------------- |
| `pv_comunitarias:client:Empezar`  | client | `(cantidad, zone)` | Inicia/actualiza la condena |
| `pv_comunitarias:client:Terminar` | client | —                  | Libera al jugador           |
| `pv_comunitarias:client:OpenMenu` | client | —                  | Abre el panel NUI           |

#### 4.4 Callbacks

| Callback                             | Lado   | Devuelve                                        |
| ------------------------------------ | ------ | ----------------------------------------------- |
| `pv_comunitarias:server:CheckOnLoad` | server | `{ remaining, zone }`                           |
| `pv_comunitarias:server:RestarTarea` | server | `newRemaining` (int)                            |
| `pv_comunitarias:nui:GetData`        | server | `{ activos, online, stats, locale, framework }` |
| `pv_comunitarias:nui:Assign`         | server | `{ ok, msg }`                                   |
| `pv_comunitarias:nui:Edit`           | server | `{ ok, msg }`                                   |
| `pv_comunitarias:nui:Remove`         | server | `{ ok, msg }`                                   |

#### 4.5 API server

Funciones globales expuestas por `server/main.lua`, útiles si quieres integrar el sistema con otros scripts (jueces, sentencias automáticas, etc):

```lua
-- Asignar (suma) o crear condena
local ok, msg, charname = AssignService(adminSrc, target, amount, 'assign')

-- Editar (sobreescribe el restante)
local ok, msg, charname = AssignService(adminSrc, target, amount, 'edit')

-- Quitar toda la condena
local ok, msg, charname = RemoveService(adminSrc, target)
```

`target` acepta **id online** (número) o **citizenid** (string). Los admin `adminSrc = 0` cuenta como consola.

#### 4.6 Formato de la tabla `pv_comunitarias`

| Columna       | Tipo           | Descripción                                                                |
| ------------- | -------------- | -------------------------------------------------------------------------- |
| `citizenid`   | VARCHAR(64) PK | Identificador del jugador (citizenid en QB/QBX, license/identifier en ESX) |
| `charname`    | VARCHAR(96)    | Nombre IC                                                                  |
| `remaining`   | INT            | Tareas que le quedan                                                       |
| `assigned`    | INT            | Tareas asignadas totales (para calcular progreso)                          |
| `zone`        | VARCHAR(64)    | Id de la zona en `Config.Zonas`                                            |
| `assigned_by` | VARCHAR(96)    | Nombre del admin que asignó                                                |
| `assigned_at` | TIMESTAMP      | Última vez que se asignó/editó                                             |


---

# 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/comunitarias/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.
