# Top Serveurs

## 🗳️ Top-Serveurs Vote System – In-Game Voting & Rewards

***

### ⚡ Getting Started

Players can vote for your server on [Top-Serveurs](https://top-serveurs.net) directly from in-game, and instantly receive configurable rewards.

***

### 💬 How to Open the Vote Menu

**1. By Command**

* Enabled by default (`Config.enable_command = true`)
* Players use the command set in `Config.command` (default: `/vote`)

**2. Client Event**

```lua
TriggerEvent("redrp-bt:showVoteUi")
```

**3. Server Event**

```lua
TriggerClientEvent("redrp-bt:showVoteUi", source)
```

***

### ⚙️ Configuration Example (`config.lua`)

```lua
Config = {}
Config.serverToken = "..." -- Your Top-Serveurs token
Config.serverURL = "https://top-serveurs.net/rdr/vote/your-server-name"

Config.DiscordWebhook   = ""        -- Discord webhook for staff notifications
Config.DiscordName      = "BT_TOPSERVER"
Config.enable_command   = true
Config.command          = "vote"
Config.enable_client_side  = true
Config.client_function  = 'redrp-bt:showVoteUi'
Config.NotifyAllPlayersOnVote = true -- Notify everyone when someone votes

-- Leaderboard config
Config.MaxVotersToDisplay = 5                -- Number of top voters in leaderboard
Config.LeaderboardRefreshInterval = 120      -- Minutes between leaderboard announcements

Config.Txt = {
    VoteForUs = "Vote for Western Raiders",
    AlreadyVoted = "Your vote has already been rewarded, thank you :)",
    WinMoneyGold = "Thank you for your vote, here is your reward: %d %s",
    WinWeapon = "Thank you for your vote, congratulations, here is a weapon: %s",
    WinItem = "Thank you for your vote, you have won: %d %s",
    VoteAgain = "You can vote again on Top-Serveurs",
    NotifyAll = "%s has voted for the server! (/vote)",
    LeaderBoardTitle = "**🏆 Top Voters Leaderboard 🏆**\n\n",
    LeaderBoardPlayer = "**%d.** `%s` — **%d votes**\n"
}
```

***

### 🎁 Rewards Structure

Set up your reward chances and prize pools in `Config.Prices`:

```lua
Config.Prices = {
    ["$"] = { chance = 40, min = 1, max = 3 },           -- 40% chance: Money (random amount)
    ["Gold"] = { chance = 30, min = 1, max = 2 },        -- 30% chance: Gold (random amount)
    ["Items"] = {
        chance = 15,
        ItemList = {
            ["ammoarrowdynamite"] = { label = "Dynamite Arrow", chance = 3, min = 1, max = 3 },
            -- ...many more (see config)
        }
    },
    ["Weapons"] = {
        chance = 10,
        WeaponList = {
            ["WEAPON_MELEE_TORCH"] = { label = "Torch", chance = 5 },
            -- ...many more (see config)
        }
    }
}
```

* **You can edit, remove, or add as many rewards as you want.**
* All labels and items/weapons must match your server’s inventory and database.

***

### 🏆 Leaderboard

* **Displays top voters in-game**
* Number of voters and refresh interval are configurable:
  * `Config.MaxVotersToDisplay`
  * `Config.LeaderboardRefreshInterval` (minutes)

***

### 🟧 Notification System

* **SendValidNotification:** Called when a player wins a reward.
* **SendErrorNotification:** Called when the player has already been rewarded for their vote.
* **SendInfoNotification:** Used for generic info (e.g., can vote again soon).
* **Discord Logging:** All votes/rewards can be logged to your Discord using your webhook.

***

### 📌 Notes

* All menu texts, reward messages, and notifications are configurable in `Config.Txt`.
* Notifying all players on each vote is enabled/disabled by `Config.NotifyAllPlayersOnVote`.
* No SQL setup is required for basic operation, but leaderboard or advanced logging may require persistent storage.
* For leaderboard and multi-vote support, ensure your identifiers and data saving logic are implemented correctly.


---

# 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://botiv.gitbook.io/rdr2/top-serveurs.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.
