RiotService
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
Last updated