@@ -6,17 +6,24 @@ using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Server.Managers;
|
||||
using ReallifeGamemode.Server.Util;
|
||||
using System;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using ReallifeGamemode.Server.Log;
|
||||
|
||||
namespace ReallifeGamemode.Server.DrivingSchool
|
||||
{
|
||||
internal class DrivingSchool : Script
|
||||
{
|
||||
private static readonly ILogger logger = LogManager.GetLogger<DrivingSchool>();
|
||||
|
||||
private static TextLabel informationLabel;
|
||||
private static Marker marker;
|
||||
private static ColShape _colShape;
|
||||
public static Vector3 Position { get; }
|
||||
private const int FAILPOINTS = 2;
|
||||
|
||||
private const int CAR_LICENSE_PRICE = 2500;
|
||||
private const int BIKE_LICENSE_PRICE = 3500;
|
||||
|
||||
private readonly IReadOnlyCollection<Vector3> BikeRoute = new List<Vector3>
|
||||
{
|
||||
new Vector3(-741.98, -1283.46, 6.17),
|
||||
@@ -122,14 +129,14 @@ namespace ReallifeGamemode.Server.DrivingSchool
|
||||
public void StartDrivingSchool(Player client)
|
||||
{
|
||||
User user = client.GetUser();
|
||||
|
||||
|
||||
if (user.DriverLicenseVehicle || client.HasData("ActiveSchool"))
|
||||
{
|
||||
client.SendChatMessage("~b~[INFO]~s~ Du besitzt schon einen Führerschein.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (user.Handmoney < 2500)
|
||||
|
||||
if (user.Handmoney < CAR_LICENSE_PRICE)
|
||||
{
|
||||
client.SendNotification("~r~[FEHLER]~s~ Du hast nicht genug Geld auf der Hand($2.500)!", true);
|
||||
return;
|
||||
@@ -138,7 +145,8 @@ namespace ReallifeGamemode.Server.DrivingSchool
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
User payer = client.GetUser(dbContext);
|
||||
payer.Handmoney -= 2500;
|
||||
payer.Handmoney -= CAR_LICENSE_PRICE;
|
||||
logger.LogInformation("Player {0} bought the driving school (car) for {1} dollars", client.Name, CAR_LICENSE_PRICE);
|
||||
// client.TriggerEvent("SERVER:SET_HANDMONEY", payer.Handmoney);
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
@@ -174,8 +182,8 @@ namespace ReallifeGamemode.Server.DrivingSchool
|
||||
[RemoteEvent("drivingSchoolEventEnd")]
|
||||
public void DrivingSchoolEventEnd(Player user, int checkpoint)
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
User drivingUser = user.GetUser(dbContext);
|
||||
|
||||
if (drivingUser.failpoints > FAILPOINTS)
|
||||
@@ -186,13 +194,13 @@ namespace ReallifeGamemode.Server.DrivingSchool
|
||||
else
|
||||
{
|
||||
user.TriggerEvent("renderTextOnScreen", "Du hast den Führerschein bestanden. Glückwunsch!");
|
||||
user.ResetData("ActiveSchool");
|
||||
user.ResetData("ActiveSchool");
|
||||
drivingUser.DriverLicenseVehicle = true;
|
||||
drivingUser.failpoints = 0;
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Vehicle veh = user.Vehicle;
|
||||
user.WarpOutOfVehicle();
|
||||
ServerVehicle sVeh = VehicleManager.GetServerVehicleFromVehicle(veh);
|
||||
@@ -208,31 +216,31 @@ namespace ReallifeGamemode.Server.DrivingSchool
|
||||
[RemoteEvent("drivingSchoolEvent")]
|
||||
public void DrivingSchoolEvent(Player user, int checkpoint)
|
||||
{
|
||||
/* for (int i = 0; i >= 33; i++)
|
||||
{
|
||||
if (checkpoint <= 24)
|
||||
{
|
||||
user.TriggerEvent("kmh100");
|
||||
}
|
||||
else if (checkpoint >= 25 && checkpoint <= 26)
|
||||
{
|
||||
user.TriggerEvent("kmh150");
|
||||
}
|
||||
else if (checkpoint >= 26 && checkpoint <= 28)
|
||||
{
|
||||
user.TriggerEvent("kmh100");
|
||||
}
|
||||
else if (checkpoint >= 29 && checkpoint <= 31)
|
||||
{
|
||||
user.TriggerEvent("kmh150");
|
||||
}
|
||||
else if (checkpoint >= 32 && checkpoint <= 33)
|
||||
{
|
||||
user.TriggerEvent("kmh100");
|
||||
}
|
||||
}
|
||||
*/
|
||||
switch(checkpoint)
|
||||
/* for (int i = 0; i >= 33; i++)
|
||||
{
|
||||
if (checkpoint <= 24)
|
||||
{
|
||||
user.TriggerEvent("kmh100");
|
||||
}
|
||||
else if (checkpoint >= 25 && checkpoint <= 26)
|
||||
{
|
||||
user.TriggerEvent("kmh150");
|
||||
}
|
||||
else if (checkpoint >= 26 && checkpoint <= 28)
|
||||
{
|
||||
user.TriggerEvent("kmh100");
|
||||
}
|
||||
else if (checkpoint >= 29 && checkpoint <= 31)
|
||||
{
|
||||
user.TriggerEvent("kmh150");
|
||||
}
|
||||
else if (checkpoint >= 32 && checkpoint <= 33)
|
||||
{
|
||||
user.TriggerEvent("kmh100");
|
||||
}
|
||||
}
|
||||
*/
|
||||
switch (checkpoint)
|
||||
{
|
||||
case 25:
|
||||
case 26:
|
||||
@@ -275,7 +283,7 @@ namespace ReallifeGamemode.Server.DrivingSchool
|
||||
client.SendChatMessage("~b~[INFO]~s~ Du besitzt schon einen Motorradschein.");
|
||||
return;
|
||||
}
|
||||
if (user.Handmoney < 3500)
|
||||
if (user.Handmoney < BIKE_LICENSE_PRICE)
|
||||
{
|
||||
client.SendNotification("~r~[FEHLER]~s~Du hast nicht genug Geld auf der Hand($3.500)!", true);
|
||||
return;
|
||||
@@ -284,7 +292,8 @@ namespace ReallifeGamemode.Server.DrivingSchool
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
User payer = client.GetUser(dbContext);
|
||||
payer.Handmoney -= 3500;
|
||||
payer.Handmoney -= BIKE_LICENSE_PRICE;
|
||||
logger.LogInformation("Player {0} bought the driving school (bike) for {1} dollars", client.Name, BIKE_LICENSE_PRICE);
|
||||
// client.TriggerEvent("SERVER:SET_HANDMONEY", payer.Handmoney);
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user