SocialService

非推奨を表示

*このコンテンツは、ベータ版のAI(人工知能)を使用して翻訳されており、エラーが含まれている可能性があります。このページを英語で表示するには、 こちら をクリックしてください。

作成できません
サービス
複製されていません

SocialService は、Roblox プラットフォームの関係に影響を与えるソーシャル機能を容易にします。主な使用は、招待プロンプト と電話帳をプレイヤーに表示することで、 Class.SocialService

概要

方法

イベント

コールバック

プロパティ

方法

HideSelfView

void

呼び出すプレイヤーの自分のビューを非表示にします。このメソッドを呼び出している間、自分のビューがすでに非表示になっている場合、それは何もしません。


戻り値

void

PromptGameInvite

void

PromptGameInvite() は、ローカルプレイヤーに招待プロンプトを表示し、そのプレイヤーの友達を現在のエクスペリエンスに招待することができます。このメソッドを呼び出す前に、 Class.SocialService:CanSendGameInviteAsync()|CanSendGameInvite

招待プロンプトの実装、カスタマイズ、通知、およびランチャデータの使用については、Player Invite Promptsを参照してください。

パラメータ

player: Instance

招待ポップアップでプロンプトする Player

experienceInviteOptions: Instance

プロンプトのカスタマイズのオプション ExperienceInviteOptions オブジェクト。

既定値: "nil"

戻り値

void

コードサンプル

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

void

プレイヤーが誰かを呼び出すと、 Player イベントが発動します。CallInviteStateChanged を使用する前

プレイヤーが電話帳を開く資格がありません、エラーダイアログが表示されます。

このメソッドのサンプル実装は、Roblox Connect を参照してください。

パラメータ

player: Instance

電話帳でプロンプトするプレーヤー。

tag: string

異なる電話帳の "エントリポイント" または類似の項目を区別するための弦。たとえば、コールするプレイヤーのキャラクターが現在どの領域にあるかを定義する弦を渡すことができます。


戻り値

void

コードサンプル

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

void

プレイヤーの自己ビューを表示します。このメソッドが自己ビューが表示されている間に呼び出されると、何もしません。

パラメータ

selfViewPosition: Enum.SelfViewPosition

自分のビューを配置する位置。

既定値: "LastPosition"

戻り値

void

CanSendCallInviteAsync

イールド

Class.Player が友達にコールインビテーションを送信できるかどうかを返します。このメソッドの結果を常に Player 前に使用する必要があります。電話ブックの開き方はプレイヤーによって異なるため、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() は、true を返しますが、Player が他のプレイヤーを現在のエクスペリエンスに招待できるかどうかは常にこのメソッドの結果を使用する必

プレイヤーの招待プロンプトに関する詳細は、Player Invite Prompts を参照してください。

パラメータ

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

イベント

CallInviteStateChanged

このイベントは、プレイヤーの呼び出し状態が変更されると発動します。

パラメータ

player: Instance

Class.Player インスタンスは、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

電話帳からの呼び出しが処理されるコールバック。PromptPhoneBook() パラメーターを使用して、異なる「入力ポイント」または類似の処理を異なる "タグ" パラメーターで区別できます。Class.SocialService:PromptPhoneBook()|PromptPhoneBook() でのみコールバックを設定する定できます。

パラメータ

tag: string

電話帳のエントリポイント間で異なる電話帳のエントリを区別するのに役立つストリング。

callParticipantIds: Array

コールに関わるすべてのプレイヤーを含むアレイ。コーラーは常にアレイの最初のプレイヤーになります。


戻り値

Class.DataModel.PlaceId と ReservedServerAccessCode のキーを含む、値が DataModel.PlaceId であり、1>Class.TeleportService:ReserveServer()1> によって返されたサーバーアクセスコードです。

コードサンプル

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