> ## Documentation Index
> Fetch the complete documentation index at: https://zyra-store.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Exports de Zyra Fuel: referencia completa

> Referencia de exports cliente y servidor de Zyra Fuel: GetFuel, SetFuel, RefuelVehicle, GetStationPrice y SetStationPrice con ejemplos.

Zyra Fuel expone funciones tanto en cliente como en servidor para que otros scripts puedan consultar y modificar el nivel de combustible y los precios de las gasolineras. A continuacion se documentan todas las exports disponibles.

## Client Exports

### `GetFuel`

Devuelve el porcentaje actual de combustible de un vehiculo.

```lua theme={null}
local fuel = exports.zyra_fuel:GetFuel(vehicle)
```

| Parametro | Tipo | Descripcion |
| - | - | - |
| `vehicle` | integer | Handle del vehiculo (entidad de FiveM). |

**Retorno:** `number` (0.0 a 100.0) o `nil` si el vehiculo no es valido.

**Ejemplo:**

```lua client/example_getfuel.lua theme={null}
local vehicle = GetVehiclePedIsIn(PlayerPedId(), false)
local fuel = exports.zyra_fuel:GetFuel(vehicle)
if fuel and fuel < 20.0 then
    print('Tienes poco combustible: ' .. string.format('%.1f', fuel) .. '%')
end
```

### `SetFuel`

Establece el nivel de combustible de un vehiculo a un valor concreto.

```lua theme={null}
exports.zyra_fuel:SetFuel(vehicle, level)
```

| Parametro | Tipo | Descripcion |
| - | - | - |
| `vehicle` | integer | Handle del vehiculo. |
| `level` | number | Nuevo porcentaje de combustible (0.0 a 100.0). |

**Ejemplo:**

```lua client/example_setfuel.lua theme={null}
local vehicle = GetVehiclePedIsIn(PlayerPedId(), false)
exports.zyra_fuel:SetFuel(vehicle, 100.0)
exports.zyra_notify:Notify('Deposito llenado al 100%', 'success')
```

### `RefuelVehicle`

Inicia el proceso de repostaje en un vehiculo con una cantidad especifica de litros.

```lua theme={null}
exports.zyra_fuel:RefuelVehicle(vehicle, liters)
```

| Parametro | Tipo | Descripcion |
| - | - | - |
| `vehicle` | integer | Handle del vehiculo. |
| `liters` | number | Litros a repostar (limitado por capacidad del deposito). |

**Ejemplo:**

```lua client/example_refuel.lua theme={null}
local vehicle = GetVehiclePedIsIn(PlayerPedId(), false)
exports.zyra_fuel:RefuelVehicle(vehicle, 15.0)
-- El jugador vera la animacion de manguera y la UI de progreso
```

## Server Exports

### `GetStationPrice`

Obtiene el precio por litro configurado para una estacion.

```lua theme={null}
local price = exports.zyra_fuel:GetStationPrice(stationId)
```

| Parametro | Tipo | Descripcion |
| - | - | - |
| `stationId` | string | Identificador de la estacion (ej. `'ruta_68_norte'`). |

**Retorno:** `number` (precio por litro) o `nil` si la estacion no existe.

**Ejemplo:**

```lua server/example_getprice.lua theme={null}
RegisterCommand('preciogasolina', function(source, args)
    local station = args[1] or 'default'
    local price = exports.zyra_fuel:GetStationPrice(station)
    if price then
        TriggerClientEvent('chat:addMessage', source, {
            args = { 'Zyra Fuel', 'Precio en ' .. station .. ': $' .. price .. '/L' }
        })
    end
end, false)
```

### `SetStationPrice`

Modifica el precio por litro de una estacion en tiempo real.

```lua theme={null}
exports.zyra_fuel:SetStationPrice(stationId, newPrice)
```

| Parametro | Tipo | Descripcion |
| - | - | - |
| `stationId` | string | Identificador de la estacion. |
| `newPrice` | number | Nuevo precio por litro. Debe ser mayor que 0. |

**Ejemplo:**

```lua server/example_setprice.lua theme={null}
-- Duplica el precio de todas las estaciones durante un evento de escasez
RegisterCommand('escasez', function(source, args)
    for stationId, _ in pairs(Config.GasStations) do
        local current = exports.zyra_fuel:GetStationPrice(stationId)
        if current then
            exports.zyra_fuel:SetStationPrice(stationId, current * 2.0)
        end
    end
    TriggerClientEvent('zyra_notify:client:Notify', -1, 'Escasez de combustible: precios duplicados.', 'error')
end, true)
```

> [!NOTE]
>
> Si tienes `oxmysql` activo, `SetStationPrice` persiste el nuevo precio en la base de datos y sobrevive a reinicios del servidor.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.