sell house
This commit is contained in:
@@ -293,12 +293,6 @@ namespace ReallifeGamemode.Server.Managers
|
||||
|
||||
House house = GetHouseById(user.HouseId.Value, dbContext);
|
||||
|
||||
if (user.HouseId == null)
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Du besitzt kein Haus");
|
||||
return;
|
||||
}
|
||||
|
||||
HouseRental rental = dbContext.HouseRentals.Where(h => h.HouseId == house.Id && h.UserId == target.Id).FirstOrDefault();
|
||||
if (rental == null)
|
||||
{
|
||||
@@ -376,6 +370,34 @@ namespace ReallifeGamemode.Server.Managers
|
||||
player.SendNotification("~g~Du hast den Mietvertrag gekündigt.");
|
||||
house.User?.SendNotification($"~y~{player.Name}~s~ hat seinen Mietvertrag gekündigt.");
|
||||
|
||||
RemoveHouse(house);
|
||||
LoadHouse(house);
|
||||
|
||||
SendClientHouseData(player, house);
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("CLIENT:House_SellHouse")]
|
||||
public void HouseManagerSellHouseEvent(Client player)
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
User user = player.GetUser(dbContext);
|
||||
if (user.HouseId == null)
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Du besitzt kein Haus");
|
||||
return;
|
||||
}
|
||||
|
||||
House house = GetHouseById(user.HouseId.Value, dbContext);
|
||||
|
||||
house.OwnerId = null;
|
||||
user.HouseId = null;
|
||||
|
||||
dbContext.SaveChanges();
|
||||
|
||||
player.SendChatMessage("Du hast dein Haus verkauft");
|
||||
|
||||
SendClientHouseData(player, house);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user