frakcar kaufen wucherpreis

This commit is contained in:
hydrant
2020-04-04 11:42:44 +02:00
parent 26f4ea1332
commit 69a4ab5d22
2 changed files with 49 additions and 24 deletions

View File

@@ -12,6 +12,7 @@ using System.Linq;
using System.Reflection;
using ReallifeGamemode.Database;
using ReallifeGamemode.Server.Types;
using Microsoft.EntityFrameworkCore;
namespace ReallifeGamemode.Server.Managers
{
@@ -140,7 +141,7 @@ namespace ReallifeGamemode.Server.Managers
};
if (player.GetUser().FactionLeader && !player.GetUser().Faction.StateOwned) availableTargets.Add("Fraktion");
if (player.GetUser().GroupRank == GroupRank.OWNER) availableTargets.Add("Gruppe");
//if (player.GetUser().GroupRank == GroupRank.OWNER) availableTargets.Add("Gruppe");
player.TriggerEvent("ShopVehicle_OpenMenu", GetBusiness(shopVehicle.BusinessId).Name, shopVehicle.Price, availableTargets.ToArray());
}
@@ -156,21 +157,24 @@ namespace ReallifeGamemode.Server.Managers
ShopVehicle shopVehicle = (ShopVehicle)sVeh;
int price = shopVehicle.Price;
CarDealerBusinessBase business = GetBusiness(shopVehicle.BusinessId) as CarDealerBusinessBase;
TransactionResult result = BankManager.TransferMoney(player.GetUser(dbContext), business, price, "Auto gekauft", dbContext);
if (result == TransactionResult.SENDER_NOT_ENOUGH_MONEY)
{
player.SendNotification("~r~Du hast nicht genug Geld: " + price.ToMoneyString());
return;
}
Vector3 spawnPos = business.CarSpawnPositon.Around(3);
player.TriggerEvent("SERVER:Util_setWaypoint", spawnPos.X, spawnPos.Y);
User u = player.GetUser(dbContext);
ServerVehicle newVeh = null;
if (target == "Spieler")
{
TransactionResult result = BankManager.TransferMoney(u, business, price, "Auto gekauft", dbContext);
if (result == TransactionResult.SENDER_NOT_ENOUGH_MONEY)
{
player.SendNotification("~r~Du hast nicht genug Geld: " + price.ToMoneyString());
return;
}
newVeh = new UserVehicle
{
Heading = business.CarSpawnHeading,
@@ -188,6 +192,14 @@ namespace ReallifeGamemode.Server.Managers
}
else if (target == "Fraktion")
{
var faction = dbContext.Factions.Include(f => f.BankAccount).Where(f => f.Id == u.FactionId).First();
TransactionResult result = BankManager.TransferMoney(faction, business, price * 3, "Auto gekauft", dbContext);
if (result == TransactionResult.SENDER_NOT_ENOUGH_MONEY)
{
player.SendNotification("~r~Die Fraktion hat nicht genug Geld: " + price.ToMoneyString());
return;
}
newVeh = new FactionVehicle
{
Heading = business.CarSpawnHeading,
@@ -202,22 +214,22 @@ namespace ReallifeGamemode.Server.Managers
Active = true,
};
}
else if (target == "Gruppe")
{
newVeh = new GroupVehicle
{
Heading = business.CarSpawnHeading,
PositionX = spawnPos.X,
PositionY = spawnPos.Y,
PositionZ = spawnPos.Z,
Locked = false,
GroupId = player.GetUser().Group.Id,
Model = shopVehicle.Model,
PrimaryColor = 111,
SecondaryColor = 111,
Active = true,
};
}
//else if (target == "Gruppe")
//{
// newVeh = new GroupVehicle
// {
// Heading = business.CarSpawnHeading,
// PositionX = spawnPos.X,
// PositionY = spawnPos.Y,
// PositionZ = spawnPos.Z,
// Locked = false,
// GroupId = player.GetUser().Group.Id,
// Model = shopVehicle.Model,
// PrimaryColor = 111,
// SecondaryColor = 111,
// Active = true,
// };
//}
dbContext.ServerVehicles.Add(newVeh);
dbContext.SaveChanges();