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}"); } }
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}"); } }
internal static void openStorage(IPlayer player) { try { if (player == null || !player.Exists) { return; } int charId = User.GetPlayerOnline(player); if (charId <= 0) { return; } if (!ServerHotels.HasCharacterAnApartment(charId)) { return; } int dimension = player.Dimension; if (dimension <= 5000) { return; } int apartmentId = dimension - 5000; int hotelId = ServerHotels.GetHotelIdByApartmentId(apartmentId); if (apartmentId <= 0 || hotelId <= 0 || !ServerHotels.ExistHotelApartment(hotelId, apartmentId)) { return; } var hotelStorageContent = ServerHotels.GetServerHotelStorageItems(apartmentId); //Apartment Items var characterInvArray = CharactersInventory.GetCharacterInventory(charId); //Spieler Inventar player.EmitLocked("Client:FactionStorage:openCEF", charId, apartmentId, "hotel", characterInvArray, hotelStorageContent); } catch (Exception e) { Alt.Log($"{e}"); } }