#i need to make voice for invisible human. But this thing not work

1 messages · Page 1 of 1 (latest)

upbeat kiln
#
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 });
    }
}
#

can't find problem, anyone know?

#

also here is console

thin birch
#

U don't need continue in the foreach

upbeat kiln
#

only one time works and then skips

#

as i can understand

thin birch
#

It only sends the message every 1, 3, 5 ... Player.
To send all the current spectators remove the continue

fierce prism
thin birch
#

Also might change the channel to something because on receiving end it will check more stuff to which you probably don't want

fierce prism
#

Also you're sending to each spectator of every player

upbeat kiln
#

actually i cant hear him, when i d-class

#

not only spectator

fierce prism
#

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

upbeat kiln
fierce prism
#

Use SpeakerToy.Create and set its position every frame

#

To the player's position

upbeat kiln
#

ok thanks

upbeat kiln
fierce prism
#

No need to decode it

#

You can just create an AudioMessage with the data from the VoiceMessage

#

Data and DataLen

upbeat kiln
fierce prism
#

You don't use Speaker.Play

#

You create an AudioMessage and send it to clients

upbeat kiln
#

can you show an example?

upbeat kiln
# fierce prism You don't use Speaker.Play

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);
}
fierce prism
#

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

fierce prism
#

Np

vapid adder
#

sorry just

#

invisible players with 268 are still there client side

fierce prism
#

no because they're using validatedvisibility