# Functions/Events

### client/editable-main.lua

#### `1.customHack(hackType)`

Initiates a hack based on the provided `hackType`.

The result (success or failure) of the minigame is passed to the `finishHack(success)` function.

#### Example:

```lua
customHack("cancelEscort")  -- Starts the "cancelEscort" hack
```

#### `2.cancelCustomHack()`

Cancels an active hack operation.

#### Functionality:

* This function stops the current minigame (if active) by calling `exports['boii_minigames']:cancel()`. You may need to replace this with your specific cancel method if different.

#### Example:

```lua
cancelCustomHack()  -- Cancels any active hack
```

#### `3.crossnotify(message, types)`

Sends a notification to the player based on the framework being used (`QB` or `ESX`).

#### Parameters:

* **`message`**: The notification message.
* **`types`**: The notification type (e.g., `"success"`, `"error"`).

#### Functionality:

* Uses `QBCore.Functions.Notify` for `qb-core` or `ESX.ShowNotification` for `ESX` to send the notification.

#### Example:

```lua
crossnotify("Hack successful!", "success")  -- Sends a success notification
```

### server/editable-main.lua

#### `1.skyheist:server:policeAlert`

Triggered when an alert needs to be sent to the police about a cargo plane heist.

* Sends a dispatch alert to on-duty police officers based on the configured dispatch system (`qs`, `cd`, `rcore`, `ps`, or `default`).
* Sends notifications via frameworks (QBCore or ESX) to on-duty police officers.
* Notifies the police using custom or default dispatch systems and updates the police with in-game notifications.

***

#### `2.skyheist:server:rewardItems`

Rewards the player with items after completing a heist.ayer the reward item based on the configuration.

Handles rare item drop chances and grants the player additional rare items based on the configured chance.

***

#### `3.skyheist:server:sellRewardItems`

Allows the player to sell their reward items for money.

* Counts the amount of reward items the player holds.
* Removes the items from the player's inventory and adds money based on the sell price of the item.
* Sends a notification with the total money earned from selling the items.
* Logs the transaction in Discord.

***

### Helper Functions

#### `1.giveItem(src, itemName, cnt)`

Adds the specified item to the player's inventory.

#### `2.removeItem(src, itemName, cnt)`

Removes the specified item from the player's inventory.

#### `3.countItem(src, itemName)`

Returns the amount of the specified item in the player's inventory.

***

### Example of Dispatch Systems

1. **QS Dispatch**: Sends a detailed alert using QS-Dispatch.
2. **CD Dispatch**: Uses `cd_dispatch` for player notifications.
3. **RCore Dispatch**: Sends alerts using `rcore_dispatch`.
4. **PS Dispatch**: Sends a notification to law enforcement.
5. **Default Dispatch**: Sends a basic message in the chat.

***

### Notes

* Make sure the correct inventory and dispatch systems are configured in `Config`.
* All dispatch systems require proper event handlers to trigger notifications and blips.
* The `skyheist:server:rewardItems` event ensures that players only loot once per instance.


---

# 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://enyo-scripts.gitbook.io/documentations/fivem-scripts/sky-heist/functions-events.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.
