CloudKVStore

继承自

描述

排行榜节点

函数

void ()
清理排行榜数据
TableGetOrderDataIndex (bool bAscend, int nIndex)
获取排行榜名次
intSetValue (string key, string name, int value)
设置同步kv值
intGetValue (string key, string name)
获取同步kv值
intSetValueAsync (string key, string name, int value, LuaFunction func)
设置异步kv值
intGetValueAsync (string key, string value, LuaFunction func)
获取异步kv值

代码示例

local CloudService = game:GetService("CloudService")

--获取排行榜(没有则创建)
 local Level = CloudService:GetOrderDataCloud("LevelAA")
--清空排行榜
Level:CleanOrderDataList()

 local LeveBB= CloudService:GetOrderDataCloud("LevelBB")

--同步设值
LeveBB:SetValue("1000068432","无意义",40)
LeveBB:SetValue("1000038432","无意义",70)
print("Hello LeveBB!")

--异步设值
LeveBB:SetValueAsync("1000018432","无意义",50, function (code)
	--code 为0成功,非0失败
	print("code is ", code)
end)

LeveBB:SetValueAsync("1000028432","无意义",60, function (code)
	--code 为0成功,非0失败
	print("code is ", code)
end)

LeveBB:SetValueAsync("1000048432","无意义",70, function (code)
	--code 为0成功,非0失败
	print("code is ", code)
end)


--同步获值
local getVal = LeveBB:GetValue("1000068432","无意义")
print("getVal is!", getVal)

local newGetVal = LeveBB:GetValueAsync("1000068432","无意义", function (code, val)
	--code 为0成功,非0失败
	print("code is, getVal is ", code, val)
end)
print("Hello LeveBB!")

--获取降序第二名
 local tableA = LeveBB:GetOrderDataIndex(false, 2)
for k, v in pairs(tableA) do
	print("TABLE A    key is value is", v.key,  v.value)
end
print("Hello LeveBB!")

--获取降序第二名到四名
 local  tableB = LeveBB:GetOrderDataValueArea(false, 2, 4)
for k, v in pairs(tableB) do
	print("TABLE B  key is value is", v.key,  v.value)
end
Last Updated: