PolicyService
*このコンテンツは、ベータ版のAI(人工知能)を使用して翻訳されており、エラーが含まれている可能性があります。このページを英語で表示するには、 こちら をクリックしてください。
PolicyService は、年齢、場所、プラットフォームタイプに基づいて世界中のプレイヤーに関するポリシー遵守情報のクエリを助けます。
概要
方法
ユーザーがエクスペリエンス内のブランドプロジェクトアセットを見ることができるかどうかを決定します。
地理的位置、年齢グループ、プラットフォームに基づいてプレイヤーに関するポリシー情報を返します。
プロパティ
方法
CanViewBrandProjectAsync
ユーザーがエクスペリエンス内のブランドプロジェクトアセットを見ることができるかどうかを決定します。このメソッドでは、ブランドと協力して、ブランド準拠のオーディエンスにのみ商業資産を表示することができます。
を使用するには、Roblox が提供するブランドプロジェクトIDを使用する必要があります。ブランドプロジェクトIDをリクエストするには、 連絡してください 。
このメソッドをサーバー側のスクリプトで呼び出し、pcall() で包んでください。
パラメータ
Player ブランドプロジェクトを表示しようとしているオブジェクト。
Roblox が提供するブランドプロジェクト ID。ブランドプロジェクトに関連するすべてのアセットを表します。
戻り値
ブランドプロジェクトを特定のユーザーに表示できるかどうか。
コードサンプル
You must call CanViewBrandProjectAsync from the server-side and then fire an event on the client. Calling this method from the client-side returns an error.
-- In ServerScriptService
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local PolicyService = game:GetService("PolicyService")
-- Pre-created RemoteEvent in ReplicatedStorage
local RemoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent")
local brandedAsset = ReplicatedStorage:WaitForChild("BrandedAsset")
local defaultAsset = Instance.new("Part")
Players.PlayerAdded:Connect(function(player)
-- PolicyService:CanViewBrandProjectAsync can only be called from the Server
local success, canView = pcall(function()
return PolicyService:CanViewBrandProjectAsync(player, "BRP-0123456789")
end)
if success and canView then
RemoteEvent:FireClient(player, brandedAsset)
else
RemoteEvent:FireClient(player, defaultAsset)
end
end)
-- In StarterPlayerScripts
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
-- Pre-created RemoteEvent in ReplicatedStorage
local RemoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent")
RemoteEvent.OnClientEvent:Connect(function(partToLoad)
local clonedPart = partToLoad:Clone()
clonedPart.Parent = workspace
end)
GetPolicyInfoForPlayerAsync
地理的位置、年齢グループ、プラットフォームに基づいてプレイヤーに関するポリシー情報を返す。返された辞書の構造は次のとおりです:
<th>種類</th><th>必要です for</th><th>説明</th></tr></thead><tbody><tr><td><code>アドが許可されている</code></td><td>ブールブルーン</td><td><a href="../../../production/monetization/immersive-ads.md">没入型広告</a> を含むすべての経験。</td><td>When <code>true</code> 、プレイヤーはエクスペリエンス内の没入型広告を見る可能性があります。</td></tr><tr><td><code>アレイドランダムアイテムが制限された</code></td><td>ブールブルーン</td><td>有料のランダムアイテムを持つすべての経験。</td><td>When <code>true</code> では、プレイヤーは <b>有料のランダムアイテム生成機と対話できません</b> 、Robux または Robux で購入した経験通貨を介して、または直接 Robux を介して。</td></tr><tr><td><code>許可された外部リンク参照</code></td><td>アレイ</td><td>外部リンクを参照するすべての経験。</td><td>ソーシャルメディアリンク、ハンドル、またはアイコノグラフィーなど、プレイヤーが見ることが許可されている外部リンクのリスト。可能な値には、<code>"Discord"</code>、<code>"Facebook"</code>、<code>"Twitch"</code>、<code>"YouTube"</code>、<code>"X"</code>、<code>"GitHub"</code>、および<code>"Guilded"</code>があります。</td></tr><tr><td><code>コンテンツ共有が許可されていますかIsContentSharingAllowed</code></td><td>ブールブルーン</td><td>ユーザーがプラットフォーム外でコンテンツを共有できるすべての経験。</td><td>When <code>true</code> では、プレイヤーは <code>Class.CaptureService:PromptShareCapture()|PromptShareCapture()</code> のような外部共有フローを開く API を使用してコンテンツを共有することが許可されます。</td></tr><tr><td><code>IsEligibleToPurchase subscriptionを購入できるか</code></td><td>ブールブルーン</td><td>サブスクリプションを販売したいすべてのエクスペリエンス。</td><td>When <code>true</code> では、プレイヤーはエクスペリエンス内でサブスクリプションを購入できます。</td></tr><tr><td><code>IsPaidItemTradingAllowされている</code></td><td>ブールブルーン</td><td>ユーザーが他のプレイヤーと取引できる仮想アイテムを購入できるすべての経験。</td><td>When <code>true</code> では、プレイヤーは、インエクスペリエンス通貨または Robux で購入したバーチャルアイテムを取引できます。</td></tr><tr><td><code>IsSubjectToChinaポリシーに対する</code></td><td>ブールブルーン</td><td>中国で利用可能なすべての経験。</td><td>When <code>true</code> では、エクスペリエンスは変更の準拠性を強制する必要があります。詳細は <a href="https://devforum.roblox.com/t/new-programs-available-roblox-china-licensed-to-operate/1023361">このフォーラム投稿</a> を参照してください。</td></tr></tbody>
名前 |
---|
除外事項
どの非同期呼び出しと同様、このメソッドは pcall() で包まれ、適切にエラー処理される必要があります。可能なエラーメッセージとその理由の完全なリストは:
<th>理由</th></tr></thead><tbody><tr><td>インスタンスはプレイヤーではありませんでした</td><td><code>プレイヤー</code> パラメータは <code>Class.Player</code> インスタンスではありません。</td></tr><tr><td>見つからないプレイヤー</td><td><code>Class.Players</code> オブジェクトが欠落している内部エラー。</td></tr><tr><td>このメソッドは、ローカルでないプレイヤーのためにクライアントに呼び出すことはできません</td><td>このメソッドは、非ローカルの <code>Class.Player</code> にクライアントで呼び出すことはできません。</td></tr><tr><td>GetPolicyInfoForPlayerAsync が多くの回呼ばれすぎています</td><td>GetPolicyInfoForPlayerAsync() が、HTTP 応答が返される前に、100 回以戻る呼び出される内部エラー。</td></tr></tbody>
メッセージ |
---|
プレイヤーのクライアント IP ジオロケーションに従って国/地域コードストリングを返す LocalizationService:GetCountryRegionForPlayerAsync() も参照してください。
パラメータ
戻り値
要求されたプレイヤーのポリシー情報に関する情報を含む辞書; 上記の辞書構造を参照してください。
コードサンプル
This code sample gets policy information for the local player and warns if they cannot interact with paid random item generators.
local PolicyService = game:GetService("PolicyService")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local success, result = pcall(function()
return PolicyService:GetPolicyInfoForPlayerAsync(player)
end)
if not success then
warn("PolicyService error: " .. result)
elseif result.ArePaidRandomItemsRestricted then
warn("Player cannot interact with paid random item generators")
end