OrderedDataStore

แสดงที่เลิกใช้งานแล้ว

*เนื้อหานี้จะพร้อมใช้งานในภาษาที่คุณเลือกในเร็วๆ นี้

ไม่สามารถสร้าง
ไม่ซ้ำ

A OrderedDataStore is essentially a GlobalDataStore with the exception that stored values must be positive integers. It exposes a method GetSortedAsync() which allows inspection of the entries in sorted order using a DataStorePages object.

Ordered data stores do not support versioning and metadata, so DataStoreKeyInfo is always nil for keys in an OrderedDataStore. If you need versioning and metadata support, use a DataStore.

Ordered data stores do not support the optional userIds parameter for SetAsync() or IncrementAsync().

See Data Stores for an overview on using ordered data stores.

ตัวอย่างโค้ด

OrderedDataStore Basics

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()
-- The data in 'topTen' is stored with the index being the index on the page
-- For each item, 'data.key' is the key in the OrderedDataStore and 'data.value' is the value
for rank, data in ipairs(topTen) do
local name = data.key
local points = data.value
print(name .. " is ranked #" .. rank .. " with " .. points .. "points")
end
-- Potentially load the next page...
--pages:AdvanceToNextPageAsync()
end
-- Create some data
pointsStore:SetAsync("Alex", 55)
pointsStore:SetAsync("Charley", 32)
pointsStore:SetAsync("Sydney", 68)
-- Display the top ten players
printTopTenPlayers()

สรุป

วิธีการ

วิธีการรับทอดมาจากGlobalDataStore

คุณสมบัติ

วิธีการ

GetSortedAsync

ผลตอบแทน

Returns a DataStorePages object. The sort order is determined by ascending, the length of each page by pageSize, and minValue/maxValue are optional parameters which filter the results.

See Data Stores for request limits and descriptions of the error codes.

พารามิเตอร์

ascending: bool

A boolean indicating whether the returned data pages are in ascending order.

pagesize: number

The length of each page. By default is 50. The max allowed value is 100.

minValue: Variant

Optional parameter. If set, data pages with a value less than minValue will be excluded.

maxValue: Variant

Optional parameter. If set, data pages with a value greater than maxValue will be excluded.


ส่งค่ากลับ

A sorted DataStorePages object based on the provided arguments.

อีเวนต์