minor improvement

This commit is contained in:
EternityDev 2024-04-13 09:00:52 +07:00
parent 4cd0f3f2cf
commit 0fb349fe0f

View file

@ -47,6 +47,9 @@ local queueOutRequest: {
local logger: { local logger: {
[string]: boolean [string]: boolean
} = {} } = {}
local players: {
Player
} = {}
queueInRequest[1] = {} queueInRequest[1] = {}
queueInRequest[2] = {} queueInRequest[2] = {}
@ -58,6 +61,7 @@ local UnreliableEvent = Event.Unreliable
local RequestEvent = Event.Request local RequestEvent = Event.Request
local function initializeEachPlayer(player: Player) local function initializeEachPlayer(player: Player)
players = Players:GetPlayers()
if not player then return end if not player then return end
if not queueOut[player] then if not queueOut[player] then
queueOut[player] = {} queueOut[player] = {}
@ -85,6 +89,9 @@ local function initializeEachPlayer(player: Player)
end end
Players.PlayerAdded:Connect(initializeEachPlayer) Players.PlayerAdded:Connect(initializeEachPlayer)
Players.PlayerRemoving:Connect(function()
players = Players:GetPlayers()
end)
function ServerProcess.insertQueue(Identifier: string, reliable: boolean, player: Player, ...: any) function ServerProcess.insertQueue(Identifier: string, reliable: boolean, player: Player, ...: any)
if not reliable then if not reliable then
@ -190,8 +197,8 @@ function ServerProcess.start()
table.clear(data) table.clear(data)
end end
end end
for _, player: Player in ipairs(Players:GetPlayers()) do for _, player: Player in ipairs(players) do
if not queueOut[player] then continue end if not player or not queueOut[player] then continue end
for Identifier: string, data: any in queueOut[player] do for Identifier: string, data: any in queueOut[player] do
if #data == 0 then continue end if #data == 0 then continue end
ReliableEvent:FireClient(player, Buffer.revert(Identifier), data) ReliableEvent:FireClient(player, Buffer.revert(Identifier), data)