business sell

This commit is contained in:
hydrant
2019-09-12 22:28:19 +02:00
parent e345aa14e7
commit 4c54803ef3
2 changed files with 34 additions and 1 deletions

View File

@@ -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();
}
}
}
}