haus system auf core geändert
This commit is contained in:
144
ReallifeGamemode.Server.Core/Commands/Admin/HouseCommand.cs
Normal file
144
ReallifeGamemode.Server.Core/Commands/Admin/HouseCommand.cs
Normal file
@@ -0,0 +1,144 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Server.Core.API;
|
||||
using ReallifeGamemode.Server.Core.Extensions;
|
||||
using ReallifeGamemode.Server.Core.Managers;
|
||||
using ReallifeGamemode.Server.Types;
|
||||
|
||||
namespace ReallifeGamemode.Server.Core.Commands.Admin
|
||||
{
|
||||
class HouseCommand : AdminCommand
|
||||
{
|
||||
public override string CommandName => "house";
|
||||
|
||||
protected override AdminLevel AdminLevel => AdminLevel.HEADADMIN;
|
||||
|
||||
public override string HelpText => "[add / remove / price / type / reloadhouses]";
|
||||
|
||||
public void Handle(IPlayer player, string option1, string option2 = null)
|
||||
{
|
||||
using var dbContext = GetDbContext();
|
||||
|
||||
option1 = option1?.ToLower();
|
||||
|
||||
var houseManager = Main.GetScript<HouseManager>();
|
||||
|
||||
if (option1 == "add")
|
||||
{
|
||||
House nearHouse = houseManager.GetNearHouse(player.Position, dbContext);
|
||||
if (nearHouse != null)
|
||||
{
|
||||
player.SendMessage("In der Nähe ist schon ein Haus", ChatPrefix.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
House house = new House()
|
||||
{
|
||||
Price = 0,
|
||||
Type = "Haus",
|
||||
X = (float)player.Position.X,
|
||||
Y = (float)player.Position.Y,
|
||||
Z = (float)player.Position.Z
|
||||
};
|
||||
|
||||
dbContext.Houses.Add(house);
|
||||
dbContext.SaveChanges();
|
||||
|
||||
houseManager.LoadHouse(house);
|
||||
|
||||
player.SendNotification("Das Haus wurde erstellt");
|
||||
|
||||
return;
|
||||
}
|
||||
else if (option1 == "remove")
|
||||
{
|
||||
House nearHouse = houseManager.GetNearHouse(player.Position, dbContext);
|
||||
if (nearHouse == null)
|
||||
{
|
||||
player.SendMessage("In deiner Nähe befindet sich kein Haus", ChatPrefix.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (nearHouse.OwnerId != null)
|
||||
{
|
||||
dbContext.Users.Where(u => u.Id == nearHouse.OwnerId).First().HouseId = null;
|
||||
}
|
||||
|
||||
foreach (HouseRental rental in dbContext.HouseRentals.Include(r => r.User).Where(r => r.HouseId == nearHouse.Id))
|
||||
{
|
||||
rental.User.NewPlayer.SendRawMessage("!{#81F7BE}* Dein Mietvertrag wurde administrativ aufgelöst!");
|
||||
dbContext.HouseRentals.Remove(rental);
|
||||
}
|
||||
|
||||
dbContext.Houses.Remove(nearHouse);
|
||||
dbContext.SaveChanges();
|
||||
|
||||
houseManager.RemoveHouse(nearHouse);
|
||||
|
||||
player.SendNotification("Das Haus wurde gelöscht");
|
||||
return;
|
||||
}
|
||||
else if (option1 == "price")
|
||||
{
|
||||
if (!int.TryParse(option2, out int price))
|
||||
{
|
||||
player.SendMessage("/house price [Price]", ChatPrefix.Usage);
|
||||
return;
|
||||
}
|
||||
|
||||
House nearHouse = houseManager.GetNearHouse(player.Position, dbContext);
|
||||
if (nearHouse == null)
|
||||
{
|
||||
player.SendMessage("In deiner Nähe befindet sich kein Haus", ChatPrefix.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
nearHouse.Price = price;
|
||||
dbContext.SaveChanges();
|
||||
|
||||
houseManager.RemoveHouse(nearHouse);
|
||||
houseManager.LoadHouse(nearHouse);
|
||||
|
||||
player.SendNotification("Der Hauspreis wurde gesetzt");
|
||||
return;
|
||||
}
|
||||
else if (option1 == "type")
|
||||
{
|
||||
if (option2 == null)
|
||||
{
|
||||
player.SendMessage("/house type [Type]", ChatPrefix.Usage);
|
||||
return;
|
||||
}
|
||||
|
||||
House nearHouse = houseManager.GetNearHouse(player.Position, dbContext);
|
||||
if (nearHouse == null)
|
||||
{
|
||||
player.SendMessage("In deiner Nähe befindet sich kein Haus", ChatPrefix.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
nearHouse.Type = option2;
|
||||
dbContext.SaveChanges();
|
||||
|
||||
houseManager.RemoveHouse(nearHouse);
|
||||
houseManager.LoadHouse(nearHouse);
|
||||
|
||||
player.SendNotification("Der Haustyp wurde gesetzt");
|
||||
|
||||
return;
|
||||
}
|
||||
else if (option1 == "reloadhouses")
|
||||
{
|
||||
houseManager.ReloadAllHouses();
|
||||
player.SendNotification("Alle Häuser wurden neu geladen");
|
||||
return;
|
||||
}
|
||||
|
||||
player.SendMessage("/house [add / remove / price / type / reloadhouses]", ChatPrefix.Usage);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,6 @@ namespace ReallifeGamemode.Server.Core.Commands
|
||||
Log = LogManager.GetLogger(this.GetType());
|
||||
}
|
||||
|
||||
protected DatabaseContext GetDbContext() => Main.GetDbContext();
|
||||
protected DatabaseContext GetDbContext(bool useLoggerFactory = true) => Main.GetDbContext(useLoggerFactory);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using ReallifeGamemode.Server.Core.API;
|
||||
using ReallifeGamemode.Server.Core.Extensions;
|
||||
|
||||
namespace ReallifeGamemode.Server.Core.Commands.User
|
||||
{
|
||||
@@ -9,7 +10,7 @@ namespace ReallifeGamemode.Server.Core.Commands.User
|
||||
{
|
||||
public override bool CanExecute(IPlayer player)
|
||||
{
|
||||
return player.GetSharedData("loggedIn", false);
|
||||
return player.IsLoggedIn();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace ReallifeGamemode.Server.Core
|
||||
}
|
||||
}
|
||||
|
||||
public static DatabaseContext GetDbContext(bool useLoggerFactory = false)
|
||||
public static DatabaseContext GetDbContext(bool useLoggerFactory = true)
|
||||
{
|
||||
return new DatabaseContext(useLoggerFactory);
|
||||
}
|
||||
|
||||
407
ReallifeGamemode.Server.Core/Managers/HouseManager.cs
Normal file
407
ReallifeGamemode.Server.Core/Managers/HouseManager.cs
Normal file
@@ -0,0 +1,407 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Server.Core.API;
|
||||
using ReallifeGamemode.Server.Types;
|
||||
using ReallifeGamemode.Server.Core.Extensions;
|
||||
using System.Linq;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using ReallifeGamemode.Server.Common;
|
||||
|
||||
namespace ReallifeGamemode.Server.Core.Managers
|
||||
{
|
||||
class HouseManager : Script
|
||||
{
|
||||
private readonly Dictionary<int, IMarker> houseMarkers = new Dictionary<int, IMarker>();
|
||||
private readonly Dictionary<int, ITextLabel> houseLabels = new Dictionary<int, ITextLabel>();
|
||||
private readonly Dictionary<int, IColShape> houseColShapes = new Dictionary<int, IColShape>();
|
||||
private readonly Dictionary<int, IBlip> houseBlips = new Dictionary<int, IBlip>();
|
||||
|
||||
private readonly Dictionary<int, List<IPlayer>> playerInColShape = new Dictionary<int, List<IPlayer>>();
|
||||
|
||||
public HouseManager()
|
||||
{
|
||||
EventHandler.RegisterClientEvent("House_BuyHouse", HouseManagerBuyHouseEvent);
|
||||
EventHandler.RegisterClientEvent("House_SetRentalFee", HouseManagerSetRentalFeeEvent);
|
||||
EventHandler.RegisterClientEvent("House_CancelUserRental", HouseManagerCancelUserRentalEvent);
|
||||
EventHandler.RegisterClientEvent("House_RentInHouse", HouseManagerRentInHouseEvent);
|
||||
EventHandler.RegisterClientEvent("House_CancelOwnRental", HouseManagerCancelOwnRentalEvent);
|
||||
EventHandler.RegisterClientEvent("House_SellHouse", HouseManagerSellHouseEvent);
|
||||
|
||||
LoadHouses();
|
||||
}
|
||||
|
||||
private void LoadHouses()
|
||||
{
|
||||
using var dbContext = GetDbContext();
|
||||
var houses = dbContext.Houses.Include(h => h.Owner);
|
||||
foreach (House house in houses)
|
||||
{
|
||||
LoadHouse(house);
|
||||
}
|
||||
}
|
||||
|
||||
public void LoadHouse(House house)
|
||||
{
|
||||
Position housePos = new Position(house.X, house.Y, house.Z);
|
||||
|
||||
playerInColShape[house.Id] = new List<IPlayer>();
|
||||
|
||||
houseMarkers[house.Id] = Api.Marker.CreateMarker(MarkerType.VerticalCylinder, housePos.Subtract(new Position(0, 0, 1.7)), new Position(), new Position(), 1.6f, Color.White);
|
||||
string text = $"~g~Zum Verkauf\n~s~{house.Type}\nPreis: ~y~{(house.Price == 0 ? "~r~Nicht verkäuflich" : house.Price.ToMoneyString())}";
|
||||
|
||||
if (house.OwnerId != null)
|
||||
{
|
||||
text = $"{house.Type}\n~s~Besitzer: ~y~{house.Owner.Name}";
|
||||
|
||||
if (house.RentalFee != 0)
|
||||
{
|
||||
text += $"\n~s~Mietpreis: ~g~{house.RentalFee.ToMoneyString()}";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//houseBlips[house.Id] = NAPI.Blip.CreateBlip(40, house.Position, 0.7f, 11, "Haus", shortRange: true); too many blips
|
||||
}
|
||||
|
||||
houseLabels[house.Id] = Api.TextLabel.CreateTextLabel(text, housePos, 10f, 1f, 0, new Color(255, 255, 255));
|
||||
|
||||
if (house.Price != 0)
|
||||
{
|
||||
houseColShapes[house.Id] = Api.ColShape.CreateCyclinder(housePos.Subtract(new Position(0, 0, 2)), 4.0f, 2f);
|
||||
|
||||
houseColShapes[house.Id].OnEntityEnter += HouseManager_OnEntityEnterColShape;
|
||||
houseColShapes[house.Id].OnEntityExit += HouseManager_OnEntityExitColShape;
|
||||
}
|
||||
}
|
||||
|
||||
private void HouseManager_OnEntityExitColShape(IColShape colShape, IPlayer client)
|
||||
{
|
||||
if (!client.IsLoggedIn() || client.IsInVehicle) return;
|
||||
if (!houseColShapes.ContainsValue(colShape))
|
||||
{
|
||||
return;
|
||||
}
|
||||
int houseId = houseColShapes.Where(p => p.Value.Handle == colShape.Handle).FirstOrDefault().Key;
|
||||
playerInColShape[houseId].Remove(client);
|
||||
|
||||
client.TriggerEvent("CloseHouseMenu");
|
||||
}
|
||||
|
||||
private void HouseManager_OnEntityEnterColShape(IColShape colShape, IPlayer client)
|
||||
{
|
||||
if (!client.IsLoggedIn() || client.IsInVehicle) return;
|
||||
if (!houseColShapes.ContainsValue(colShape))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
using (var dbContext = GetDbContext())
|
||||
{
|
||||
int houseId = houseColShapes.Where(p => p.Value.Handle == colShape.Handle).FirstOrDefault().Key;
|
||||
playerInColShape[houseId].Add(client);
|
||||
House house = GetHouseById(houseId, dbContext);
|
||||
User user = client.GetUser(dbContext);
|
||||
|
||||
client.TriggerEvent("ShowHouseMenu");
|
||||
SendPlayerHouseData(client, house);
|
||||
}
|
||||
}
|
||||
|
||||
public House GetHouseById(int id, DatabaseContext dbContext)
|
||||
{
|
||||
return dbContext.Houses.Where(h => h.Id == id).Include(h => h.Owner).FirstOrDefault();
|
||||
}
|
||||
|
||||
private void SendPlayerHouseData(IPlayer player, House house)
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
User user = player.GetUser(dbContext);
|
||||
var userHouseStatus = -1;
|
||||
|
||||
if (house.OwnerId == null) userHouseStatus = 0;
|
||||
else if (house.OwnerId == user?.Id) userHouseStatus = 1;
|
||||
else if (dbContext.HouseRentals.Where(h => h.HouseId == house.Id && h.UserId == user.Id).Count() == 1) userHouseStatus = 2;
|
||||
|
||||
var rentals = dbContext.HouseRentals.Where(h => h.HouseId == house.Id).Include(h => h.User).Select(h => h.User.Name).ToList();
|
||||
|
||||
var newHouse = new
|
||||
{
|
||||
OwnerName = house.Owner?.Name,
|
||||
house.RentalFee,
|
||||
house.Price,
|
||||
house.Type,
|
||||
Rentals = rentals
|
||||
};
|
||||
|
||||
player.TriggerEvent("SetHouseData", newHouse.SerializeJson(), userHouseStatus);
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveHouse(House house)
|
||||
{
|
||||
if (houseMarkers.ContainsKey(house.Id))
|
||||
{
|
||||
houseMarkers[house.Id].Remove();
|
||||
houseMarkers.Remove(house.Id);
|
||||
}
|
||||
|
||||
if (houseLabels.ContainsKey(house.Id))
|
||||
{
|
||||
houseLabels[house.Id].Remove();
|
||||
houseLabels.Remove(house.Id);
|
||||
}
|
||||
|
||||
if (houseColShapes.ContainsKey(house.Id))
|
||||
{
|
||||
houseColShapes[house.Id].Remove();
|
||||
houseColShapes.Remove(house.Id);
|
||||
}
|
||||
|
||||
if (houseBlips.ContainsKey(house.Id))
|
||||
{
|
||||
houseBlips[house.Id].Remove();
|
||||
houseBlips.Remove(house.Id);
|
||||
}
|
||||
|
||||
foreach (IPlayer client in playerInColShape[house.Id])
|
||||
{
|
||||
client.TriggerEvent("CloseHouseMenu");
|
||||
}
|
||||
}
|
||||
|
||||
public House GetNearHouse(Position position, DatabaseContext dbContext)
|
||||
{
|
||||
return dbContext.Houses.Where(h => h.NewPosition.DistanceTo(position) <= 5f).Include(h => h.Owner).OrderBy(h => h.NewPosition.DistanceTo(position)).FirstOrDefault();
|
||||
}
|
||||
|
||||
public void ReloadAllHouses()
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
foreach (House house in dbContext.Houses.Include(h => h.Owner).ToList())
|
||||
{
|
||||
RemoveHouse(house);
|
||||
LoadHouse(house);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void HouseManagerBuyHouseEvent(IPlayer player, params object[] args)
|
||||
{
|
||||
using var dbContext = new DatabaseContext();
|
||||
User user = player.GetUser(dbContext, bankAccount: true);
|
||||
|
||||
if (user.HouseId != null)
|
||||
{
|
||||
player.SendMessage("Du kann nicht mehrere Häuser besitzen", ChatPrefix.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
House house = GetNearHouse(player.Position, dbContext);
|
||||
|
||||
var userBank = user.BankAccount;
|
||||
|
||||
if (userBank.Balance < house.Price)
|
||||
{
|
||||
player.SendMessage($"Du hast nicht genug Geld für das Haus ({house.Price.ToMoneyString()})", ChatPrefix.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
house.Owner = user;
|
||||
user.House = house;
|
||||
|
||||
userBank.Balance -= house.Price;
|
||||
|
||||
dbContext.SaveChanges();
|
||||
|
||||
RemoveHouse(house);
|
||||
LoadHouse(house);
|
||||
}
|
||||
|
||||
private void HouseManagerSetRentalFeeEvent(IPlayer player, params object[] args)
|
||||
{
|
||||
var rentalFee = args[0].ToInt();
|
||||
|
||||
using var dbContext = GetDbContext();
|
||||
User user = player.GetUser(dbContext);
|
||||
|
||||
if (user.HouseId == null)
|
||||
{
|
||||
player.SendMessage("Du besitzt kein Haus", ChatPrefix.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
House house = GetHouseById(user.HouseId.Value, dbContext);
|
||||
|
||||
if (DateTime.Now - house.LastRentSetTime < TimeSpan.FromDays(7))
|
||||
{
|
||||
DateTime newPossibility = house.LastRentSetTime.AddDays(7);
|
||||
string dateStr = newPossibility.ToLongDateString();
|
||||
string timeStr = newPossibility.ToShortTimeString();
|
||||
player.SendNotification(
|
||||
$"~r~Die Miete wurde in den letzten 7 Tagen schon verändert. Die nächste Änderung kann am {dateStr} um {timeStr} Uhr geändert werden.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (rentalFee < 0)
|
||||
{
|
||||
player.SendNotification("~r~Die Miete darf kein negativer Betrag sein!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (rentalFee > 5000)
|
||||
{
|
||||
player.SendNotification($"~r~Die Miete darf einen Preis von {5000.ToMoneyString()} nicht überschreiten!");
|
||||
return;
|
||||
}
|
||||
|
||||
house.LastRentSetTime = DateTime.Now;
|
||||
house.RentalFee = rentalFee;
|
||||
|
||||
dbContext.SaveChanges();
|
||||
|
||||
player.SendNotification($"Der Mietpreis wurde auf ~g~{rentalFee.ToMoneyString()}~s~ gesetzt");
|
||||
|
||||
RemoveHouse(house);
|
||||
LoadHouse(house);
|
||||
}
|
||||
|
||||
private void HouseManagerCancelUserRentalEvent(IPlayer player, params object[] args)
|
||||
{
|
||||
string userName = args[0] as string;
|
||||
using var dbContext = new DatabaseContext();
|
||||
User user = player.GetUser(dbContext);
|
||||
if (user.HouseId == null)
|
||||
{
|
||||
player.SendMessage("Du besitzt kein Haus", ChatPrefix.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
User target = dbContext.Users.Where(u => u.Name == userName).FirstOrDefault();
|
||||
if (target == null)
|
||||
{
|
||||
player.SendNotification("~r~Dieser Spieler wurde nicht gefunden.");
|
||||
return;
|
||||
}
|
||||
|
||||
House house = GetHouseById(user.HouseId.Value, dbContext);
|
||||
|
||||
HouseRental rental = dbContext.HouseRentals.Where(h => h.HouseId == house.Id && h.UserId == target.Id).FirstOrDefault();
|
||||
if (rental == null)
|
||||
{
|
||||
player.SendNotification("~r~Der Spieler ist nicht in deinem Haus eingemietet");
|
||||
return;
|
||||
}
|
||||
|
||||
dbContext.HouseRentals.Remove(rental);
|
||||
dbContext.SaveChanges();
|
||||
|
||||
target.NewPlayer?.SendNotification($"~y~{player.Name}~s~ hat deinen Mietvertrag ~g~gekündigt~s~.");
|
||||
|
||||
player.SendNotification("Du hast dem Spieler ~y~" + target.Name + "~s~ den Mietvertrag gekündigt.");
|
||||
SendPlayerHouseData(player, house);
|
||||
}
|
||||
|
||||
private void HouseManagerRentInHouseEvent(IPlayer player, params object[] args)
|
||||
{
|
||||
using var dbContext = new DatabaseContext();
|
||||
User user = player.GetUser(dbContext);
|
||||
House house = GetNearHouse(player.Position, dbContext);
|
||||
|
||||
if (house == null)
|
||||
{
|
||||
player.SendMessage("In deiner Nähe ist kein Haus", ChatPrefix.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (house.RentalFee == 0)
|
||||
{
|
||||
player.SendMessage("Dieses Haus hat keinen Platz für Mieter", ChatPrefix.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
HouseRental newRental = new HouseRental
|
||||
{
|
||||
HouseId = house.Id,
|
||||
UserId = user.Id
|
||||
};
|
||||
|
||||
dbContext.HouseRentals.Add(newRental);
|
||||
|
||||
dbContext.SaveChanges();
|
||||
|
||||
player.SendNotification("~g~Du hast dich in das Haus eingemietet");
|
||||
|
||||
house.OwnerPlayer?.SendNotification($"~y~{player.Name}~s~ hat sich in dein Haus eingemietet.");
|
||||
SendPlayerHouseData(player, house);
|
||||
}
|
||||
|
||||
private void HouseManagerCancelOwnRentalEvent(IPlayer player, params object[] args)
|
||||
{
|
||||
using var dbContext = GetDbContext();
|
||||
User user = player.GetUser(dbContext);
|
||||
House house = GetNearHouse(player.Position, dbContext);
|
||||
|
||||
if (house == null)
|
||||
{
|
||||
player.SendMessage("In deiner Nähe ist kein Haus", ChatPrefix.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
HouseRental rental = dbContext.HouseRentals.Where(h => h.HouseId == house.Id && h.UserId == user.Id).FirstOrDefault();
|
||||
|
||||
if (rental == null)
|
||||
{
|
||||
player.SendNotification("~r~Du bist nin diesem Haus nicht eingemietet");
|
||||
return;
|
||||
}
|
||||
|
||||
dbContext.HouseRentals.Remove(rental);
|
||||
|
||||
dbContext.SaveChanges();
|
||||
|
||||
player.SendNotification("~g~Du hast den Mietvertrag gekündigt.");
|
||||
house.OwnerPlayer?.SendNotification($"~y~{player.Name}~s~ hat seinen Mietvertrag gekündigt.");
|
||||
|
||||
RemoveHouse(house);
|
||||
LoadHouse(house);
|
||||
|
||||
SendPlayerHouseData(player, house);
|
||||
}
|
||||
|
||||
private void HouseManagerSellHouseEvent(IPlayer player, params object[] args)
|
||||
{
|
||||
using var dbContext = GetDbContext();
|
||||
User user = player.GetUser(dbContext);
|
||||
if (user.HouseId == null)
|
||||
{
|
||||
player.SendMessage("Du besitzt kein Haus", ChatPrefix.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
House house = GetHouseById(user.HouseId.Value, dbContext);
|
||||
house.OwnerId = null;
|
||||
user.HouseId = null;
|
||||
|
||||
var backMoney = (int)(house.Price * 0.4);
|
||||
|
||||
player.SendMessage("Du bekommst vom Hausverkauf ~g~" + backMoney.ToMoneyString() + "~s~ zurück.");
|
||||
|
||||
user.BankAccount.Balance += backMoney;
|
||||
|
||||
dbContext.SaveChanges();
|
||||
|
||||
player.SendMessage("!{#81F7BE}* Du hast dein Haus verkauft.");
|
||||
|
||||
RemoveHouse(house);
|
||||
LoadHouse(house);
|
||||
|
||||
SendPlayerHouseData(player, house);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,6 @@ namespace ReallifeGamemode.Server.Core
|
||||
Log = LogManager.GetLogger(GetType());
|
||||
}
|
||||
|
||||
protected DatabaseContext GetDbContext() => Main.GetDbContext();
|
||||
protected DatabaseContext GetDbContext(bool useLoggerFactory = true) => Main.GetDbContext(useLoggerFactory);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user