PointsService

显示已弃用

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

无法创建
服务
已弃用

点服务类控制点。

积分是用于在 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

代码示例

When a player is awarded points successfully the below example would print the userId and their new point balance. If, for example, the Roblox account was awarded thirty points (and had none to begin with) "User: 1 has now earned 30 (+30) points in the current game, now making their total balance 30" would be printed.

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)