點數服務類別控制點數。
點數是用於在 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)
參數
範例程式碼
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)