PointsService

显示已弃用

*此内容使用人工智能(Beta)翻译,可能包含错误。若要查看英文页面,请点按 此处

无法创建
服务
已弃用

PointsService 类可以控制点。

积分是一种奖励系统,用于显示玩家在 Roblox 上的成就和参与度。 通过此服务获得积分的方式取决于游戏开发者的自由。

概要

活动

属性

方法

活动

PointsAwarded

当点击成功奖励玩家时,该事件也会触发,并且还会将玩家在当前游戏中和所有游戏中的更新平衡的点数传递给玩家。

当玩家成功获得积分时,下面的例子将打印用户ID和其新的积分余额。如果Roblox帐户获得了三十积分(并且没有积分开始)

用户: 1 已经游戏得 30 (+30) 积分,现在将其总余额

将被打印。


local function pointsAwarded(userId, pointsAwarded, userBalanceInGame, userTotalBalance)
print("User: " .. userId .. " has now earned " .. userBalanceInGame .. " (+" .. pointsAwarded ..") points in the current game, now making their total balance " .. userTotalBalance)
end
game:GetService("PointsService").PointsAwarded:Connect(pointsAwarded)

参数

userId: number
pointsAwarded: number
userBalanceInGame: number
userTotalBalance: number

代码示例

PointsService.PointsAwarded

local PointsService = game:GetService("PointsService")
local function onPointsAwarded(userId, pointsAwarded, userBalanceInGame, userTotalBalance)
print(
"User:",
userId,
"has now earned",
userBalanceInGame,
"(+",
pointsAwarded,
") points in the current game, now making their total balance",
userTotalBalance
)
end
PointsService.PointsAwarded:Connect(onPointsAwarded)