# RiotService

```lua
local Riot = {}
local Stellar = shared.Stellar

local Players = game:GetService("Players")

local PlayerRegistered = Stellar.Get("SignalProvider"):Get("PlayerRegistered")
local InventoryService = Stellar.Get("InventoryService")
local AlarmService = Stellar.Get("AlarmService")

local RiotWeapons = {
    "AK-74u",
    "G18",
}

shared.RiotInProgress = false

local QueuedRiots = {}

function Riot:_GetNextRiot()
    if #QueuedRiots > 0 then
        local userId = QueuedRiots[1]
        local _, possibleErr = pcall(function()
            if Players:GetPlayerByUserId(userId) then
                Riot:Start(Players:GetPlayerByUserId(userId))
                table.remove(QueuedRiots, 1)
            else
                table.remove(QueuedRiots, 1)
                Riot:_GetNextRiot()
            end
        end)
        if possibleErr then
            warn(possibleErr)
        end
    else
        shared.RiotInProgress = false
    end
end

function Riot:Start(player, bought)
    if shared.RiotInProgress and bought then
        table.insert(QueuedRiots, player.UserId)
        return false
    end

    shared.RiotInProgress = true
    for _, v in pairs(game.Teams["Class - D"]:GetPlayers()) do
        Riot:_GiveRiotLoadout(v)
    end
    AlarmService:TriggerAlarm("riot")

    task.delay(7 * 60, function()
        AlarmService:StopAlarm("riot")
        shared.RiotInProgress = false
        Riot:_GetNextRiot()
    end)
    return true
end

function Riot:_GiveRiotLoadout(player)
    pcall(function()
        for _, v in RiotWeapons do
            InventoryService:GiveTempTool(player, v)
        end
    end)
end

function Riot:Init()
    PlayerRegistered:Connect(function(player)
        player.CharacterAdded:Connect(function()
            if player.Team.Name == "Class - D" and shared.RiotInProgress then
                task.delay(0.2, function()
                    Riot:_GiveRiotLoadout(player)
                end)
            end
        end)
    end)
end

return Riot
```


---

# 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://stellardocs.bulkgames.us/examples/riotservice.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.
