コード例 #1
0
ファイル: SmartphoneHandler.cs プロジェクト: h04X-2K/ValeaRP
 public async Task requestPoliceAppMostWanteds(ClassicPlayer player)
 {
     try
     {
         if (player == null || !player.Exists || player.CharacterId <= 0 || !ServerFactions.IsCharacterInAnyFaction(player.CharacterId) || !ServerFactions.IsCharacterInFactionDuty(player.CharacterId) || (ServerFactions.GetCharacterFactionId(player.CharacterId) != 2 && ServerFactions.GetCharacterFactionId(player.CharacterId) != 12))
         {
             return;
         }
         if (ServerFactions.GetCharacterFactionId(player.CharacterId) == 2 && ServerFactions.GetCharacterFactionRank(player.CharacterId) < 6)
         {
             HUDHandler.SendNotification(player, 3, 2500, "Keine Berechtigung: ab Rang 6."); return;
         }
         string mostWantedList = JsonConvert.SerializeObject(Characters.PlayerCharacters.ToList().Where(x => User.IsCharacterOnline(x.charId) && CharactersWanteds.HasCharacterWanteds(x.charId) && Characters.IsCharacterPhoneEquipped(x.charId)).Select(x => new
         {
             description = $"{x.charname} - {CharactersWanteds.GetCharacterWantedFinalJailTime(x.charId)} Hafteinheiten",
             posX        = $"{Characters.GetCharacterLastPosition(x.charId).X}",
             posY        = $"{Characters.GetCharacterLastPosition(x.charId).Y}",
         }).OrderBy(x => x.description).ToList());
         player.EmitLocked("Client:Smartphone:setPoliceAppMostWanteds", mostWantedList);
     }
     catch (Exception e)
     {
         Alt.Log($"{e}");
     }
 }
コード例 #2
0
        public async Task WithdrawFactionMoney(IPlayer player, string type, int factionId, int moneyAmount) //Type: faction | company
        {
            try
            {
                if (player == null || !player.Exists || factionId <= 0 || moneyAmount < 1 || type == "")
                {
                    return;
                }
                if (type != "faction" && type != "company")
                {
                    return;
                }
                int charid = User.GetPlayerOnline(player);
                if (charid == 0)
                {
                    return;
                }

                if (type == "faction")
                {
                    if (!ServerFactions.IsCharacterInAnyFaction(charid))
                    {
                        HUDHandler.SendNotification(player, 4, 5000, "Du bist in keiner Fraktion und hast keine Berechtigung dazu."); return;
                    }
                    if (factionId != ServerFactions.GetCharacterFactionId(charid))
                    {
                        HUDHandler.SendNotification(player, 4, 5000, "Ein unerwarteter Fehler ist aufgetreten. [FACTIONBANK-001]"); return;
                    }
                    if (ServerFactions.GetCharacterFactionRank(charid) != ServerFactions.GetFactionMaxRankCount(factionId) && ServerFactions.GetCharacterFactionRank(charid) != ServerFactions.GetFactionMaxRankCount(factionId) - 1)
                    {
                        HUDHandler.SendNotification(player, 3, 5000, "Du hast nicht den benötigten Rang um auf das Fraktionskonto zuzugreifen."); return;
                    }
                    if (ServerFactions.GetFactionBankMoney(factionId) < moneyAmount)
                    {
                        HUDHandler.SendNotification(player, 3, 5000, "Soviel Geld ist auf dem Fraktionskonto nicht vorhanden."); return;
                    }
                    ServerFactions.SetFactionBankMoney(factionId, ServerFactions.GetFactionBankMoney(factionId) - moneyAmount);
                    CharactersInventory.AddCharacterItem(charid, "Bargeld", moneyAmount, "inventory");
                    HUDHandler.SendNotification(player, 2, 5000, $"Du hast erfolgreich {moneyAmount}$ vom Fraktionskonto abgebucht.");
                    LoggingService.NewFactionLog(factionId, charid, 0, "bank", $"{Characters.GetCharacterName(charid)} ({charid}) hat {moneyAmount}$ vom Fraktionskonto abgebucht.");
                    return;
                }
                else if (type == "company")
                {
                    if (!ServerCompanys.IsCharacterInAnyServerCompany(charid))
                    {
                        HUDHandler.SendNotification(player, 4, 5000, "Du bist in keinem Unternehmen und hast keine Berechtigung dazu."); return;
                    }
                    if (factionId != ServerCompanys.GetCharacterServerCompanyId(charid))
                    {
                        HUDHandler.SendNotification(player, 4, 5000, "Ein unerwarteter Fehler ist aufgetreten. [FACTIONBANK-0001]"); return;
                    }
                    if (ServerCompanys.GetCharacterServerCompanyRank(charid) < 1)
                    {
                        HUDHandler.SendNotification(player, 3, 5000, "Du hast nicht den benötigten Rang um auf das Unternehmenskonto zuzugreifen."); return;
                    }
                    if (ServerCompanys.GetServerCompanyMoney(factionId) < moneyAmount)
                    {
                        HUDHandler.SendNotification(player, 3, 5000, "Soviel Geld ist auf dem Unternehmenskonto nicht vorhanden."); return;
                    }
                    ServerCompanys.SetServerCompanyMoney(factionId, ServerCompanys.GetServerCompanyMoney(factionId) - moneyAmount);
                    CharactersInventory.AddCharacterItem(charid, "Bargeld", moneyAmount, "inventory");
                    HUDHandler.SendNotification(player, 2, 5000, $"Du hast erfolgreich {moneyAmount}$ vom Unternehmenskonto abgebucht.");
                    LoggingService.NewCompanyLog(factionId, charid, 0, "bank", $"{Characters.GetCharacterName(charid)} ({charid}) hat {moneyAmount} vom Unternehmenskonto abgebucht.");
                    return;
                }
            }
            catch (Exception e)
            {
                Alt.Log($"{e}");
            }
        }
コード例 #3
0
ファイル: TimerHandler.cs プロジェクト: h04X-2K/ValeaRP
        public static async void OnEntityTimer(object sender, ElapsedEventArgs e)
        {
            try
            {
                Console.WriteLine($"Timer - Thread = {Thread.CurrentThread.ManagedThreadId}");
                Stopwatch stopwatch = new Stopwatch();
                stopwatch.Start();
                foreach (IVehicle Veh in Alt.Server.GetVehicles().ToList())
                {
                    if (Veh == null || !Veh.Exists)
                    {
                        continue;
                    }
                    using (var vRef = new VehicleRef(Veh))
                    {
                        if (!vRef.Exists)
                        {
                            continue;
                        }
                        lock (Veh)
                        {
                            if (Veh == null || !Veh.Exists)
                            {
                                continue;
                            }
                            ulong vehID = Veh.GetVehicleId();
                            if (vehID <= 0)
                            {
                                continue;
                            }
                            ServerVehicles.SaveVehiclePositionAndStates(Veh);
                            if (Veh.EngineOn == true)
                            {
                                ServerVehicles.SetVehicleFuel(Veh, ServerVehicles.GetVehicleFuel(Veh) - 0.03f);
                            }
                        }
                    }
                }

                stopwatch.Stop();
                Alt.Log($"OnEntityTimer: Vehicle Foreach benötigte: {stopwatch.Elapsed}");

                stopwatch.Reset();
                stopwatch.Start();
                foreach (IPlayer player in Alt.Server.GetPlayers().ToList())
                {
                    if (player == null)
                    {
                        continue;
                    }
                    using (var playerReference = new PlayerRef(player))
                    {
                        if (!playerReference.Exists)
                        {
                            return;
                        }
                        if (player == null || !player.Exists)
                        {
                            continue;
                        }
                        lock (player)
                        {
                            if (player == null || !player.Exists)
                            {
                                continue;
                            }
                            int charId = User.GetPlayerOnline(player);
                            if (charId > 0)
                            {
                                Characters.SetCharacterLastPosition(charId, player.Position, player.Dimension);
                                if (User.IsPlayerBanned(player))
                                {
                                    player.kickWithMessage($"Du bist gebannt. (Grund: {User.GetPlayerBanReason(player)}).");
                                }
                                Characters.SetCharacterHealth(charId, player.Health);
                                Characters.SetCharacterArmor(charId, player.Armor);
                                WeatherHandler.SetRealTime(player);
                                if (player.IsInVehicle)
                                {
                                    player.EmitLocked("Client:HUD:GetDistanceForVehicleKM"); HUDHandler.SendInformationToVehicleHUD(player);
                                }
                                Characters.IncreaseCharacterPaydayTime(charId);

                                if (Characters.IsCharacterUnconscious(charId))
                                {
                                    int unconsciousTime = Characters.GetCharacterUnconsciousTime(charId);
                                    if (unconsciousTime > 0)
                                    {
                                        Characters.SetCharacterUnconscious(charId, true, unconsciousTime - 1);
                                    }
                                    else if (unconsciousTime <= 0)
                                    {
                                        Characters.SetCharacterUnconscious(charId, false, 0);
                                        DeathHandler.closeDeathscreen(player);
                                        player.Spawn(new Position(355.54285f, -596.33405f, 28.75768f));
                                        player.Health = player.MaxHealth;
                                    }
                                }

                                if (Characters.IsCharacterFastFarm(charId))
                                {
                                    int fastFarmTime = Characters.GetCharacterFastFarmTime(charId);
                                    if (fastFarmTime > 0)
                                    {
                                        Characters.SetCharacterFastFarm(charId, true, fastFarmTime - 1);
                                    }
                                    else if (fastFarmTime <= 0)
                                    {
                                        Characters.SetCharacterFastFarm(charId, false, 0);
                                    }
                                }

                                if (Characters.IsCharacterInJail(charId))
                                {
                                    int jailTime = Characters.GetCharacterJailTime(charId);
                                    if (jailTime > 0)
                                    {
                                        Characters.SetCharacterJailTime(charId, true, jailTime - 1);
                                    }
                                    else if (jailTime <= 0)
                                    {
                                        if (CharactersWanteds.HasCharacterWanteds(charId))
                                        {
                                            int jailTimes = CharactersWanteds.GetCharacterWantedFinalJailTime(charId);
                                            int jailPrice = CharactersWanteds.GetCharacterWantedFinalJailPrice(charId);
                                            if (CharactersBank.HasCharacterBankMainKonto(charId))
                                            {
                                                int accNumber = CharactersBank.GetCharacterBankMainKonto(charId);
                                                int bankMoney = CharactersBank.GetBankAccountMoney(accNumber);
                                                CharactersBank.SetBankAccountMoney(accNumber, bankMoney - jailPrice);
                                                HUDHandler.SendNotification(player, 1, 7500, $"Durch deine Inhaftierung wurden dir {jailPrice}$ vom Konto abgezogen.");
                                            }
                                            HUDHandler.SendNotification(player, 1, 7500, $"Du sitzt nun für {jailTimes} Minuten im Gefängnis.");
                                            Characters.SetCharacterJailTime(charId, true, jailTimes);
                                            CharactersWanteds.RemoveCharacterWanteds(charId);
                                            player.Position = new Position(1691.4594f, 2565.7056f, 45.556763f);
                                            if (Characters.GetCharacterGender(charId) == false)
                                            {
                                                player.EmitLocked("Client:SpawnArea:setCharClothes", 11, 5, 0);
                                                player.EmitLocked("Client:SpawnArea:setCharClothes", 3, 5, 0);
                                                player.EmitLocked("Client:SpawnArea:setCharClothes", 4, 7, 15);
                                                player.EmitLocked("Client:SpawnArea:setCharClothes", 6, 7, 0);
                                                player.EmitLocked("Client:SpawnArea:setCharClothes", 8, 1, 88);
                                            }
                                            else
                                            {
                                            }
                                        }
                                        else
                                        {
                                            Characters.SetCharacterJailTime(charId, false, 0);
                                            Characters.SetCharacterCorrectClothes(player);
                                            player.Position = new Position(1846.022f, 2585.8945f, 45.657f);
                                            HUDHandler.SendNotification(player, 1, 2500, "Du wurdest aus dem Gefängnis entlassen.");
                                        }
                                    }
                                }

                                if (Characters.GetCharacterPaydayTime(charId) >= 60)
                                {
                                    Characters.IncreaseCharacterPlayTimeHours(charId);
                                    Characters.ResetCharacterPaydayTime(charId);
                                    if (CharactersBank.HasCharacterBankMainKonto(charId))
                                    {
                                        int accountNumber = CharactersBank.GetCharacterBankMainKonto(charId);
                                        CharactersBank.SetBankAccountMoney(accountNumber, CharactersBank.GetBankAccountMoney(accountNumber) + 250); //250$ Stütze
                                        ServerBankPapers.CreateNewBankPaper(accountNumber, DateTime.Now.ToString("d", CultureInfo.CreateSpecificCulture("de-DE")), DateTime.Now.ToString("t", CultureInfo.CreateSpecificCulture("de-DE")), "Eingehende Überweisung", "Staat", "Arbeitslosengeld", "+250$", "Unbekannt");

                                        if (!Characters.IsCharacterCrimeFlagged(charId) && Characters.GetCharacterJob(charId) != "None" && DateTime.Now.Subtract(Convert.ToDateTime(Characters.GetCharacterLastJobPaycheck(charId))).TotalHours >= 12 && !ServerFactions.IsCharacterInAnyFaction(charId))
                                        {
                                            if (Characters.GetCharacterJobHourCounter(charId) >= ServerJobs.GetJobNeededHours(Characters.GetCharacterJob(charId)) - 1)
                                            {
                                                int jobCheck = ServerJobs.GetJobPaycheck(Characters.GetCharacterJob(charId));
                                                Characters.SetCharacterLastJobPaycheck(charId, DateTime.Now);
                                                Characters.ResetCharacterJobHourCounter(charId);
                                                CharactersBank.SetBankAccountMoney(accountNumber, CharactersBank.GetBankAccountMoney(accountNumber) + jobCheck);
                                                ServerBankPapers.CreateNewBankPaper(accountNumber, DateTime.Now.ToString("d", CultureInfo.CreateSpecificCulture("de-DE")), DateTime.Now.ToString("t", CultureInfo.CreateSpecificCulture("de-DE")), "Eingehende Überweisung", "Arbeitsamt", $"Gehalt: {Characters.GetCharacterJob(charId)}", $"+{jobCheck}$", "Unbekannt");
                                                HUDHandler.SendNotification(player, 1, 5000, $"Gehalt erhalten (Beruf: {Characters.GetCharacterJob(charId)} | Gehalt: {jobCheck}$)");
                                            }
                                            else
                                            {
                                                Characters.IncreaseCharacterJobHourCounter(charId);
                                            }
                                        }

                                        if (ServerFactions.IsCharacterInAnyFaction(charId) && ServerFactions.IsCharacterInFactionDuty(charId))
                                        {
                                            int factionid       = ServerFactions.GetCharacterFactionId(charId);
                                            int factionPayCheck = ServerFactions.GetFactionRankPaycheck(factionid, ServerFactions.GetCharacterFactionRank(charId));
                                            if (ServerFactions.GetFactionBankMoney(factionid) >= factionPayCheck)
                                            {
                                                ServerFactions.SetFactionBankMoney(factionid, ServerFactions.GetFactionBankMoney(factionid) - factionPayCheck);
                                                CharactersBank.SetBankAccountMoney(accountNumber, CharactersBank.GetBankAccountMoney(accountNumber) + factionPayCheck);
                                                HUDHandler.SendNotification(player, 1, 5000, $"Du hast deinen Lohn i.H.v. {factionPayCheck}$ erhalten ({ServerFactions.GetFactionRankName(factionid, ServerFactions.GetCharacterFactionRank(charId))})");
                                                ServerBankPapers.CreateNewBankPaper(accountNumber, DateTime.Now.ToString("d", CultureInfo.CreateSpecificCulture("de-DE")), DateTime.Now.ToString("t", CultureInfo.CreateSpecificCulture("de-DE")), "Eingehende Überweisung", $"{ServerFactions.GetFactionFullName(factionid)}", $"Gehalt: {ServerFactions.GetFactionRankName(factionid, ServerFactions.GetCharacterFactionRank(charId))}", $"+{factionPayCheck}$", "Dauerauftrag");
                                                LoggingService.NewFactionLog(factionid, charId, 0, "paycheck", $"{Characters.GetCharacterName(charId)} hat seinen Lohn i.H.v. {factionPayCheck}$ erhalten ({ServerFactions.GetFactionRankName(factionid, ServerFactions.GetCharacterFactionRank(charId))}).");
                                            }
                                            else
                                            {
                                                HUDHandler.SendNotification(player, 3, 5000, $"Deine Fraktion hat nicht genügend Geld um dich zu bezahlen ({factionPayCheck}$).");
                                            }
                                        }

                                        var playerVehicles = ServerVehicles.ServerVehicles_.Where(x => x.id > 0 && x.charid == charId && x.plate.Contains("NL"));
                                        int taxMoney       = 0;
                                        foreach (var i in playerVehicles)
                                        {
                                            if (!i.plate.Contains("NL"))
                                            {
                                                continue;
                                            }
                                            taxMoney += ServerAllVehicles.GetVehicleTaxes(i.hash);
                                        }

                                        if (playerVehicles != null && taxMoney > 0)
                                        {
                                            if (CharactersBank.GetBankAccountMoney(accountNumber) < taxMoney)
                                            {
                                                HUDHandler.SendNotification(player, 3, 5000, $"Deine Fahrzeugsteuern konnten nicht abgebucht werden ({taxMoney}$)");
                                            }
                                            else
                                            {
                                                CharactersBank.SetBankAccountMoney(accountNumber, CharactersBank.GetBankAccountMoney(accountNumber) - taxMoney);
                                                ServerBankPapers.CreateNewBankPaper(accountNumber, DateTime.Now.ToString("d", CultureInfo.CreateSpecificCulture("de-DE")), DateTime.Now.ToString("t", CultureInfo.CreateSpecificCulture("de-DE")), "Ausgehende Überweisung", "Zulassungsamt", $"Fahrzeugsteuer", $"-{taxMoney}$", "Bankeinzug");
                                                HUDHandler.SendNotification(player, 1, 5000, $"Du hast deine Fahrzeugsteuern i.H.v. {taxMoney}$ bezahlt.");
                                            }
                                        }
                                    }
                                    else
                                    {
                                        HUDHandler.SendNotification(player, 3, 5000, $"Dein Einkommen konnte nicht überwiesen werden da du kein Hauptkonto hast.");
                                    }
                                }
                            }
                        }
                    }
                }
                stopwatch.Stop();
                Alt.Log($"OnEntityTimer: Player Foreach benötigte: {stopwatch.Elapsed}");
            }
            catch (Exception ex)
            {
                Alt.Log($"{ex}");
            }
        }
コード例 #4
0
ファイル: KeyHandler.cs プロジェクト: h04X-2K/ValeaRP
        public async Task PressE(IPlayer player)
        {
            lock (player)
            {
                if (player == null || !player.Exists)
                {
                    return;
                }
                int charId = User.GetPlayerOnline(player);
                if (charId == 0)
                {
                    return;
                }

                ClassicColshape farmCol = (ClassicColshape)ServerFarmingSpots.ServerFarmingSpotsColshapes_.FirstOrDefault(x => ((ClassicColshape)x).IsInRange((ClassicPlayer)player));
                if (farmCol != null && !player.IsInVehicle)
                {
                    if (player.HasPlayerHandcuffs() || player.HasPlayerRopeCuffs())
                    {
                        HUDHandler.SendNotification(player, 3, 5000, "Wie willst du das mit Handschellen/Fesseln machen?"); return;
                    }
                    if (player.GetPlayerFarmingActionMeta() != "None")
                    {
                        return;
                    }
                    var farmColData = ServerFarmingSpots.ServerFarmingSpots_.FirstOrDefault(x => x.id == (int)farmCol.GetColShapeId());

                    if (farmColData != null)
                    {
                        if (farmColData.neededItemToFarm != "None")
                        {
                            if (!CharactersInventory.ExistCharacterItem(charId, farmColData.neededItemToFarm, "inventory") && !CharactersInventory.ExistCharacterItem(charId, farmColData.neededItemToFarm, "backpack"))
                            {
                                HUDHandler.SendNotification(player, 3, 3500, $"Zum Farmen benötigst du: {farmColData.neededItemToFarm}."); return;
                            }
                        }
                        player.SetPlayerFarmingActionMeta("farm");
                        FarmingHandler.FarmFieldAction(player, farmColData.itemName, farmColData.itemMinAmount, farmColData.itemMaxAmount, farmColData.animation, farmColData.duration);
                        return;
                    }
                }

                ClassicColshape farmProducerCol = (ClassicColshape)ServerFarmingSpots.ServerFarmingProducerColshapes_.FirstOrDefault(x => ((ClassicColshape)x).IsInRange((ClassicPlayer)player));
                if (farmProducerCol != null && !player.IsInVehicle)
                {
                    if (player.GetPlayerFarmingActionMeta() != "None")
                    {
                        HUDHandler.SendNotification(player, 3, 5000, $"Warte einen Moment."); return;
                    }
                    var farmColData = ServerFarmingSpots.ServerFarmingProducer_.FirstOrDefault(x => x.id == (int)farmProducerCol.GetColShapeId());
                    if (farmColData != null)
                    {
                        FarmingHandler.ProduceItem(player, farmColData.neededItem, farmColData.producedItem, farmColData.neededItemAmount, farmColData.producedItemAmount, farmColData.duration);
                        return;
                    }
                }

                if (((ClassicColshape)Minijobs.Elektrolieferant.Main.startJobShape).IsInRange((ClassicPlayer)player))
                {
                    Minijobs.Elektrolieferant.Main.StartMinijob(player);
                    return;
                }

                if (((ClassicColshape)Minijobs.Pilot.Main.startJobShape).IsInRange((ClassicPlayer)player))
                {
                    Minijobs.Pilot.Main.TryStartMinijob(player);
                    return;
                }

                if (((ClassicColshape)Minijobs.Müllmann.Main.startJobShape).IsInRange((ClassicPlayer)player))
                {
                    Minijobs.Müllmann.Main.StartMinijob(player);
                    return;
                }

                if (((ClassicColshape)Minijobs.Busfahrer.Main.startJobShape).IsInRange((ClassicPlayer)player))
                {
                    Minijobs.Busfahrer.Main.TryStartMinijob(player);
                    return;
                }

                var houseEntrance = ServerHouses.ServerHouses_.FirstOrDefault(x => ((ClassicColshape)x.entranceShape).IsInRange((ClassicPlayer)player));
                if (houseEntrance != null)
                {
                    HouseHandler.openEntranceCEF(player, houseEntrance.id);
                    return;
                }

                var hotelPos = ServerHotels.ServerHotels_.FirstOrDefault(x => player.Position.IsInRange(new Position(x.posX, x.posY, x.posZ), 2f));
                if (hotelPos != null && !player.IsInVehicle)
                {
                    HotelHandler.openCEF(player, hotelPos);
                    return;
                }

                if (player.Dimension >= 5000)
                {
                    int houseInteriorCount = ServerHouses.GetMaxInteriorsCount();
                    for (var i = 1; i <= houseInteriorCount; i++)
                    {
                        if (i > houseInteriorCount || i <= 0)
                        {
                            continue;
                        }
                        if ((player.Dimension >= 5000 && player.Dimension < 10000) && player.Position.IsInRange(ServerHouses.GetInteriorExitPosition(i), 2f))
                        {
                            //Apartment Leave
                            HotelHandler.LeaveHotel(player);
                            return;
                        }
                        else if ((player.Dimension >= 5000 && player.Dimension < 10000) && player.Position.IsInRange(ServerHouses.GetInteriorStoragePosition(i), 2f))
                        {
                            //Apartment Storage
                            HotelHandler.openStorage(player);
                            return;
                        }
                        else if (player.Dimension >= 10000 && player.Position.IsInRange(ServerHouses.GetInteriorExitPosition(i), 2f))
                        {
                            //House Leave
                            HouseHandler.LeaveHouse(player, i);
                            return;
                        }
                        else if (player.Dimension >= 10000 && player.Position.IsInRange(ServerHouses.GetInteriorStoragePosition(i), 2f))
                        {
                            //House Storage
                            HouseHandler.openStorage(player);
                            return;
                        }
                        else if (player.Dimension >= 10000 && player.Position.IsInRange(ServerHouses.GetInteriorManagePosition(i), 2f))
                        {
                            //Hausverwaltung
                            HouseHandler.openManageCEF(player);
                            return;
                        }
                    }
                }

                var teleportsPos = ServerItems.ServerTeleports_.FirstOrDefault(x => player.Position.IsInRange(new Position(x.posX, x.posY, x.posZ), 1.5f));
                if (teleportsPos != null && !player.IsInVehicle)
                {
                    player.Position = new Position(teleportsPos.targetX, teleportsPos.targetY, teleportsPos.targetZ + 0.5f);
                    return;
                }

                var shopPos = ServerShops.ServerShops_.FirstOrDefault(x => player.Position.IsInRange(new Position(x.posX, x.posY, x.posZ), 3f));
                if (shopPos != null && !player.IsInVehicle)
                {
                    if (player.HasPlayerHandcuffs() || player.HasPlayerRopeCuffs())
                    {
                        HUDHandler.SendNotification(player, 3, 5000, "Wie willst du das mit Handschellen/Fesseln machen?"); return;
                    }
                    ShopHandler.openShop(player, shopPos);
                    return;
                }

                var garagePos = ServerGarages.ServerGarages_.FirstOrDefault(x => player.Position.IsInRange(new Position(x.posX, x.posY, x.posZ), 2f));
                if (garagePos != null && !player.IsInVehicle)
                {
                    GarageHandler.OpenGarageCEF(player, garagePos.id);
                    return;
                }

                var clothesStoragePos = ServerClothesStorages.ServerClothesStorages_.ToList().FirstOrDefault(x => player.Position.IsInRange(new Position(x.posX, x.posY, x.posZ), 5f));
                if (clothesStoragePos != null && !player.IsInVehicle)
                {
                    ServerClothesStorages.RequestClothesStorage((ClassicPlayer)player, clothesStoragePos.id);
                    return;
                }

                var clothesShopPos = ServerClothesShops.ServerClothesShops_.FirstOrDefault(x => player.Position.IsInRange(new Position(x.posX, x.posY, x.posZ), 6f));
                if (clothesShopPos != null && !player.IsInVehicle)
                {
                    ShopHandler.openClothesShop((ClassicPlayer)player, clothesShopPos.id);
                    return;
                }

                var tattooShop = ServerTattooShops.ServerTattooShops_.ToList().FirstOrDefault(x => x.owner != 0 && player.Position.IsInRange(new Position(x.pedX, x.pedY, x.pedZ), 2.5f));
                if (tattooShop != null && !player.IsInVehicle)
                {
                    ShopHandler.openTattooShop((ClassicPlayer)player, tattooShop);
                    return;
                }

                var vehicleShopPos = ServerVehicleShops.ServerVehicleShops_.FirstOrDefault(x => player.Position.IsInRange(new Position(x.pedX, x.pedY, x.pedZ), 2f));
                if (vehicleShopPos != null && !player.IsInVehicle)
                {
                    if (vehicleShopPos.neededLicense != "None" && !Characters.HasCharacterPermission(charId, vehicleShopPos.neededLicense))
                    {
                        HUDHandler.SendNotification(player, 3, 5000, $"Du hast hier keinen Zugriff drauf."); return;
                    }
                    ShopHandler.OpenVehicleShop(player, vehicleShopPos.name, vehicleShopPos.id);
                    return;
                }

                var bankPos = ServerBanks.ServerBanks_.FirstOrDefault(x => player.Position.IsInRange(new Position(x.posX, x.posY, x.posZ), 1f));
                if (bankPos != null && !player.IsInVehicle)
                {
                    if (bankPos.zoneName == "Maze Bank Fraktion")
                    {
                        if (!ServerFactions.IsCharacterInAnyFaction(charId))
                        {
                            return;
                        }
                        if (ServerFactions.GetCharacterFactionRank(charId) != ServerFactions.GetFactionMaxRankCount(ServerFactions.GetCharacterFactionId(charId)) && ServerFactions.GetCharacterFactionRank(charId) != ServerFactions.GetFactionMaxRankCount(ServerFactions.GetCharacterFactionId(charId)) - 1)
                        {
                            return;
                        }
                        player.EmitLocked("Client:FactionBank:createCEF", "faction", ServerFactions.GetCharacterFactionId(charId), ServerFactions.GetFactionBankMoney(ServerFactions.GetCharacterFactionId(charId)));
                        return;
                    }
                    else if (bankPos.zoneName == "Maze Bank Company")
                    {
                        if (!ServerCompanys.IsCharacterInAnyServerCompany(charId))
                        {
                            return;
                        }
                        if (ServerCompanys.GetCharacterServerCompanyRank(charId) != 1 && ServerCompanys.GetCharacterServerCompanyRank(charId) != 2)
                        {
                            HUDHandler.SendNotification(player, 3, 5000, "Du hast kein Unternehmen auf welches du zugreifen kannst."); return;
                        }
                        player.EmitLocked("Client:FactionBank:createCEF", "company", ServerCompanys.GetCharacterServerCompanyId(charId), ServerCompanys.GetServerCompanyMoney(ServerCompanys.GetCharacterServerCompanyId(charId)));
                        return;
                    }
                    else
                    {
                        var bankArray = CharactersBank.GetCharacterBankAccounts(charId);
                        player.EmitLocked("Client:Bank:createBankAccountManageForm", bankArray, bankPos.zoneName);
                        return;
                    }
                }

                var barberPos = ServerBarbers.ServerBarbers_.FirstOrDefault(x => player.Position.IsInRange(new Position(x.posX, x.posY, x.posZ), 2f));
                if (barberPos != null && !player.IsInVehicle)
                {
                    player.EmitLocked("Client:Barber:barberCreateCEF", Characters.GetCharacterHeadOverlays(charId));
                    return;
                }

                if (player.Position.IsInRange(Constants.Positions.VehicleLicensing_Position, 3f))
                {
                    if (player.HasPlayerHandcuffs() || player.HasPlayerRopeCuffs())
                    {
                        HUDHandler.SendNotification(player, 3, 5000, "Wie willst du das mit Handschellen/Fesseln machen?"); return;
                    }
                    VehicleHandler.OpenLicensingCEF(player);
                    return;
                }

                if (ServerFactions.IsCharacterInAnyFaction(charId))
                {
                    int factionId      = ServerFactions.GetCharacterFactionId(charId);
                    var factionDutyPos = ServerFactions.ServerFactionPositions_.FirstOrDefault(x => x.factionId == factionId && x.posType == "duty" && player.Position.IsInRange(new Position(x.posX, x.posY, x.posZ), 2f));
                    if (factionDutyPos != null && !player.IsInVehicle)
                    {
                        bool isDuty = ServerFactions.IsCharacterInFactionDuty(charId);
                        ServerFactions.SetCharacterInFactionDuty(charId, !isDuty);
                        if (isDuty)
                        {
                            HUDHandler.SendNotification(player, 2, 5000, "Du hast dich erfolgreich vom Dienst abgemeldet.");
                        }
                        else
                        {
                            HUDHandler.SendNotification(player, 2, 5000, "Du hast dich erfolgreich zum Dienst angemeldet.");
                        }
                        if (factionId == 2 || factionId == 12)
                        {
                            SmartphoneHandler.RequestLSPDIntranet((ClassicPlayer)player);
                        }
                        return;
                    }

                    var factionStoragePos = ServerFactions.ServerFactionPositions_.FirstOrDefault(x => x.factionId == factionId && x.posType == "storage" && player.Position.IsInRange(new Position(x.posX, x.posY, x.posZ), 2f));
                    if (factionStoragePos != null && !player.IsInVehicle)
                    {
                        if (player.HasPlayerHandcuffs() || player.HasPlayerRopeCuffs())
                        {
                            HUDHandler.SendNotification(player, 3, 5000, "Wie willst du das mit Handschellen/Fesseln machen?"); return;
                        }
                        bool isDuty = ServerFactions.IsCharacterInFactionDuty(charId);
                        if (isDuty)
                        {
                            var factionStorageContent = ServerFactions.GetServerFactionStorageItems(factionId, charId); //Fraktionsspind Items
                            var CharacterInvArray     = CharactersInventory.GetCharacterInventory(charId);              //Spieler Inventar
                            player.EmitLocked("Client:FactionStorage:openCEF", charId, factionId, "faction", CharacterInvArray, factionStorageContent);
                            return;
                        }
                    }

                    var factionServicePhonePos = ServerFactions.ServerFactionPositions_.ToList().FirstOrDefault(x => x.factionId == factionId && x.posType == "servicephone" && player.Position.IsInRange(new Position(x.posX, x.posY, x.posZ), 2f));
                    if (factionServicePhonePos != null && !player.IsInVehicle && ServerFactions.IsCharacterInFactionDuty(charId))
                    {
                        ServerFactions.UpdateCurrentServicePhoneOwner(factionId, charId);
                        ServerFactions.sendMsg(factionId, $"{Characters.GetCharacterName(charId)} hat das Leitstellentelefon deiner Fraktion übernommen.");
                        return;
                    }
                }

                if (player.Position.IsInRange(Constants.Positions.Jobcenter_Position, 2.5f) && !Characters.IsCharacterCrimeFlagged(charId) && !player.IsInVehicle) //Arbeitsamt
                {
                    TownhallHandler.createJobcenterBrowser(player);
                    return;
                }

                if (player.Position.IsInRange(Constants.Positions.TownhallHouseSelector, 2.5f))
                {
                    TownhallHandler.openHouseSelector(player);
                    return;
                }

                if (player.Position.IsInRange(Constants.Positions.IdentityCardApply, 2.5f) && Characters.GetCharacterAccState(charId) == 0 && !player.IsInVehicle) //Rathaus IdentityCardApply
                {
                    TownhallHandler.tryCreateIdentityCardApplyForm(player);
                    return;
                }
            }
        }