public async Task UnrentHouse(IPlayer player, int houseId) { try { if (player == null || !player.Exists || houseId <= 0) { return; } int charId = (int)player.GetCharacterMetaId(); if (charId <= 0) { return; } if (!ServerHouses.ExistHouse(houseId) || ServerHouses.GetHouseOwner(houseId) <= 0) { return; } if (!ServerHouses.IsCharacterRentedInAnyHouse(charId) || !ServerHouses.IsCharacterRentedInHouse(charId, houseId)) { return; } ServerHouses.RemoveServerHouseRenter(houseId, charId); HUDHandler.SendNotification(player, 2, 3000, "Du hast dich aus dem Haus ausgemietet."); } catch (Exception e) { Alt.Log($"{e}"); } }
public async Task RemoveRenter(IPlayer player, int houseId, int renterId) { try { if (player == null || !player.Exists || houseId <= 0 || renterId <= 0) { return; } int charId = (int)player.GetCharacterMetaId(); if (charId <= 0) { return; } int dimension = player.Dimension; if (dimension <= 10000) { return; } int dhouseId = dimension - 10000; if (dhouseId <= 0 || dhouseId != houseId || !ServerHouses.ExistHouse(houseId)) { return; } if (ServerHouses.GetHouseOwner(houseId) != charId) { HUDHandler.SendNotification(player, 4, 5000, "Fehler: Du bist nicht der Hausbesitzer."); return; } if (!ServerHouses.IsCharacterRentedInAnyHouse(renterId) || !ServerHouses.IsCharacterRentedInHouse(renterId, houseId)) { HUDHandler.SendNotification(player, 4, 5000, "Fehler: Dieser Spieler ist nicht in deinem Haus eingemietet."); return; } ServerHouses.RemoveServerHouseRenter(houseId, renterId); HUDHandler.SendNotification(player, 2, 2000, $"Du hast den Mieter {Characters.GetCharacterName(renterId)} erfolgreich gekündigt."); foreach (var renterPlayer in Alt.Server.GetPlayers().ToList().Where(x => x != null && x.Exists && x.GetCharacterMetaId() == (ulong)renterId)) { HUDHandler.SendNotification(renterPlayer, 3, 2000, $"Dein Mietvertrag in dem Haus '{ServerHouses.GetHouseStreet(houseId)}' wurde gekündigt."); break; } } catch (Exception e) { Alt.Log($"{e}"); } }