Beispiel #1
0
 public async Task RentHotel(IPlayer player, int hotelId, int apartmentId)
 {
     try
     {
         if (player == null || !player.Exists || hotelId <= 0 || apartmentId <= 0)
         {
             return;
         }
         int charId = User.GetPlayerOnline(player);
         if (charId <= 0)
         {
             return;
         }
         if (!ServerHotels.ExistHotelApartment(hotelId, apartmentId))
         {
             HUDHandler.SendNotification(player, 3, 5000, "Ein unerwarteter Fehler ist aufgetreten [HOTEL-001]."); return;
         }
         if (ServerHotels.HasCharacterAnApartment(charId))
         {
             HUDHandler.SendNotification(player, 3, 5000, $"Du besitzt bereits ein Hotelzimmer in dem Hotel '{ServerHotels.GetCharacterRentedHotelName(charId)}'."); return;
         }
         if (ServerHotels.GetApartmentOwner(hotelId, apartmentId) > 0)
         {
             HUDHandler.SendNotification(player, 3, 5000, "Dieses Apartment ist bereits vermietet."); return;
         }
         if (!CharactersBank.HasCharacterBankMainKonto(charId))
         {
             HUDHandler.SendNotification(player, 3, 5000, "Du hast noch kein Hauptkonto in der Bank festgelegt."); return;
         }
         int accNumber = CharactersBank.GetCharacterBankMainKonto(charId);
         if (accNumber <= 0)
         {
             return;
         }
         if (CharactersBank.GetBankAccountLockStatus(accNumber))
         {
             HUDHandler.SendNotification(player, 3, 5000, "Dein Bankkonto ist gesperrt."); return;
         }
         if (CharactersBank.GetBankAccountMoney(accNumber) < ServerHotels.GetApartmentPrice(hotelId, apartmentId))
         {
             HUDHandler.SendNotification(player, 3, 5000, $"Soviel Geld hast du auf deinem Konto nicht ({ServerHotels.GetApartmentPrice(hotelId, apartmentId)}$) - du hast {CharactersBank.GetBankAccountMoney(accNumber)}$"); return;
         }
         CharactersBank.SetBankAccountMoney(accNumber, CharactersBank.GetBankAccountMoney(accNumber) - ServerHotels.GetApartmentPrice(hotelId, apartmentId));
         ServerBankPapers.CreateNewBankPaper(accNumber, DateTime.Now.ToString("d", CultureInfo.CreateSpecificCulture("de-DE")), DateTime.Now.ToString("t", CultureInfo.CreateSpecificCulture("de-DE")), "Ausgehende Überweisung", "Hotelzahlung", $"Zimmerbuchung: {apartmentId}", $"+{ServerHotels.GetApartmentPrice(hotelId, apartmentId)}$", "Bankeinzug");
         ServerHotels.SetApartmentOwner(hotelId, apartmentId, charId);
         HUDHandler.SendNotification(player, 2, 5000, $"Sie haben sich das Zimmer mit der Zimmernummer '{apartmentId}' erfolgreich gemietet (Kosten: {ServerHotels.GetApartmentPrice(hotelId, apartmentId)}$). Dieses Zimmer läuft automatisch nach {ServerHotels.GetApartmentRentHours(hotelId, apartmentId)} Stunden ab.");
     }
     catch (Exception e)
     {
         Alt.Log($"{e}");
     }
 }
Beispiel #2
0
 public async Task EnterHotel(IPlayer player, int hotelId, int apartmentId)
 {
     try
     {
         if (player == null || !player.Exists || hotelId <= 0 || apartmentId <= 0)
         {
             return;
         }
         int charId = User.GetPlayerOnline(player);
         if (charId <= 0)
         {
             return;
         }
         if (!ServerHotels.ExistHotelApartment(hotelId, apartmentId))
         {
             HUDHandler.SendNotification(player, 3, 5000, "Ein unerwarteter Fehler ist aufgetreten [HOTEL-001]."); return;
         }
         if (ServerHotels.GetApartmentOwner(hotelId, apartmentId) <= 0)
         {
             HUDHandler.SendNotification(player, 3, 5000, "Fehler: Dieses Zimmer ist nicht vermietet."); return;
         }
         var hotel = ServerHotels.ServerHotelsApartments_.FirstOrDefault(x => x.hotelId == hotelId && x.id == apartmentId);
         if (hotel == null)
         {
             return;
         }
         if (!player.Position.IsInRange(ServerHotels.GetHotelPosition(hotelId, apartmentId), 3f))
         {
             return;
         }
         if (hotel.isLocked)
         {
             HUDHandler.SendNotification(player, 3, 5000, "Fehler: Das Zimmer ist abgeschlossen."); return;
         }
         if (!ServerHouses.ExistInteriorId(hotel.interiorId))
         {
             return;
         }
         player.Position  = ServerHouses.GetInteriorExitPosition(hotel.interiorId);
         player.Dimension = 5000 + apartmentId;
     }
     catch (Exception e)
     {
         Alt.Log($"{e}");
     }
 }
Beispiel #3
0
 public static async Task LockHotel(IPlayer player, int hotelId, int apartmentId)
 {
     try
     {
         if (player == null || !player.Exists || hotelId <= 0 || apartmentId <= 0)
         {
             return;
         }
         int charId = User.GetPlayerOnline(player);
         if (charId <= 0)
         {
             return;
         }
         if (!ServerHotels.ExistHotelApartment(hotelId, apartmentId))
         {
             HUDHandler.SendNotification(player, 3, 5000, "Ein unerwarteter Fehler ist aufgetreten [HOTEL-001]."); return;
         }
         if (!ServerHotels.HasCharacterAnApartment(charId))
         {
             HUDHandler.SendNotification(player, 3, 5000, $"Du besitzt hier kein Zimmer."); return;
         }
         if (ServerHotels.GetApartmentOwner(hotelId, apartmentId) != charId)
         {
             HUDHandler.SendNotification(player, 3, 5000, $"Du besitzt hier kein Zimmer."); return;
         }
         var hotel = ServerHotels.ServerHotelsApartments_.FirstOrDefault(x => x.hotelId == hotelId && x.id == apartmentId);
         if (hotel == null)
         {
             return;
         }
         if (hotel.isLocked)
         {
             HUDHandler.SendNotification(player, 2, 2500, $"Du hast dein Zimmer aufgeschlossen");
         }
         else
         {
             HUDHandler.SendNotification(player, 4, 2500, $"Du hast dein Zimmer abgeschlossen");
         }
         hotel.isLocked = !hotel.isLocked;
     }
     catch (Exception e)
     {
         Alt.Log($"{e}");
     }
 }
Beispiel #4
0
        public async Task PressU(IPlayer player)
        {
            try
            {
                lock (player)
                {
                    if (player == null || !player.Exists)
                    {
                        return;
                    }
                    int charId = User.GetPlayerOnline(player);
                    if (charId <= 0)
                    {
                        return;
                    }
                    if (player.HasPlayerHandcuffs() || player.HasPlayerRopeCuffs())
                    {
                        HUDHandler.SendNotification(player, 3, 5000, "Wie willst du das mit Handschellen/Fesseln machen?"); return;
                    }

                    ClassicColshape serverDoorLockCol = (ClassicColshape)ServerDoors.ServerDoorsLockColshapes_.FirstOrDefault(x => ((ClassicColshape)x).IsInRange((ClassicPlayer)player));
                    if (serverDoorLockCol != null)
                    {
                        var doorColData = ServerDoors.ServerDoors_.FirstOrDefault(x => x.id == (int)serverDoorLockCol.GetColShapeId());
                        if (doorColData != null)
                        {
                            string doorKey  = doorColData.doorKey;
                            string doorKey2 = doorColData.doorKey2;
                            if (doorKey == null || doorKey2 == null)
                            {
                                return;
                            }
                            if (!CharactersInventory.ExistCharacterItem(charId, doorKey, "inventory") && !CharactersInventory.ExistCharacterItem(charId, doorKey, "backpack") && !CharactersInventory.ExistCharacterItem(charId, doorKey2, "inventory") && !CharactersInventory.ExistCharacterItem(charId, doorKey2, "backpack"))
                            {
                                return;
                            }

                            if (!doorColData.state)
                            {
                                HUDHandler.SendNotification(player, 4, 1500, "Tür abgeschlossen.");
                            }
                            else
                            {
                                HUDHandler.SendNotification(player, 2, 1500, "Tür aufgeschlossen.");
                            }
                            doorColData.state = !doorColData.state;
                            Alt.EmitAllClients("Client:DoorManager:ManageDoor", doorColData.hash, new Position(doorColData.posX, doorColData.posY, doorColData.posZ), (bool)doorColData.state);
                            return;
                        }
                    }

                    if (player.Dimension >= 5000)
                    {
                        int houseInteriorCount = ServerHouses.GetMaxInteriorsCount();
                        for (var i = 1; i <= houseInteriorCount; i++)
                        {
                            if (player.Dimension >= 5000 && player.Dimension < 10000 && player.Position.IsInRange(ServerHouses.GetInteriorExitPosition(i), 2f))
                            {
                                //Hotel abschließen / aufschließen
                                if (player.Dimension - 5000 <= 0)
                                {
                                    continue;
                                }
                                int apartmentId = player.Dimension - 5000;
                                int hotelId     = ServerHotels.GetHotelIdByApartmentId(apartmentId);
                                if (hotelId <= 0 || apartmentId <= 0)
                                {
                                    continue;
                                }
                                if (!ServerHotels.ExistHotelApartment(hotelId, apartmentId))
                                {
                                    HUDHandler.SendNotification(player, 3, 5000, "Ein unerwarteter Fehler ist aufgetreten [HOTEL-001]."); return;
                                }
                                if (ServerHotels.GetApartmentOwner(hotelId, apartmentId) != charId)
                                {
                                    HUDHandler.SendNotification(player, 3, 5000, "Du hast keinen Schlüssel."); return;
                                }
                                HotelHandler.LockHotel(player, hotelId, apartmentId);
                                return;
                            }
                            else if (player.Dimension >= 10000 && player.Position.IsInRange(ServerHouses.GetInteriorExitPosition(i), 2f))
                            {
                                //Haus abschließen / aufschließen
                                if (player.Dimension - 10000 <= 0)
                                {
                                    continue;
                                }
                                int houseId = player.Dimension - 10000;
                                if (houseId <= 0)
                                {
                                    continue;
                                }
                                if (!ServerHouses.ExistHouse(houseId))
                                {
                                    HUDHandler.SendNotification(player, 3, 5000, "Ein unerwarteter Fehler ist aufgetreten [HOUSE-001]."); return;
                                }
                                if (ServerHouses.GetHouseOwner(houseId) != charId && !ServerHouses.IsCharacterRentedInHouse(charId, houseId))
                                {
                                    HUDHandler.SendNotification(player, 3, 5000, "Dieses Haus gehört nicht dir und / oder du bist nicht eingemietet."); return;
                                }
                                HouseHandler.LockHouse(player, houseId);
                                return;
                            }
                        }
                    }

                    var houseEntrance = ServerHouses.ServerHouses_.FirstOrDefault(x => ((ClassicColshape)x.entranceShape).IsInRange((ClassicPlayer)player));
                    if (houseEntrance != null)
                    {
                        HouseHandler.LockHouse(player, houseEntrance.id);
                    }
                }
            }
            catch (Exception e)
            {
                Alt.Log($"{e}");
            }
        }