Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do i make a global(across ALL servers) queue?

Asked by 4 years ago

I'm trying to make a minigames queue for my game (a part of the game), and I want players all over different servers be able to queue and get in the minigame, but, I'm worried if I only make the queue server only, players would need to wait a very long time to get enough players. So, I want to make a queue for all servers in the game.

0
lemme edit my answeer below to see if i can accommodate for what you want User#23252 26 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

you could use http service, the easiest way..

or you could get creative with datastore service.

in order to use HTTP service, you need an external server/website.. and you could make servers constantly request and update the information on your web server;

in this example whoever, I'll try to get creative with data-store service,

lets say for example that i am making a thing that displays the name of the player with the most money in the game....

local data_name = "playerWith_MostMoneyInThisWonderFullgame"
local global_key = "theRichestPlayerKnown"
local money_key = "MostMoneyyyyy"
local datastore = game:GetService("DataStoreService"):GetDataStore(data_name)
local players = game.Players

local surfaceUi = workspace.board.surfaceGui.textlabel

local function newRichestPlayer(player)
    if player then
        local money = player.leaderstats.Money
        pcall(function()
            datastore:SetAsync(global_key,player.Name)
            datastore:SetAsync(money_key,money)
        end)

        surfaceUi.Text = player.Name.."\n"..money

    end
end



players.PlayerAdded:Connect(function(player)
    local playerWithMostMoney;
    local money

    pcall(function()
        playerWithMostMoney = datastore:GetAsync(global_key)
        money =datastore:GetAsync(money_key)
    end)

    if playerWithMostMoney then
        if player.leaderstats.Money.Value > money then
            newRichestPlayer(player)
        else
            surfaceUi.Text = playerWithMostMoney.."\n"..money 
        end
    else
        print("there is currently no known richest player")
        surfaceUi.Text = "unknown"
    end

end)


local co = coroutine.wrap(function()
    while wait(2) do
        local playerWithMostMoney;
        local money

        pcall(function()
            playerWithMostMoney = datastore:GetAsync(global_key)
            money =datastore:GetAsync(money_key)
        end)

        for _, player in pairs(players:GetChildren()) do

            if playerWithMostMoney then
                if player.leaderstats.Money.Value > money then
                    newRichestPlayer(player)
                end
            else
                print("there is currently no known richest player")
                surfaceUi.Text = "unknown"
            end

        end
    end
end)

co()

sorry this is not in the best form, i am kinda of in a hurry

0
can you explain more about how to use it? EnderCrayonBM 17 — 4y
0
there User#23252 26 — 4y
Ad

Answer this question