PointsService

顯示已棄用項目

*此內容是使用 AI(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)