# 🪛 Lock Picking

## INSTALLATION GUIDE

### Step 0 - First Steps

{% hint style="info" %}
**1.** Download your resource from [FiveM's Keymaster](https://keymaster.fivem.net/asset-grants)\
**2.** Unzip the `inside-lockpicking` folder and place this folder in your server's resource folder.\
**3.** Add the resource to your server start config (server.cfg): **ensure inside-lockpicking**\
If you are using a framework, it must be placed anywhere below your framework resource e.g., es\_extended, not above.

\
ensure es\_extended \
ensure inside-lockpicking
{% endhint %}

### Step 1 - Configure Resource

{% hint style="info" %}
You **MUST** read all configurable options inside th&#x65;**`[inside-lockpicking/config.lua]`** file and configure them to suit your server's needs.
{% endhint %}

## How do i use it?

You can start the lock picking by using the default settings.

```lua
-- Initiates the lockpicking minigame and stores the result
local result = exports['inside-lockpicking']:StartLockPicking()

-- Checks the result of the minigame
if result == 'success' then
    -- This section is executed if the player wins the minigame
    print('Congratulations, you succeeded!')
elseif result == 'fail' then
    -- This section is executed if the player loses the minigame
    print('Unfortunately, you did not succeed this time.')
end
```

**Example 2**

Or you can use the start the lock picking by sending customized settings in a table.

{% hint style="danger" %}
Remember to use item requirements, first configure config.lua correctly to check if the player has a given item.
{% endhint %}

{% code fullWidth="false" %}

```lua
-- Table with settings
local settings = {
    difficulty = 'hard', -- easy, medium, hard
    requiredItem = 'lockpick', -- item name
    requiredAmount = 1 -- quantity
}

-- Initiates the lockpicking minigame and stores the result
local result = exports['inside-lockpicking']:StartLockPicking(settings)

-- Checks the result of the minigame
if result == 'success' then
    -- This section is executed if the player wins the minigame
    print('Congratulations, you succeeded!')
elseif result == 'fail' then
    -- This section is executed if the player loses the minigame
    print('Unfortunately, you did not succeed this time.')
elseif result == 'no_item' then 
    -- If the player does not have a given number of items in the inventory
    print('You need the required item to start this minigame.')
end
```

{% endcode %}
