> For the complete documentation index, see [llms.txt](https://wxn-studios.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://wxn-studios.gitbook.io/documentation/fivecraft-scripts/weapon-repairs/developer-api.md).

# Developer API

I built this resource with extensibility in mind. Whether you want to trigger the bench from your own script, add custom benches dynamically, or just understand how the code flows, this guide is for you.

## Exports

I've exposed the core functions so you can open the repair interface from anywhere—whether that's a job script, a housing menu, or a command.

### OpenBench

This is the main entry point. You can call this to force the UI open for a specific player.

```lua
-- @param entity (number): The object entity handle (the bench)
-- @param netId (number|nil): Network ID (optional, but I recommend passing it for server validation)

exports['FiveCraft-WeaponRepairs']:OpenBench(entity, netId)
```

Example usage:

{% code title="example.lua" %}

```lua
RegisterCommand('openrepair', function()
    local playerPed = PlayerPedId()
    local coords = GetEntityCoords(playerPed)
    local bench = GetClosestObjectOfType(coords.x, coords.y, coords.z, 5.0, `gr_prop_gr_bench_02a`, false, false, false)
    
    if bench ~= 0 then
        exports['FiveCraft-WeaponRepairs']:OpenBench(bench)
    else
        print("No bench nearby!")
    end
end)
```

{% endcode %}

### CloseBench

If you need to force-close the UI (e.g., player walks too far away, dies, or is cuffed), use this.

```lua
exports['FiveCraft-WeaponRepairs']:CloseBench()
```

## Wrapper System

I hate rewriting code for different frameworks, so I abstracted all the framework-specific logic into wrappers. If you're editing the code, you should use these instead of native calls.

* Notify(type, message, ...) (client/cl\_notifications.lua)\
  Why use it: It automatically handles translation and switches between Ox, ESX, and QB notifications based on the config.
* Progress(label, duration) (client/cl\_utils.lua)\
  Why use it: It respects the user's choice between a progress bar or a circle, and handles the animation/disable controls logic for you.
* ShowTextUI(text) / HideTextUI() (client/cl\_utils.lua)\
  Why use it: It cleanly manages the "Press E" prompt so you don't have overlapping UI elements.

## Dynamic Benches

One of the coolest features I added is the ability to use **any** prop as a repair station.

If you have a housing script (like `qs-housing` or `loaf_housing`) that lets players place furniture, you don't need to add coordinates to the config manually.

How to do it:

{% stepper %}
{% step %}

### Open the config

Open `shared/sh_config.lua`.
{% endstep %}

{% step %}

### Add the prop model

Add the prop model hash to `Config.Interaction.Models`.

```lua
Config.Interaction.Models = {
    `gr_prop_gr_bench_02a`,
    `prop_toolchest_01`, -- I just added this!
}
```

{% endstep %}
{% endstepper %}

That's it.

* If using **Target**: The script automatically adds the target option to all props of that model.
* If using **TextUI**: The proximity loop automatically detects when you're near that model and shows the "Press E" prompt.

## Localization (i18n)

I know communities are global, so I leaned heavily into `ox_lib`'s locale system.

If you want to add a language I haven't supported yet (like Italian or Portuguese):

{% stepper %}
{% step %}
Create a new file in `locales/` (e.g., `it.json`).
{% endstep %}

{% step %}
Copy the keys from `en.json`.
{% endstep %}

{% step %}
Translate the values.
{% endstep %}
{% endstepper %}

The script will automatically pick it up based on your server settings or `ox_lib` config.


---

# 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://wxn-studios.gitbook.io/documentation/fivecraft-scripts/weapon-repairs/developer-api.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.
