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>필요한 것:</th><th>설명</th></tr></thead><tbody><tr><td><code>광고 허용AreAdsAllowed</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 true , 플레이어는 Robux 또는 Robux로 구매한 경험 통화를 통해 유료 랜덤 아이템 생성기와 상호작용할 수 없습니다.</td></tr><tr><td><code>허용된 외부 링크 참조</code></td><td>배열</td><td>외부 링크를 참조하는 모든 경험.</td><td>소셜 미디어 링크, 핸들 또는 아이콘처럼 플레이어가 볼 수 있는 외부 링크 참조 목록.가능한 값에는 <code>"디스코드"</code> , <code>"페이스북"</code> , <code>"트위치"</code> , <code>"유튜브"</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>유료 아이템 거래 허용 IsPaidItemTradingAllowed</code></td><td>부울</td><td>다른 플레이어와 거래할 수 있는 가상 아이템을 구매할 수 있는 모든 경험.</td><td>When <code>true</code> , 플레이어는 경험 통화 또는 Robux로 구매한 가상 아이템을 거래할 수 있습니다.</td></tr><tr><td><code>중국 정책에 대한 대상IsSubjectToChinaPolicies</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>내부 오류로 <code>GetPolicyInfoForPlayerAsync()</code>가 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