> For the complete documentation index, see [llms.txt](https://fjsf-scripts.gitbook.io/fjsf-scripts-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://fjsf-scripts.gitbook.io/fjsf-scripts-docs/scripts/fjsf_lib.md).

# FJSF\_LIB

`fjsf_lib` is a shared utility library for FiveM that provides reusable helpers and systems which can be used on both **client** and **server** side.

***

{% hint style="info" %}

### Download

### **Download for Free:** [https://fjsf-scripts.com](https://fjsf-scripts.com/)

{% endhint %}

***

### Installation

1. Download `fjsf_lib`
2. Place the folder into your resources directory, for example:

   ```
   resources/[libs]/fjsf_lib
   ```

***

### Server configuration

{% hint style="warning" %}

### `fjsf_lib` **must be ensured before any resource that uses it**.

{% endhint %}

Add this line to your `server.cfg`:

```cfg
ensure fjsf_lib
```

If another resource starts before `fjsf_lib`, its functions will not be available.

***

### Usage methods

There are **two supported ways** to use `fjsf_lib`.

***

### Method 1: Shared global access

This method exposes all library functions through a global `fjsf` table.

#### Setup

Add the following file to your resource:

```lua
@fjsf_lib/init.lua
```

Example `fxmanifest.lua`:

```lua
shared_scripts {
    '@fjsf_lib/init.lua'
}
```

#### Usage

```lua
fjsf.callbackCall('example:callback', 5000, function(result)
    print(result)
end)
```

```lua
local playerId, ped, coords, distance =
    fjsf.getClosestPlayer(GetEntityCoords(PlayerPedId()), 10.0, true)
```

***

### Method 2: Using exports

All functions are also available through exports.

#### Usage

```lua
exports['fjsf_lib']:callbackCall('example:callback', 5000, function(result)
    print(result)
end)
```

```lua
local playerId, ped, coords, distance =
    exports['fjsf_lib']:getClosestPlayer(coords, 10.0, true)
```
