PointsService 类可以控制点。
积分是一种奖励系统,用于显示玩家在 Roblox 上的成就和参与度。 通过此服务获得积分的方式取决于游戏开发者的自由。
概要
活动
- PointsAwarded(userId : number,pointsAwarded : number,userBalanceInGame : number,userTotalBalance : number):RBXScriptSignal
在授予玩家成功时,会同时传递更新的点数余额给玩家,以及所有游戏中玩家拥有的更新余额。
属性
方法
活动
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)
参数
代码示例
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)