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

# Hustling

## Exports

`Randolio: Hustling` provides a set of client-side exports that allow other resources to start, cancel, and check the status of a player's hustle session.

These exports can be used to integrate the hustling system with other scripts, menus, NPCs, jobs, or custom UI.

***

### Available Exports

| Export               | Description                                                                 |
| -------------------- | --------------------------------------------------------------------------- |
| `startHustleRun`     | Starts a standard money hustle run                                          |
| `startDrugHustleRun` | Starts a drug hustle run                                                    |
| `cancelHustleRun`    | Cancels the player's current hustle session                                 |
| `isPlayerHustling`   | Returns whether the player is currently hustling and the active hustle type |

***

## `startHustleRun`

Starts a standard **money hustle** session.

The hustle system will request a new run from the server, select a location, and begin the hustle route.

### Usage

```lua
exports.randol_hustling:startHustleRun()
```

### Returns

```lua
boolean
```

Returns:

* `true` — The hustle run successfully started.
* `false` — The run could not be started.

### Possible Failure Reasons

The export can fail if:

* The player already has an active hustle session.
* The player is currently on cooldown.
* No valid hustle locations are available.
* The player does not have sufficient funds to start the run.

### Example

```lua
local started = exports.randol_hustling:startHustleRun()

if started then
    print('Hustle run started!')
else
    print('Unable to start hustle run.')
end
```

### What Happens When Started?

Once successfully started:

1. A hustle session is created.
2. The session type is set to `money`.
3. The hustle HUD is displayed.
4. The player is given the first hustle location.
5. The player is instructed to drive to the selected location.

***

## `startDrugHustleRun`

Starts a **drug hustle** session.

This works similarly to `startHustleRun`, but uses the drug hustle system and validates that the player has the required drugs.

### Usage

```lua
exports.randol_hustling:startDrugHustleRun()
```

### Returns

```lua
boolean
```

Returns:

* `true` — The drug hustle successfully started.
* `false` — The run could not be started.

### Possible Failure Reasons

The export can fail if:

* The player already has an active hustle session.
* The player is currently on drug hustle cooldown.
* No valid hustle locations are available.
* The player does not have enough of the required drug.
* The configured drug is invalid.

### Example

```lua
local started = exports.randol_hustling:startDrugHustleRun()

if started then
    print('Drug hustle started!')
else
    print('Unable to start drug hustle.')
end
```

### What Happens When Started?

Once successfully started:

1. A hustle session is created.
2. The session type is set to `drug`.
3. The hustle HUD is displayed.
4. The first hustle location is selected.
5. The player is instructed to drive to the location.
6. The configured drug label is passed to the hustle point.

***

## `cancelHustleRun`

Cancels the player's currently active hustle session.

### Usage

```lua
exports.randol_hustling:cancelHustleRun()
```

### Returns

```lua
boolean
```

Returns:

* `true` — The cancellation request was successfully sent.
* `false` — The player does not currently have an active hustle session.

### Example

```lua
local cancelled = exports.randol_hustling:cancelHustleRun()

if cancelled then
    print('Hustle run cancelled.')
else
    print('There is no active hustle run.')
end
```

### Important

This export triggers the following server event:

```lua
randol_hustle:cancelRun
```

The cancellation is therefore handled server-side.

***

## `isPlayerHustling`

Checks whether the player currently has an active hustle session.

This is useful when another resource needs to determine whether the player is currently doing a hustle run.

### Usage

```lua
local active, hustleType = exports.randol_hustling:isPlayerHustling()
```

### Returns

The export returns **two values**:

```lua
active, hustleType
```

#### `active`

A boolean indicating whether the player currently has an active hustle session.

```lua
true
```

or

```lua
false
```

#### `hustleType`

The type of the current hustle session.

Possible values are:

```lua
'money'
```

or

```lua
'drug'
```

If the player is not currently hustling, the hustle type may be `nil`.

### Example

```lua
local active, hustleType = exports.randol_hustling:isPlayerHustling()

if active then
    print(('Player is currently doing a %s hustle.'):format(hustleType))
else
    print('Player is not currently hustling.')
end
```

***

## Integration Examples

### Custom Menu

You can use the exports inside your own menu system.

```lua
local active = exports.randol_hustling:isPlayerHustling()

if not active then
    exports.randol_hustling:startHustleRun()
end
```

***

### Start a Drug Hustle From Another Resource

```lua
RegisterCommand('drughustle', function()
    local active = exports.randol_hustling:isPlayerHustling()

    if active then
        print('You are already hustling.')
        return
    end

    exports.randol_hustling:startDrugHustleRun()
end)
```

***

### Check the Current Hustle Type

```lua
local active, hustleType = exports.randol_hustling:isPlayerHustling()

if active and hustleType == 'money' then
    print('Player is running a money hustle.')
elseif active and hustleType == 'drug' then
    print('Player is running a drug hustle.')
end
```

***

### Cancel From Another Resource

```lua
exports.randol_hustling:cancelHustleRun()
```
