# Letter Sequence

## ⚙️Installation

1. Download `vise_letter_sequence_game` resource from Cfx.re Keymaster
2. Extract `vise_letter_sequence_game` into your server's resources directory
3. Add `ensure vise_letter_sequence_game` to your `resources.cfg`

## 🕹️ Starting the Game

You can either **start the game through your own scripts** or use **the test command.**

**✅ Starting through your own scripts:**

```lua
local result = exports.vise_letter_sequence_game:start()

print('game ended with result:', result)
```

**✅ Using the test command:**

Type command `/test_vise_letter_sequence_game` in-game.

{% tabs %}
{% tab title="Video preview" %}
{% embed url="<https://youtu.be/VuuLLhcNqk4?t=11>" %}
Game can be seen at 0:11-0:26
{% endembed %}
{% endtab %}

{% tab title="Image preview" %}

<div><figure><img src="https://624746648-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3LzeOMV7JHxsxfU16ab1%2Fuploads%2FE39CXIAteS1A5gjVc9CH%2Fvise_letter_sequence_main.png?alt=media&#x26;token=0c676802-844d-417d-9765-b8e62ed318b4" alt=""><figcaption><p>Game main screen</p></figcaption></figure> <figure><img src="https://624746648-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3LzeOMV7JHxsxfU16ab1%2Fuploads%2FEdggGCDLeWakr2sjiu1l%2Fvise_letter_sequence_win.png?alt=media&#x26;token=47d30e03-ef1b-46f6-bd64-648466e92f9d" alt=""><figcaption><p>Success screen</p></figcaption></figure> <figure><img src="https://624746648-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3LzeOMV7JHxsxfU16ab1%2Fuploads%2FpcB81pZ5PTI9urpbOhU8%2Fvise_letter_sequence_loss.png?alt=media&#x26;token=e2f7cb56-2f0e-429a-acb8-e914b50e531d" alt=""><figcaption><p>Failure screen</p></figcaption></figure></div>
{% endtab %}
{% endtabs %}

🔄 **Result (return value)**

The `start()` function will return `true` if the player finishes the game, or `false` if they fail or run out of time.\
\
If you're using a **callback**, the same `true` or `false` will be passed into the callback function.

```lua
local result = exports.vise_letter_sequence_game:start()

if result then
    print('game completed')
else
    print('game failed')
end

-- You can also optionally use a callback to determine if game was completed or not
exports.vise_letter_sequence_game:start(settings, function(result)
    if result then
        print('game completed')
    else
        print('game failed')
    end
end)
```

## 🔧 Settings

When starting the game, you can pass a **settings table** to customize how the game works.

Here are the available setting options:

* `numberOfLetters` – How many letters to show *(default: 16)*
* `timeout` – How long (in seconds) the player has complete the game *(default: 8)*

**Example settings:**

<pre class="language-lua"><code class="lang-lua"><strong>local settings = {
</strong>    numberOfLetters = 16,
    timeout = 8,
}
</code></pre>

## 📦 Usage Examples

**Regular usage:**

```lua
local settings = {
    numberOfLetters = 16,
    timeout = 8,
}

local result = exports.vise_letter_sequence_game:start(settings)

if result then
    print('game completed')
else
    print('game failed')
end
```

**Callback usage:**

```lua
local settings = {
    numberOfLetters = 16,
    timeout = 8,
}

exports.vise_letter_sequence_game:start(settings, function(result)
    if result then
        print('game completed')
    else
        print('game failed')
    end
end)
```
