fix chargemoney on enter Taxi @JobManager.cs

This commit is contained in:
Siga
2020-03-27 21:23:11 +01:00
parent 331675bfb5
commit b6057ce495

View File

@@ -227,14 +227,20 @@ namespace ReallifeGamemode.Server.Managers
Player driver = veh.GetDriver(); Player driver = veh.GetDriver();
if (!driver.HasData("DriverPrice")) return; if (!driver.HasData("DriverPrice")) return;
int taxiPrice = driver.GetData<int>("DriverPrice"); int taxiPrice = driver.GetData<int>("DriverPrice");
float km = 0; float km = 0;
if (!driver.HasData("FareKm")) { driver.SetData<float>("FareKm", km); } if (!driver.HasData("FareKm")) { driver.SetData<float>("FareKm", km); }
km = driver.GetData<float>("FareKm"); km = driver.GetData<float>("FareKm");
if (driver.HasData("Passager")) return; if (driver.HasData("Passager")) return;
driver.SetData<int>("Passager", player.GetUser().Id); driver.SetData<int>("Passager", player.GetUser().Id);
driver.SetData<bool>("hasPassager", true); driver.SetData<bool>("hasPassager", true);
using (var dbContext = new DatabaseContext())
{
User contractUser = player.GetUser(dbContext);
contractUser.Handmoney -= (int)Math.Round(km * taxiPrice);
dbContext.SaveChanges();
contractUser.Player.TriggerEvent("SERVER:SET_HANDMONEY", contractUser.Handmoney);
Console.WriteLine($"{(int)Math.Round(km * taxiPrice)}");
}
player.TriggerEvent("CLIENT:startCustomerFare", taxiPrice, km); player.TriggerEvent("CLIENT:startCustomerFare", taxiPrice, km);
var taxiContracts = taxiJob.TaxiContracts.Where(t => t.Name == player.Name); var taxiContracts = taxiJob.TaxiContracts.Where(t => t.Name == player.Name);
@@ -261,7 +267,6 @@ namespace ReallifeGamemode.Server.Managers
var taxiJob = JobManager.GetJob<TaxiDriverJob>(); var taxiJob = JobManager.GetJob<TaxiDriverJob>();
if (veh.Occupants.Count == 0) return; if (veh.Occupants.Count == 0) return;
Player driver = veh.GetDriver(); Player driver = veh.GetDriver();
Console.WriteLine($"{driver.Name}");
if (driver == null) return; if (driver == null) return;
if (player.GetUser().Id != driver.GetData<int>("Passager")) { player.TriggerEvent("CLIENT:cancelFare"); return; } if (player.GetUser().Id != driver.GetData<int>("Passager")) { player.TriggerEvent("CLIENT:cancelFare"); return; }
player.TriggerEvent("CLIENT:cancelFareCustomer"); player.TriggerEvent("CLIENT:cancelFareCustomer");