public override void OnPlayerSendingVoiceMessage(PlayerSendingVoiceMessageEventArgs ev)
{
LabApi.Features.Console.Logger.Info("1");
if (!Plugin.HasComponents.TryGetValue(ev.Player, out var module)) return;
LabApi.Features.Console.Logger.Info("2");
if (!module.LastSchematicVisibleState) return;
LabApi.Features.Console.Logger.Info("3");
foreach (var pl in Player.List.Where(r => ev.Player != r && r.IsAlive && Vector3.Distance(ev.Player.Position, r.Position) <= Plugin.Instance.Config.VoiceChatDistance))
{
LabApi.Features.Console.Logger.Info(pl.Nickname);
foreach (var ply in pl.CurrentSpectators)
{
ply.ReferenceHub.connectionToClient.Send(new VoiceChat.Networking.VoiceMessage() { Channel = VoiceChatChannel.Proximity, Data = ev.Message.Data, DataLength = ev.Message.DataLength, Speaker = ev.Message.Speaker, SpeakerNull = ev.Message.SpeakerNull }); continue;
}
pl.ReferenceHub.connectionToClient.Send(new VoiceChat.Networking.VoiceMessage() { Channel = VoiceChatChannel.Proximity, Data = ev.Message.Data, DataLength = ev.Message.DataLength, Speaker = ev.Message.Speaker, SpeakerNull = ev.Message.SpeakerNull });
}
}
#i need to make voice for invisible human. But this thing not work
1 messages · Page 1 of 1 (latest)
U don't need continue in the foreach
so it skips foreach?
only one time works and then skips
as i can understand
It only sends the message every 1, 3, 5 ... Player.
To send all the current spectators remove the continue
Continue does nothing if you put it at the end of the loop block
Also might change the channel to something because on receiving end it will check more stuff to which you probably don't want
Also you're sending to each spectator of every player
Is the player invisible in a sense that they have the Invisible effect?
You'd need to create a SpeakerToy, parent it to the player and send the voice message as an AudioMessage
Make sure to cancel the sending event
its maded by OnPlayerValidatedVisibility
so, how do i do it?
ok thanks
ok one more thing
how to play ev.Message.Data to float array?
No need to decode it
You can just create an AudioMessage with the data from the VoiceMessage
Data and DataLen
but speaker input only samples float[]
when how to use SpeakerToy.Create and why not voice message. i dont understand.
can you show an example?
like this?
AudioMessage audioMessage = new(module.Speaker.ControllerId, ev.Message.Data, ev.Message.DataLength);
foreach (var pl in Player.List.Where(r => ev.Player != r && r.IsAlive && Vector3.Distance(ev.Player.Position, r.Position) <= Plugin.Instance.Config.VoiceChatDistance))
{
LabApi.Features.Console.Logger.Info(pl.Nickname);
foreach (var ply in pl.CurrentSpectators)
{
ply.ReferenceHub.connectionToClient.Send(audioMessage); continue;
}
pl.ReferenceHub.connectionToClient.Send(audioMessage);
}
You need to create the toy when the player spawns and move it every frame to the player's position
Using the speaker's id you need to create an AudioMessage with data from the VoiceMessage
it works, thank you.
cant you set its parent to the players transform
sorry just
invisible players with 268 are still there client side
no because they're using validatedvisibility
