Hello everyone, I'm trying to make my sounds play for future reference.
The code below is working, if you press "V", the bot will duplicate my speech.
private void OnPlayerVoice(BasePlayer player, byte[] data)
{
Speak(data, player.transform.position);
}
private BasePlayer bot;
private void Speak(byte[] data, Vector3 pos)
{
if(bot == null)
{
bot = GameManager.server.CreateEntity("assets/prefabs/player/player.prefab", pos) as BasePlayer;
bot.Spawn();
}
Server.Broadcast($"speak: {data.Length}");
NetWrite netWrite = Network.Net.sv.StartWrite();
netWrite.PacketID(Message.Type.VoiceData);
netWrite.EntityID(bot.net.ID);
netWrite.BytesWithSize(data);
netWrite.Send(new SendInfo(new List<Connection>() { BasePlayer.activePlayerList[0].Connection })
{
priority = Priority.Immediate
});
}
However, if I assume I will use any (short, because the rasta has a limit) .mp to base64, paste into the code and convert to byte[], and transfer to Speak(), then absolutely nothing will happen, no errors, nothing, the bot will not even open its mouth.
If someone has worked with this, can you tell me what's wrong? :/