diff --git a/ReallifeGamemode.Database/Entities/User.cs b/ReallifeGamemode.Database/Entities/User.cs index 01f206ba..60404d7b 100644 --- a/ReallifeGamemode.Database/Entities/User.cs +++ b/ReallifeGamemode.Database/Entities/User.cs @@ -88,6 +88,9 @@ namespace ReallifeGamemode.Database.Entities public House House { get; set; } public int? JobId { get; set; } + public int? BusSkill { get; set; } + public int? PilotSkill { get; set; } + public int Wanteds { diff --git a/ReallifeGamemode.Server/Events/Key.cs b/ReallifeGamemode.Server/Events/Key.cs index ed6e245c..10a722d2 100644 --- a/ReallifeGamemode.Server/Events/Key.cs +++ b/ReallifeGamemode.Server/Events/Key.cs @@ -504,6 +504,36 @@ namespace ReallifeGamemode.Server.Events player.SendNotification("~r~Du hast keinen Schlüssel."); 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) { diff --git a/ReallifeGamemode.Server/Job/BusDriverJob.cs b/ReallifeGamemode.Server/Job/BusDriverJob.cs index 9cab0dc9..ff08f230 100644 --- a/ReallifeGamemode.Server/Job/BusDriverJob.cs +++ b/ReallifeGamemode.Server/Job/BusDriverJob.cs @@ -3,6 +3,9 @@ using System.Collections.Generic; using GTANetworkAPI; using ReallifeGamemode.Server.Util; using Newtonsoft.Json; +using ReallifeGamemode.Server.Extensions; +using ReallifeGamemode.Database.Models; +using Microsoft.CodeAnalysis.CSharp.Syntax; namespace ReallifeGamemode.Server.Job { @@ -154,7 +157,67 @@ namespace ReallifeGamemode.Server.Job 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"); + } } } } diff --git a/ReallifeGamemode.Server/Util/CheckPointHandle.cs b/ReallifeGamemode.Server/Util/CheckPointHandle.cs index 40ff99e7..ef03a3a5 100644 --- a/ReallifeGamemode.Server/Util/CheckPointHandle.cs +++ b/ReallifeGamemode.Server/Util/CheckPointHandle.cs @@ -2,6 +2,9 @@ using ReallifeGamemode.Server.Services; using GTANetworkAPI; using System.Linq; +using ReallifeGamemode.Server.Extensions; + + namespace ReallifeGamemode.Server.Util { public class CheckPointHandle : Script @@ -41,6 +44,7 @@ namespace ReallifeGamemode.Server.Util public void PlayerInCheckpoint(Player user) { CheckPointListForPlayer temp = null; + Job.BusDriverJob temp2 = null; for (int a = 0; a < listHandle.Count; a++) { temp = listHandle[a]; @@ -49,12 +53,28 @@ namespace ReallifeGamemode.Server.Util 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(); } } public class CheckPointListForPlayer { + public int LastCheckpoint; public IEnumerable list = new List(); public Player player; public int delay = 0; @@ -84,17 +104,18 @@ namespace ReallifeGamemode.Server.Util this.checkPointsDone++; if (this.list.Count() > checkPointsDone) { - Vector3 nextCp = list.ElementAt(checkPointsDone); + LastCheckpoint = 0; + Vector3 nextCp = list.ElementAt(checkPointsDone); 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) { - CheckPointHandle.RemovePlayerHandlerFromList(this.player); - - if (this.eventInCheckpoint == "busDriverJob") - { - Job.BusDriverJob.payWage(this.player, 1000); - } + LastCheckpoint = 0; + CheckPointHandle.RemovePlayerHandlerFromList(this.player); } }