개발자 상품

개발자 상품이란 체험 내 통화, 탄약, 물약 등 사용자가 여러 번 구매할 수 있는 아이템이나 능력을 말합니다.

개발자 상품 만들기

개발자 상품으로 사용할 이미지를 만들 때는 다음과 같은 요건을 고려해야 합니다.

  • 512×512 픽셀의 템플릿을 사용하세요.
  • 이미지를 .jpg, .png 또는 .bmp 형식으로 저장하세요.
  • 업로드 과정에서 최종 개발자 상품을 원형 이미지로 다듬어 잘라내기 때문에 중요한 세부 정보를 원형 경계선 바깥에 포함하시면 안 됩니다.

새로운 개발자 상품을 만드려면 다음을 수행하세요.

  1. 크리에이터 대시보드로 이동합니다.

  2. 만들려는 개발자 상품이 사용될 체험을 클릭합니다. 체험의 개요 페이지가 나타납니다.

  3. 왼쪽 탐색에서 '관련 아이템(Associated Items)'을 선택합니다. '관련 아이템(Associated Items)' 페이지가 나타납니다.

  4. 가로로 펼쳐진 탐색 메뉴에서 '개발자 상품(DEVELOPER PRODUCTS)'을 선택합니다. 해당 체험의 모든 개발자 상품이 표시됩니다.

  5. '개발자 상품 만들기(CREATE A DEVELOPER PRODUCT)' 버튼을 클릭합니다. '개발자 상품 만들기(Create a Developer Product)' 페이지가 나타납니다.

  6. '이미지 업로드(UPLOAD IMAGE)' 버튼을 클릭합니다. 파일 브라우저가 표시됩니다.

  7. 아이콘으로 표시할 이미지를 선택한 다음 '열기(Open)' 버튼을 클릭합니다.

  8. 다음 필드를 채웁니다.

    • '이름(Name)': 개발자 상품의 제목입니다.
    • '설명(Description)': 사용자가 이 개발자 상품을 구매하면 어떤 것을 기대할 수 있는지에 대한 설명입니다.
    • 'Robux 가격(Price in Robux)': 이 개발자 상품을 구매하는 사용자에게 부과하려는 Robux 금액입니다.
  9. '개발자 상품 만들기(CREATE DEVELOPER PRODUCT)' 버튼을 클릭합니다. '관련 아이템(Associated Items)' 페이지의 '개발자 상품(Developer Products)' 섹션 안에 개발자 상품이 표시됩니다.

개발자 상품 ID 찾기

개발자 상품 ID는 개발자 상품의 고유한 식별자입니다. 배지에 대한 스크립트를 작성할 때 이 ID가 필요합니다.

개발자 상품 ID 찾는 방법

  1. 체험의 '관련 아이템(Associated Items)' 페이지에서 '개발자 상품(Developer Product)' 섹션으로 이동합니다.

  2. 개발자 상품 섬네일 위로 마우스를 가져가 버튼을 클릭합니다. 콘텍스트 메뉴가 표시됩니다.

  3. 애셋 ID 복사를 선택합니다. 개발자 상품 ID가 클립보드에 복사됩니다.

개발자 상품 스크립트 작성

체험에서 개발자 상품 효과를 실행하려면 스크립팅을 사용해야 합니다.

일반적인 개발자 상품 스크립팅의 사용 사례에는 다음이 포함됩니다.

구매 프롬프트 표시

사용자에게 개발자 상품 중 하나를 구매하도록 프롬프트를 표시하려면 MarketplaceServicePromptProductPurchase() 메소드를 사용하세요. 체험에서 발생하는 필요에 따라, 사용자가 버튼을 누를 때나 사용자의 캐릭터가 공급업체 NPC와 대화할 때와 같은 상황에서 promptPurchase() 함수를 호출할 수 있습니다.


local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local productId = 0000000 -- Change this to your developer product ID
-- Function to prompt purchase of the developer product
local function promptPurchase()
MarketplaceService:PromptProductPurchase(player, productId)
end

구매 처리

사용자가 개발자 상품을 구매한 후 이 거래를 처리하고 기록하는 것은 크리에이터의 책임입니다. 이러한 작업은 MarketplaceService.ProcessReceipt 콜백을 사용하여 ServerScriptService 내의 Script를 통해 할 수 있습니다.


local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local productFunctions = {}
-- ProductId 123123 brings the user back to full health
productFunctions[123123] = function(receipt, player)
if player.Character and player.Character:FindFirstChild("Humanoid") then
player.Character.Humanoid.Health = player.Character.Humanoid.MaxHealth
-- Indicate a successful purchase
return true
end
end
-- ProductId 456456 awards 100 gold to the user
productFunctions[456456] = function(receipt, player)
local stats = player:FindFirstChild("leaderstats")
local gold = stats and stats:FindFirstChild("Gold")
if gold then
gold.Value = gold.Value + 100
return true
end
end
local function processReceipt(receiptInfo)
local userId = receiptInfo.PlayerId
local productId = receiptInfo.ProductId
local player = Players:GetPlayerByUserId(userId)
if player then
-- Get the handler function associated with the developer product ID and attempt to run it
local handler = productFunctions[productId]
local success, result = pcall(handler, receiptInfo, player)
if success then
-- The user has received their benefits!
-- return PurchaseGranted to confirm the transaction.
return Enum.ProductPurchaseDecision.PurchaseGranted
else
warn("Failed to process receipt:", receiptInfo, result)
end
end
-- the user's benefits couldn't be awarded.
-- return NotProcessedYet to try again next time the user joins.
return Enum.ProductPurchaseDecision.NotProcessedYet
end
-- Set the callback; this can only be done once by one script on the server!
MarketplaceService.ProcessReceipt = processReceipt

정보 확인

가격, 이름, 이미지 등 특정 개발자 상품에 대한 정보를 확인하려면 Enum.InfoType.Product의 두 번째 인수와 함께 MarketplaceService:GetProductInfo() 함수를 사용하세요. 예를 들면 다음과 같습니다.


local MarketplaceService = game:GetService("MarketplaceService")
local productId = 000000 -- Change this to your developer product ID
local productInfo = MarketplaceService:GetProductInfo(productId, Enum.InfoType.Product)
local success, productInfo = pcall(function()
return MarketplaceService:GetProductInfo(productId, Enum.InfoType.Product)
end)
if success then
-- Use productInfo here!
end

또한 GetDeveloperProductsAsync() 메소드를 사용하면 체험 내 모든 개발자 상품에 대한 데이터를 확인할 수 있습니다. 이 메소드가 반환하는 Pages 개체를 검사하고 필터링하여 체험 내 상점이나 상품 목록 GUI와 같은 것을 만들 수 있습니다.

예를 들어, 다음과 같은 스크립트는 체험 내 모든 개발자 상품에 대한 이름, 가격, ID, 설명 및 애셋 ID를 표시합니다.


local MarketplaceService = game:GetService("MarketplaceService")
local success, developerProducts = pcall(function()
return MarketplaceService:GetDeveloperProductsAsync():GetCurrentPage()
end)
if developerProducts then
for _, developerProduct in pairs(developerProducts) do
for field, value in pairs(developerProduct) do
print(field .. ": " .. value)
end
print(" ")
end
end