Anfang Bussystem + Skill

This commit is contained in:
Mac_Slash
2020-04-27 12:54:19 +02:00
parent 78ccd9a314
commit 929344c1c3
4 changed files with 125 additions and 8 deletions

View File

@@ -88,6 +88,9 @@ namespace ReallifeGamemode.Database.Entities
public House House { get; set; } public House House { get; set; }
public int? JobId { get; set; } public int? JobId { get; set; }
public int? BusSkill { get; set; }
public int? PilotSkill { get; set; }
public int Wanteds public int Wanteds
{ {

View File

@@ -504,6 +504,36 @@ namespace ReallifeGamemode.Server.Events
player.SendNotification("~r~Du hast keinen Schlüssel."); player.SendNotification("~r~Du hast keinen Schlüssel.");
return; return;
} }
else
{
if (u.JobId == 4)
{
if (v.Model == (uint)Types.VehicleModel.Coach)
{
if (u.BusSkill < 300)
{
player.SendNotification("~r~Dein Skilllevel(2) ist nicht hoch genug!");
return;
}
else
{
}
}
if (v.Model == (uint)Types.VehicleModel.Tourbus)
{
if (u.BusSkill < 800)
{
player.SendNotification("~r~Dein Skilllevel(3) ist nicht hoch genug!");
return;
}
else
{
}
}
}
}
} }
else if (sV is UserVehicle uV) else if (sV is UserVehicle uV)
{ {

View File

@@ -3,6 +3,9 @@ using System.Collections.Generic;
using GTANetworkAPI; using GTANetworkAPI;
using ReallifeGamemode.Server.Util; using ReallifeGamemode.Server.Util;
using Newtonsoft.Json; using Newtonsoft.Json;
using ReallifeGamemode.Server.Extensions;
using ReallifeGamemode.Database.Models;
using Microsoft.CodeAnalysis.CSharp.Syntax;
namespace ReallifeGamemode.Server.Job namespace ReallifeGamemode.Server.Job
{ {
@@ -154,7 +157,67 @@ namespace ReallifeGamemode.Server.Job
public static void payWage(Player jobber, int wage) public static void payWage(Player jobber, int wage)
{ {
using (var dbContext = new DatabaseContext())
{
jobber.GetUser(dbContext).BankAccount.Balance += wage;
if (jobber.GetUser(dbContext).BusSkill == 300)
{
jobber.SendChatMessage($"~y~[JOB] ~w~Du hast nun ~g~Skill-Level 2 ~w~erreicht!");
jobber.SendChatMessage($"~y~[JOB] ~w~Du kannst jetzt auch mit dem Coach-Bus fahren!");
}
if (jobber.GetUser(dbContext).BusSkill == 800)
{
jobber.SendChatMessage($"~y~[JOB] ~w~Du hast nun ~g~Skill-Level 3 ~w~erreicht!");
jobber.SendChatMessage($"~y~[JOB] ~w~Du kannst jetzt mit dem Coach, und dem Tourbus fahren!");
}
jobber.GetUser(dbContext).BusSkill++;
jobber.SendChatMessage($"~y~[JOB] ~w~Du hast ~g~${wage} ~w~bekommen.");
dbContext.SaveChanges();
}
}
public void BusLetzterCheckpoint(Player player)
{
Vehicle v = player.Vehicle;
if (v.Model == (uint)Types.VehicleModel.Bus)
{
Random rnd = new Random();
int rroute = rnd.Next(1, 3);
switch (rroute)
{
case 1:
{
StartBusRoute(player, "Kurz 1");
break;
}
case 2:
{
StartBusRoute(player, "Kurz 2");
break;
}
}
}
if (v.Model == (uint)Types.VehicleModel.Coach)
{
Random rnd = new Random();
int rroute = rnd.Next(1, 3);
switch (rroute)
{
case 1:
{
StartBusRoute(player, "Lang 1");
break;
}
case 2:
{
StartBusRoute(player, "Lang 2");
break;
}
}
}
if (v.Model == (uint)Types.VehicleModel.Tourbus)
{
StartBusRoute(player, "Mittel 1");
}
} }
} }
} }

View File

@@ -2,6 +2,9 @@
using ReallifeGamemode.Server.Services; using ReallifeGamemode.Server.Services;
using GTANetworkAPI; using GTANetworkAPI;
using System.Linq; using System.Linq;
using ReallifeGamemode.Server.Extensions;
namespace ReallifeGamemode.Server.Util namespace ReallifeGamemode.Server.Util
{ {
public class CheckPointHandle : Script public class CheckPointHandle : Script
@@ -41,6 +44,7 @@ namespace ReallifeGamemode.Server.Util
public void PlayerInCheckpoint(Player user) public void PlayerInCheckpoint(Player user)
{ {
CheckPointListForPlayer temp = null; CheckPointListForPlayer temp = null;
Job.BusDriverJob temp2 = null;
for (int a = 0; a < listHandle.Count; a++) for (int a = 0; a < listHandle.Count; a++)
{ {
temp = listHandle[a]; temp = listHandle[a];
@@ -48,6 +52,21 @@ namespace ReallifeGamemode.Server.Util
{ {
break; break;
} }
}
if (temp.LastCheckpoint != 1)
{
if (user.GetUser().JobId == 4)
{
Job.BusDriverJob.payWage(user, 100);
}
}
else
{
if (user.GetUser().JobId == 4)
{
Job.BusDriverJob.payWage(user, 200);
temp2.BusLetzterCheckpoint(user);
}
} }
temp.NextCheckpoint(); temp.NextCheckpoint();
} }
@@ -55,6 +74,7 @@ namespace ReallifeGamemode.Server.Util
public class CheckPointListForPlayer public class CheckPointListForPlayer
{ {
public int LastCheckpoint;
public IEnumerable<Vector3> list = new List<Vector3>(); public IEnumerable<Vector3> list = new List<Vector3>();
public Player player; public Player player;
public int delay = 0; public int delay = 0;
@@ -84,17 +104,18 @@ namespace ReallifeGamemode.Server.Util
this.checkPointsDone++; this.checkPointsDone++;
if (this.list.Count() > checkPointsDone) if (this.list.Count() > checkPointsDone)
{ {
LastCheckpoint = 0;
Vector3 nextCp = list.ElementAt(checkPointsDone); Vector3 nextCp = list.ElementAt(checkPointsDone);
this.player.TriggerEvent("setCheckPoint", nextCp, player, this.checkPointsDone, delay, this.markerID, this.markerSize, this.eventInCheckpoint); this.player.TriggerEvent("setCheckPoint", nextCp, player, this.checkPointsDone, delay, this.markerID, this.markerSize, this.eventInCheckpoint);
} }
if (this.list.Count() == checkPointsDone-1)
{
LastCheckpoint = 1;
}
if (this.list.Count() == checkPointsDone) if (this.list.Count() == checkPointsDone)
{ {
LastCheckpoint = 0;
CheckPointHandle.RemovePlayerHandlerFromList(this.player); CheckPointHandle.RemovePlayerHandlerFromList(this.player);
if (this.eventInCheckpoint == "busDriverJob")
{
Job.BusDriverJob.payWage(this.player, 1000);
}
} }
} }