public async Task tryCall(ClassicPlayer player, int targetPhoneNumber) { try { if (player == null || !player.Exists || player.CharacterId <= 0 || targetPhoneNumber <= 0 || !CharactersInventory.ExistCharacterItem(player.CharacterId, "Smartphone", "inventory") || CharactersInventory.GetCharacterItemAmount(player.CharacterId, "Smartphone", "inventory") <= 0 || !Characters.IsCharacterPhoneEquipped(player.CharacterId) || Characters.IsCharacterPhoneFlyModeEnabled(player.CharacterId) || Characters.GetCharacterPhonenumber(player.CharacterId) <= 0 || Characters.IsCharacterUnconscious(player.CharacterId) || player.HasPlayerHandcuffs() || player.HasPlayerRopeCuffs() || Characters.GetCharacterCurrentlyRecieveCaller(player.CharacterId) != 0 || Characters.GetCharacterPhoneTargetNumber(player.CharacterId) != 0) { return; } if (ServerFactions.IsNumberAFactionNumber(targetPhoneNumber)) { int factionId = ServerFactions.GetFactionIdByServiceNumber(targetPhoneNumber); if (factionId <= 0) { player.EmitLocked("Client:Smartphone:ShowPhoneCallError", 1); return; } int currentOwnerId = ServerFactions.GetCurrentServicePhoneOwner(factionId); if (currentOwnerId <= 0) { player.EmitLocked("Client:Smartphone:ShowPhoneCallError", 2); return; } ClassicPlayer targetServicePlayer = (ClassicPlayer)Alt.Server.GetPlayers().ToList().FirstOrDefault(x => x != null && x.Exists && ((ClassicPlayer)x).CharacterId == currentOwnerId); if (targetServicePlayer == null || !targetServicePlayer.Exists || !Characters.IsCharacterPhoneEquipped(currentOwnerId) || Characters.IsCharacterPhoneFlyModeEnabled(currentOwnerId)) { ServerFactions.sendMsg(factionId, "Da die Leitstelle nicht erreichbar war, wurde die Nummer zurückgesetzt. Jemand anderes sollte die Leitstelle nun übernehmen."); ServerFactions.UpdateCurrentServicePhoneOwner(factionId, 0); player.EmitLocked("Client:Smartphone:ShowPhoneCallError", 2); return; } targetPhoneNumber = Characters.GetCharacterPhonenumber(currentOwnerId); if (!Characters.ExistPhoneNumber(targetPhoneNumber)) { ServerFactions.sendMsg(factionId, "Da die Leitstelle nicht erreichbar war, wurde die Nummer zurückgesetzt. Jemand anderes sollte die Leitstelle nun übernehmen."); ServerFactions.UpdateCurrentServicePhoneOwner(factionId, 0); player.EmitLocked("Client:Smartphone:ShowPhoneCallError", 2); return; } if (Characters.GetCharacterPhoneTargetNumber(currentOwnerId) != 0 || Characters.GetCharacterCurrentlyRecieveCaller(currentOwnerId) != 0) { player.EmitLocked("Client:Smartphone:ShowPhoneCallError", 3); return; } Characters.SetCharacterCurrentlyRecieveCallState(currentOwnerId, player.CharacterId); Characters.SetCharacterCurrentlyRecieveCallState(player.CharacterId, currentOwnerId); targetServicePlayer.EmitLocked("Client:Smartphone:showPhoneReceiveCall", Characters.GetCharacterPhonenumber(player.CharacterId)); return; } if (!Characters.ExistPhoneNumber(targetPhoneNumber)) { player.EmitLocked("Client:Smartphone:ShowPhoneCallError", 1); //HUDHandler.SendNotification(player, 4, 2500, "Kein Anschluss unter dieser Nummer.."); return; } ClassicPlayer targetPlayer = (ClassicPlayer)Alt.Server.GetPlayers().ToList().FirstOrDefault(x => x != null && x.Exists && ((ClassicPlayer)x).CharacterId > 0 && Characters.GetCharacterPhonenumber(((ClassicPlayer)x).CharacterId) == targetPhoneNumber); if (targetPlayer == null || !targetPlayer.Exists || !Characters.IsCharacterPhoneEquipped(targetPlayer.CharacterId) || Characters.IsCharacterPhoneFlyModeEnabled(targetPlayer.CharacterId)) { player.EmitLocked("Client:Smartphone:ShowPhoneCallError", 2); //HUDHandler.SendNotification(player, 4, 2500, "Der angerufene Teilnehmer ist nicht erreichbar.."); return; } if (Characters.GetCharacterPhoneTargetNumber(targetPlayer.CharacterId) != 0 || Characters.GetCharacterCurrentlyRecieveCaller(targetPlayer.CharacterId) != 0) { player.EmitLocked("Client:Smartphone:ShowPhoneCallError", 3); //HUDHandler.SendNotification(player, 4, 2500, "Der angegebene Anschluss ist besetzt.."); return; } //Characters.SetCharacterTargetPhoneNumber(player.CharacterId, targetPhoneNumber); Characters.SetCharacterCurrentlyRecieveCallState(targetPlayer.CharacterId, player.CharacterId); Characters.SetCharacterCurrentlyRecieveCallState(player.CharacterId, targetPlayer.CharacterId); targetPlayer.EmitLocked("Client:Smartphone:showPhoneReceiveCall", Characters.GetCharacterPhonenumber(player.CharacterId)); } catch (Exception e) { Alt.Log($"{e}"); } }