PointsService 類型控制點數。
點數是一種獎勵系統,用於在 Roblox 中展示玩家的成就和參與。點數的獎勵由遊戲開發者獨自決定。
概要
活動
- PointsAwarded(userId : number,pointsAwarded : number,userBalanceInGame : number,userTotalBalance : number):RBXScriptSignal
在獎勵點數給予玩家時發生火焰,並且通過更新點數平衡將玩家在當前遊戲和所有遊戲中的點數更新。
屬性
方法
活動
PointsAwarded
這個事件會在點被成功給予玩家時發生,並且還會傳送更新的點數給玩家和所有遊戲。
當玩家獲得點數時,下列範例會列出用戶名和其新點數餘額。如果 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)