private async void OnServerEnablePlayer(IPlayer player) { var health = await AltAsync.GetHealthAsync(player); VoiceClient voiceClient; lock (_voiceClients) { voiceClient = new VoiceClient(player, GetTeamSpeakName(player), Configuration.VoiceRanges[1], health > 100); if (_voiceClients.ContainsKey(player)) { _voiceClients[player] = voiceClient; } else { _voiceClients.TryAdd(player, voiceClient); } } player.EmitLocked("SaltyChat:Initialize", new ClientInitData(voiceClient.TeamSpeakName)); var voiceClients = new List <VoiceClient>(); lock (_voiceClients) { foreach (var(key, value) in _voiceClients.Where(c => c.Key.Id != player.Id)) { voiceClients.Add(new VoiceClient(key, value.TeamSpeakName, value.VoiceRange, value.IsAlive, key.Position)); key.EmitLocked("SaltyChat:UpdateClient", player, voiceClient.TeamSpeakName, voiceClient.VoiceRange, voiceClient.IsAlive, player.Position); } } player.EmitLocked("SaltyChat:SyncClients", new ClientSyncData(voiceClients)); await Task.CompletedTask; }