> ## Documentation Index
> Fetch the complete documentation index at: https://docs.jaksam-scripts.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Allow or refuse a step

> Decide from your own script who can use a heist step, for example only the members of a party.

Called on the server every time a player tries to use a heist step (open a safe, hack a panel, grab a trolley, shoot a display case...), after the heist checks (police, cooldowns) and before anything happens. Return `false` and the step is refused: nothing is used, no item is taken and the heist doesn't start.

It's the place to plug in a party, gang or group script: allow a heist only to a registered party, or require a minimum number of members to start it.

```lua Function theme={null}
function canPlayerDoHeistStep(playerId, heistId, stageId, stepType, isStarting)
    return true
end
```

The function is at the bottom of `integrations/sv_integrations.lua`, edit it there. If you updated from an older version and kept your own `sv_integrations.lua`, paste it at the bottom of the file: without it every step is allowed, as before.

### Parameters

| Name | Data Type | Description |
| - | - | - |
| `playerId` | integer | Server ID of the player trying to use the step |
| `heistId` | integer | Heist ID |
| `stageId` | integer | Stage ID |
| `stepType` | string | The step type, see the [list of step types](https://docs.jaksam-scripts.com/robberies-creator/server/step-completed.md#step-types) |
| `isStarting` | boolean | `true` until the first step of the heist is completed, `false` when the heist is in progress |

### Return value

`true` to let the player use the step, `false` to refuse it. When you refuse it, tell the player why: the script shows nothing on its own.

## Example

```lua theme={null}
-- Hypothetical party script: only party members can use heist steps,
-- and a party needs at least 3 members to start a heist
function canPlayerDoHeistStep(playerId, heistId, stageId, stepType, isStarting)
    local partyId = exports["my_party"]:getPlayerParty(playerId)

    if(not partyId) then
        notify(playerId, "You need to be in a party")
        return false
    end

    if(isStarting and exports["my_party"]:getMembersCount(partyId) < 3) then
        notify(playerId, "Your party needs at least 3 members")
        return false
    end

    return true
end
```

`notify(playerId, text)` is the notification of the script, you can use it in this file.

> [!NOTE]
>
> The police count and the cooldowns are checked before your function. The required item of the step is checked right after it: a player without it is still refused, after you allowed them. A lost minigame doesn't start the heist, so `isStarting` stays `true` for the next attempt.

## Parties and groups

* **Progression is already shared.** A heist's progress belongs to the heist, not to a player: any player can do any step, and a step that's done (a hacked panel, an opened door, an emptied safe) is done for everyone. Party members can split the work without extra code
* **Rewards** go to the player who completes the step. To give something to the rest of the party, listen to the [Step completed](https://docs.jaksam-scripts.com/robberies-creator/server/step-completed.md) event: it tells you what the player received
* **Doors Creator** doors used in a heist are opened by Robberies Creator itself when the step is completed, so refusing a step here also keeps its doors closed


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.