SocialService

사용되지 않는 항목 표시

*이 콘텐츠는 AI(베타)를 사용해 번역되었으며, 오류가 있을 수 있습니다. 이 페이지를 영어로 보려면 여기를 클릭하세요.

만들 수 없음
서비스
복제되지 않음

SocialService 는 Roblox 플랫폼에서 만들어진 관계에 영향을 주는 소셜 기능을 용이하게 합니다.주요 용도는 플레이어에게 초대 프롬프트와 전화 부록을 표시하여 친구에게 초대 요청을 보낼 수 있도록 하는 것입니다. 즉, PromptGameInvite()PromptPhoneBook()를 통해 각각 보낼 수 있습니다.이러한 요청이 발생할 때 신호를 활용할 수 있습니다.

요약

메서드

이벤트

콜백

속성

메서드

GetPlayersByPartyId

Instances

매개 변수

partyId: string
기본값: ""

반환

Instances

HideSelfView

()

호출하는 플레이어의 자기 보기를 숨깁니다. 자기 보기가 이미 숨겨져 있는 동안 이 메서드가 호출되면 아무 것도 수행하지 않습니다.


반환

()

PromptGameInvite

()

PromptGameInvite() 로컬 플레이어를 통해 현재 경험에 친구를 초대할 수 있는 초대 프롬프트를 표시합니다.이 메서드를 호출하기 전에, CanSendGameInviteAsync() 를 사용하여 플레이어가 초대를 보낼 수 있는지 여부를 결정해야 합니다, 이 능력은 플랫폼이나 플레이어에 따라 다를 수 있기 때문입니다.

플레이어 초대 프롬프트에 대한 자세한 내용은 초대 프롬프트 구현, 프롬프트와 알림 사용자 정의 및 런치 데이터 사용을 참조하십시오.

매개 변수

player: Instance

초대 팝업으로 프롬프트하는 Player .

기본값: ""
experienceInviteOptions: Instance

프롬프트를 사용자 지정하기 위한 선택적 ExperienceInviteOptions 개체.

기본값: "nil"

반환

()

코드 샘플

The following code sample uses CanSendGameInviteAsync() to confirm whether the local Player can send an invite. If true, it then prompts the invite using PromptGameInvite().

Sending an Invite

local SocialService = game:GetService("SocialService")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
-- Function to check whether the player can send an invite
local function canSendGameInvite(sendingPlayer)
local success, canSend = pcall(function()
return SocialService:CanSendGameInviteAsync(sendingPlayer)
end)
return success and canSend
end
local canInvite = canSendGameInvite(player)
if canInvite then
SocialService:PromptGameInvite(player)
end

PromptPhoneBook

()

주어진 Player에 전화 책을 요청합니다.플레이어가 누군가를 호출하기로 선택하면 CallInviteStateChanged 이벤트가 발생합니다.전화 번호부를 볼 수 있는 능력은 플레이어에 따라 다를 수 있으므로 PromptPhoneBook() 를 호출하기 전에 CanSendCallInviteAsync() 을 사용해야 합니다.

플레이어가 전화 책을 열 수 없는 경우 오류 대화 상자가 표시됩니다.

이 메서드의 샘플 구현은 Roblox Connect에 참조하십시오.

매개 변수

player: Instance

전화 번호부로 프롬프트할 플레이어.

기본값: ""
tag: string

다양한 전화 부ook 항목 또는 유사한 항목을 구분하는 데 도움이 되는 문자열.예를 들어, 호출하는 플레이어의 현재 캐릭터가 속한 경험 영역을 정의하는 문자열을 전달할 수 있습니다.

기본값: ""

반환

()

코드 샘플

The following code sample, placed within a child LocalScript of a GuiButton, uses CanSendCallInviteAsync() to confirm that the player can make a call. If so, it connects PromptPhoneBook() to the button's Activated event.

SocialService:PromptPhoneBook()

local Players = game:GetService("Players")
local SocialService = game:GetService("SocialService")
local player = Players.LocalPlayer
local button = script.Parent
button.Visible = false
-- Function to check whether the player can send a call invite
local function canSendCallingInvite(sendingPlayer)
local success, canSend = pcall(function()
return SocialService:CanSendCallInviteAsync(sendingPlayer)
end)
return success and canSend
end
local canCall = canSendCallingInvite(player)
if canCall then
button.Visible = true
button.Activated:Connect(function()
SocialService:PromptPhoneBook(player, "")
end)
end

ShowSelfView

()

호출하는 플레이어의 자기 보기를 표시합니다. 자기 보기가 이미 표시되는 동안 이 메서드가 호출되면 아무 것도 수행하지 않습니다.

매개 변수

selfViewPosition: Enum.SelfViewPosition

자체 뷰를 배치할 위치.

기본값: "LastPosition"

반환

()

CanSendCallInviteAsync

생성

지정된 Player 가 친구에게 전화 초대를 보낼 수 있는 경우 true 를 반환합니다.전화 부ook을 열 수 있는 능력은 플레이어에 따라 다를 수 있으므로 항상 이 메서드의 결과를 사용해야 합니다 PromptPhoneBook() 호출하기 전에.

이 메서드의 샘플 구현은 Roblox Connect에 참조하십시오.

매개 변수

player: Instance

플레이어의 인스턴스 Player 가 전화 초대를 보낼 수 있습니다.

기본값: ""

반환

지정된 플레이어가 전화 초대를 보낼 수 있는지 여부.

코드 샘플

The following code sample, placed within a child LocalScript of a GuiButton, uses CanSendCallInviteAsync() to confirm that the player can make a call. If so, it connects PromptPhoneBook() to the button's Activated event.

SocialService:PromptPhoneBook()

local Players = game:GetService("Players")
local SocialService = game:GetService("SocialService")
local player = Players.LocalPlayer
local button = script.Parent
button.Visible = false
-- Function to check whether the player can send a call invite
local function canSendCallingInvite(sendingPlayer)
local success, canSend = pcall(function()
return SocialService:CanSendCallInviteAsync(sendingPlayer)
end)
return success and canSend
end
local canCall = canSendCallingInvite(player)
if canCall then
button.Visible = true
button.Activated:Connect(function()
SocialService:PromptPhoneBook(player, "")
end)
end

CanSendGameInviteAsync

생성

CanSendGameInviteAsync() 는 지정된 Player 가 현재 경험에 다른 플레이어를 초대할 수 있는 경우 true 를 반환합니다.플레이어를 초대할 수 있는 능력은 플랫폼이나 플레이어에 따라 다를 수 있으므로 항상 이 메서드의 결과를 사용해야 합니다. PromptGameInvite() 를 호출하기 전에.

플레이어 초대 프롬프트에 대한 자세한 내용은 플레이어 초대 프롬프트 구현, 프롬프트와 알림 사용자 정의, 런칭 데이터 사용을 참조하십시오.

매개 변수

player: Instance

플레이어의 인스턴스 Player 가 초대를 보낼 수 있습니다.

기본값: ""
recipientId: number

잠재적 Player.UserId의 선택적 옵션 , 발신자가 특정 받는 수신자초대할 수 있는지 확인하는 데 사용됩니다.

기본값: 0

반환

지정된 플레이어가 초대를 보낼 수 있는지 여부.

코드 샘플

The following code sample uses CanSendGameInviteAsync() to confirm whether the local Player can send an invite. If true, it then prompts the invite using PromptGameInvite().

Sending an Invite

local SocialService = game:GetService("SocialService")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
-- Function to check whether the player can send an invite
local function canSendGameInvite(sendingPlayer)
local success, canSend = pcall(function()
return SocialService:CanSendGameInviteAsync(sendingPlayer)
end)
return success and canSend
end
local canInvite = canSendGameInvite(player)
if canInvite then
SocialService:PromptGameInvite(player)
end

GetPartyAsync

생성

매개 변수

partyId: string
기본값: ""

반환

이벤트

CallInviteStateChanged

이 이벤트는 플레이어의 호출 초대 상태가 변경될 때 발생합니다.

매개 변수

player: Instance

호출 초대 상태 변경이 있었던 플레이어의 인스턴스 Player

inviteState: Enum.InviteState

새로운 호출 초대 상태.


코드 샘플

SocialService.CallInviteStateChanged

local SocialService = game:GetService("SocialService")
local button = script.Parent
local isPhonebookOpen = false
SocialService.CallInviteStateChanged:Connect(function(_, inviteState)
local isCalling = inviteState == Enum.InviteState.Placed
if isCalling or isPhonebookOpen then
button.Visible = false
else
button.Visible = true
end
end)

GameInvitePromptClosed

이 이벤트는 플레이어가 초대 프롬프트를 닫을 때 발생합니다.

매개 변수

player: Instance

프롬프트를 닫은 플레이어의 Player 인스턴스.

recipientIds: Array

더 이상 채워지지 않음; 빈 배열.


PhoneBookPromptClosed

플레이어가 전화 책을 닫을 때 발생합니다.

매개 변수

player: Instance

전화 부록을 닫은 플레이어의 Player 인스턴스.


콜백

OnCallInviteInvoked

전화 부ook에서 호출이 배치될 때 처리할 콜백입니다.tag 매개 변수는 PromptPhoneBook()에 설명된 것처럼 다른 "입력 지점" 또는 유사한 것들을 구분하는 데 사용할 수 있습니다.단일 콜백만 설정할 수 있습니다.

매개 변수

tag: string

다양한 전화 부ook 입력 지점을 구분하는 데 도움이 되는 문자열.

callParticipantIds: Array

호출에 참여하는 모든 플레이어가 포함된 배열. 호출자는 항상 배열에서 첫 번째 플레이어가 됩니다.


반환

값이 PlaceIdReservedServerAccessCode 키인 테이블, 해당 키의 값은 DataModel.PlaceIdTeleportService:ReserveServer()에서 반환된 서버 액세스 코드입니다.

코드 샘플

SocialService.OnCallInviteInvoked

local SocialService = game:GetService("SocialService")
local TeleportService = game:GetService("TeleportService")
SocialService.OnCallInviteInvoked = function()
local placeId = 0123456789 -- This is the place ID of the desired place to drop call participants into
local accessCode = TeleportService:ReserveServer(placeId)
return { ReservedServerAccessCode = accessCode, PlaceId = placeId }
end