PolicyService

แสดงที่เลิกใช้งานแล้ว

*เนื้อหานี้แปลโดยใช้ AI (เวอร์ชัน Beta) และอาจมีข้อผิดพลาด หากต้องการดูหน้านี้เป็นภาษาอังกฤษ ให้คลิกที่นี่

ไม่สามารถสร้าง
บริการ
ไม่ซ้ำ

PolicyService ช่วยให้คุณสอบถามข้อมูลเกี่ยวกับการปฏิบัติตามนโยบายสำหรับผู้เล่นทั่วโลกตามช่วงอายุ ตำแหน่ง และประเภทแพลตฟอร์ม

สรุป

วิธีการ

  • CanViewBrandProjectAsync(player : Player,brandProjectId : string):boolean
    ผลตอบแทน

    กำหนดว่าผู้ใช้สามารถดูทรัพยากรโครงการแบรนด์ภายในประสบการณ์ของคุณได้หรือไม่

  • ผลตอบแทน

    ส่งคืนข้อมูลนโยบายเกี่ยวกับผู้เล่นตามตำแหน่งทางภูมิศาสตร์ กลุ่มอายุ และแพลตฟอร์ม

คุณสมบัติ

วิธีการ

CanViewBrandProjectAsync

ผลตอบแทน

กำหนดว่าผู้ใช้สามารถดูทรัพยากรโครงการแบรนด์ภายในประสบการณ์ของคุณได้หรือไม่วิธีนี้ช่วยให้คุณสามารถทำงานร่วมกับแบรนด์เพื่อแสดงทรัพยากรทางการค้าให้กับผู้ชมที่สอดคล้องกับแบรนด์เท่านั้น

เพื่อใช้ CanViewBrandProjectAsync คุณต้องใช้รหัสโครงการแบรนด์ที่ให้โดย Roblox เพื่อขอรหัสโครงการแบรนด์ ติดต่อเรา

คุณต้องเรียกวิธีนี้บนสคริปทางเซิร์ฟเวอร์และห่อหุ้มมันด้วย pcall()

พารามิเตอร์

player: Player

วัตถุ Player ที่คุณกำลังพยายามแสดงโครงการแบรนด์ให้เห็น

ค่าเริ่มต้น: ""
brandProjectId: string

รหัสโครงการแบรนด์ที่ Roblox ให้ไว้ แทนที่ทุกสินทรัพย์ที่เกี่ยวข้องกับโครงการแบรนด์

ค่าเริ่มต้น: ""

ส่งค่ากลับ

ว่าโครงการแบรนด์จะแสดงให้ผู้ใช้เฉพาะรายหรือไม่

ตัวอย่างโค้ด

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.

Server-side code sample

-- 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)
Client-side code sample

-- 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>อนุญาตโฆษณาได้หรือไม่</code></td>
<td>บูลีน</td>
<td>ประสบการณ์ใดก็ได้ที่รวม <a href="/production/monetization/immersive-ads">โฆษณาแบบมีส่วนร่วม</a> .</td>
<td>เมื่อ <code>จริง</code> ผู้เล่นอาจเห็นโฆษณาแบบมีส่วนร่วมภายในประสบการณ์</td>
</tr>
<tr>
<td><code>ArePaidRandomItemsRestricted ถูกจำกัด</code></td>
<td>บูลีน</td>
<td>ประสบการณ์ใดๆ ที่มีไอเทมสุ่มจ่ายเงิน</td>
<td>เมื่อ <code>ถูกต้อง</code> ผู้เล่นสามารถ <b>ไม่</b> โต้ตอบกับตัวสร้างรายการสุ่มจ่ายเงินได้ ทั้งผ่านเงินในประสบการณ์ที่ซื้อด้วย 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>อนุญาตให้แชร์เนื้อหาหรือไม่</code></td>
<td>บูลีน</td>
<td>ประสบการณ์ใดๆ ที่อนุญาตให้ผู้ใช้แบ่งปันเนื้อหาออกจากแพลตฟอร์ม</td>
<td>เมื่อ <code>ถูกต้อง</code> ผู้เล่นจะได้รับอนุญาตให้แบ่งปันเนื้อหาโดยใช้ API ที่เปิดการแบ่งปันภายนอกเช่น <code>Class.CaptureService:PromptShareCapture()|PromptShareCapture()</code></td>
</tr>
<tr>
<td><code>สามารถซื้อผลิตภัณฑ์การค้าได้หรือไม่</code></td>
<td>บูลีน</td>
<td>ประสบการณ์ใดก็ได้ที่ต้องการขายผลิตภัณฑ์การค้า <a href="/production/monetization/commerce-products"></a></td>
<td>เมื่อ <code>ถูกต้อง</code> ผู้เล่นมีสิทธิ์ซื้อผลิตภัณฑ์การค้าภายในประสบการณ์</td>
</tr>
<tr>
<td><code>สามารถซื้อสมัครสมาชิกได้หรือไม่</code></td>
<td>บูลีน</td>
<td>ประสบการณ์ใดก็ได้ที่ต้องการขายสมาชิก</td>
<td>เมื่อ <code>ถูกต้อง</code> ผู้เล่นมีสิทธิ์ซื้อสมาชิกภายในประสบการณ์</td>
</tr>
<tr>
<td><code>อนุญาตการซื้อขายไอเทมที่จ่ายเงินแล้ว</code></td>
<td>บูลีน</td>
<td>ประสบการณ์ใดก็ได้ที่ช่วยให้ผู้ใช้สามารถซื้อไอเทมเสมือนที่พวกเขาสามารถแลกเปลี่ยนกับผู้เล่นคนอื่นได้</td>
<td>เมื่อ <code>ถูกต้อง</code> ผู้เล่นสามารถแลกเปลี่ยนไอเทมเสมือนที่ซื้อด้วยเงินในประสบการณ์หรือ Robux</td>
</tr>
<tr>
<td><code>เป็นวัตถุที่อยู่ภายใต้นโยบายของจีน</code></td>
<td>บูลีน</td>
<td>ประสบการณ์ใดๆ ที่มีอยู่ในประเทศจีน</td>
<td>เมื่อ <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> ถูกเรียกมากกว่า 100 ครั้งก่อนที่คำตอบ HTTP จะกลับมา</td>
</tr>
</tbody>
ข้อความ

ดูเพิ่มเติม LocalizationService:GetCountryRegionForPlayerAsync() ซึ่งส่งคืนสตริงรหัสประเทศ/ภูมิภาคตามตำแหน่ง IP ของผู้เล่น

พารามิเตอร์

player: Instance

The Player เพื่อรับข้อมูลนโยบาย

ค่าเริ่มต้น: ""

ส่งค่ากลับ

สารานุกรมที่มีข้อมูลเกี่ยวกับข้อมูลนโยบายของผู้เล่นที่ร้องขอ; ดูด้านบนสำหรับโครงสร้างสารานุกรม

ตัวอย่างโค้ด

This code sample gets policy information for the local player and warns if they cannot interact with paid random item generators.

Getting Policy Information for a Player

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

This code sample gets policy information for the local player and warns if they cannot purchase a real-world commerce product.

Getting Policy Information for a Player

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 not result.IsEligibleToPurchaseCommerceProduct then
warn("Player is not eligible to purchase commerce products")
end

เหตุการณ์