business sell
This commit is contained in:
@@ -232,7 +232,7 @@ namespace ReallifeGamemode.Server.Managers
|
||||
int price = business.GetData().Price;
|
||||
User user = player.GetUser(dbContext);
|
||||
|
||||
if(user.BusinessId != null)
|
||||
if (user.BusinessId != null)
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Du kannst nicht mehrere Businesse besitzen");
|
||||
}
|
||||
@@ -255,5 +255,30 @@ namespace ReallifeGamemode.Server.Managers
|
||||
business.Update();
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("CLIENT:Business_SellBusiness")]
|
||||
public void BusinessEventSellBusiness(Client player)
|
||||
{
|
||||
BusinessBase business = GetNearBusiness(player);
|
||||
if (business == null) return;
|
||||
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
User user = player.GetUser(dbContext);
|
||||
|
||||
if(user.Id != business.Id)
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Dieses Business gehört nicht dir");
|
||||
return;
|
||||
}
|
||||
|
||||
user.BusinessId = null;
|
||||
dbContext.SaveChanges();
|
||||
|
||||
player.SendChatMessage("Business verkauft");
|
||||
|
||||
business.Update();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user