學習
引擎類別
OrderedDataStore
無法建立
未複製

*此內容是使用 AI(Beta 測試版)翻譯,可能含有錯誤。若要以英文檢視此頁面,請按一下這裡


概要
方法
GetSortedAsync(ascending: boolean,pagesize: number,minValue: Variant,maxValue: Variant):DataStorePages
繼承成員
範例程式碼
有序數據存儲基礎
local DataStoreService = game:GetService("DataStoreService")
local pointsStore = DataStoreService:GetOrderedDataStore("Points")
local function printTopTenPlayers()
local isAscending = false
local pageSize = 10
local pages = pointsStore:GetSortedAsync(isAscending, pageSize)
local topTen = pages:GetCurrentPage()
-- 'topTen' 中的數據 是以索引為頁面上的索引進行存儲
-- 對於每個項目,'data.key' 是有序數據存儲中的鍵,而 'data.value' 是值
for rank, data in ipairs(topTen) do
local name = data.key
local points = data.value
print(name .. " 的排名是 #" .. rank .. ",得分是 " .. points .. " 分")
end
-- 可能加載下一頁...
--pages:AdvanceToNextPageAsync()
end
-- 創建一些數據
pointsStore:SetAsync("Alex", 55)
pointsStore:SetAsync("Charley", 32)
pointsStore:SetAsync("Sydney", 68)
-- 顯示前十名 玩家
printTopTenPlayers()

API 參考
方法
GetSortedAsync
暫停
功能: DataStore
OrderedDataStore:GetSortedAsync(
ascending:boolean, pagesize:number, minValue:Variant, maxValue:Variant
參數
ascending:boolean
pagesize:number
minValue:Variant
maxValue:Variant

©2026 Roblox Corporation、Roblox、Roblox 標誌及 Powering Imagination 是我們在美國及其他國家地區的部分註冊與未註冊商標。