# 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)
```


---

# Agent Instructions: 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:

```
GET https://fjsf-scripts.gitbook.io/fjsf-scripts-docs/scripts/fjsf_lib.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
