From 9ac064a5ea39c2cac7b86dcb0a0d7aaa59490a67 Mon Sep 17 00:00:00 2001 From: Mac_Slash Date: Tue, 28 Apr 2020 20:32:38 +0200 Subject: [PATCH] Nicht als Beifahrer + Nicht an aus an aus --- ReallifeGamemode.Server/Job/BusDriverJob.cs | 72 ++++++++++++-------- ReallifeGamemode.Server/Job/PilotJob.cs | 74 +++++++++++++-------- 2 files changed, 88 insertions(+), 58 deletions(-) diff --git a/ReallifeGamemode.Server/Job/BusDriverJob.cs b/ReallifeGamemode.Server/Job/BusDriverJob.cs index a208c692..ed54d183 100644 --- a/ReallifeGamemode.Server/Job/BusDriverJob.cs +++ b/ReallifeGamemode.Server/Job/BusDriverJob.cs @@ -6,6 +6,8 @@ using Newtonsoft.Json; using ReallifeGamemode.Server.Extensions; using ReallifeGamemode.Database.Models; using Microsoft.CodeAnalysis.CSharp.Syntax; +using ReallifeGamemode.Server.Services; +using ReallifeGamemode.Server.Managers; namespace ReallifeGamemode.Server.Job { @@ -132,46 +134,58 @@ namespace ReallifeGamemode.Server.Job [RemoteEvent("startBusRoute")] public void StartBusRoute(Player player, string type) { - if (type == "Kurz 1") + if (player.VehicleSeat == 0) { - CheckPointHandle.StartCheckPointRoute(player, Route1, 3000, 1, 7, 5, "busDriverJob"); + if (type == "Kurz 1") + { + CheckPointHandle.StartCheckPointRoute(player, Route1, 3000, 1, 7, 5, "busDriverJob"); + } + else if (type == "Kurz 2") + { + CheckPointHandle.StartCheckPointRoute(player, Route2, 3000, 1, 7, 5, "busDriverJob"); + } + else if (type == "Mittel 1") + { + CheckPointHandle.StartCheckPointRoute(player, Route3, 3000, 1, 7, 5, "busDriverJob"); + } + else if (type == "Lang 1") + { + CheckPointHandle.StartCheckPointRoute(player, RouteLong, 3000, 1, 7, 5, "busDriverJob"); + } + else if (type == "Lang 2") + { + CheckPointHandle.StartCheckPointRoute(player, RouteVeryLong, 3000, 1, 7, 5, "busDriverJob"); + } } - else if (type == "Kurz 2") - { - CheckPointHandle.StartCheckPointRoute(player, Route2, 3000, 1, 7, 5, "busDriverJob"); - } - else if (type == "Mittel 1") - { - CheckPointHandle.StartCheckPointRoute(player, Route3, 3000, 1, 7, 5, "busDriverJob"); - } - else if (type == "Lang 1") - { - CheckPointHandle.StartCheckPointRoute(player, RouteLong, 3000, 1, 7, 5, "busDriverJob"); - } - else if (type == "Lang 2") - { - CheckPointHandle.StartCheckPointRoute(player, RouteVeryLong, 3000, 1, 7, 5, "busDriverJob"); - } - } public static void payWage(Player jobber, int wage) { using (var dbContext = new DatabaseContext()) { - jobber.GetUser(dbContext).BankAccount.Balance += wage; - jobber.SendChatMessage($"~y~[JOB] ~w~Du hast ~g~${wage} ~w~bekommen."); - jobber.GetUser(dbContext).BusSkill++; - dbContext.SaveChanges(); - if (jobber.GetUser(dbContext).BusSkill == 300) + if (jobber.VehicleSeat == 0) { - 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!"); + jobber.GetUser(dbContext).BankAccount.Balance += wage; + jobber.SendChatMessage($"~y~[JOB] ~w~Du hast ~g~${wage} ~w~bekommen."); + jobber.GetUser(dbContext).BusSkill++; + dbContext.SaveChanges(); + 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!"); + } } - if (jobber.GetUser(dbContext).BusSkill == 800) + else { - 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!"); + JobBase job = JobManager.GetJob(jobber.GetUser().JobId.Value); + job.StopJob(jobber); + CheckPointHandle.DeleteCheckpoints(jobber); + ChatService.SendMessage(jobber, $"~y~[JOB]~s~ Du hast deinen Job ~o~{job.Name}~s~ beendet."); } //BusLetzterCheckpoint(jobber); //BusDriverJob rt = null; diff --git a/ReallifeGamemode.Server/Job/PilotJob.cs b/ReallifeGamemode.Server/Job/PilotJob.cs index 6d05bb99..95137a0a 100644 --- a/ReallifeGamemode.Server/Job/PilotJob.cs +++ b/ReallifeGamemode.Server/Job/PilotJob.cs @@ -5,6 +5,9 @@ using ReallifeGamemode.Server.Util; using Newtonsoft.Json; using ReallifeGamemode.Server.Extensions; using ReallifeGamemode.Database.Models; +using ReallifeGamemode.Server.Services; +using ReallifeGamemode.Server.Managers; + namespace ReallifeGamemode.Server.Job { class PilotJob : JobBase @@ -139,43 +142,56 @@ namespace ReallifeGamemode.Server.Job [RemoteEvent("startPilotRoute")] public void StartPilotRoute(Player player, string type) { - if (type == "Route 1") + if (player.VehicleSeat == 0) { - CheckPointHandle.StartCheckPointRoute(player, Route1, 0, 6, 40, 40, "pilotJob"); //6, 23, 25, 26, 27, 28 - } - else if (type == "Route 2") - { - CheckPointHandle.StartCheckPointRoute(player, Route2, 0, 6, 40, 40, "pilotJob"); - } - else if (type == "Route 3") - { - CheckPointHandle.StartCheckPointRoute(player, Route3, 0, 6, 40, 40, "pilotJob"); - } - else if (type == "Route 4") - { - CheckPointHandle.StartCheckPointRoute(player, Route4, 0, 6, 40, 40, "pilotJob"); - } - else if (type == "Route 5") - { - CheckPointHandle.StartCheckPointRoute(player, Route5, 0, 6, 40, 40, "pilotJob"); - } - else if (type == "Route 6") - { - CheckPointHandle.StartCheckPointRoute(player, Route6, 0, 6, 40, 40, "pilotJob"); + if (type == "Route 1") + { + CheckPointHandle.StartCheckPointRoute(player, Route1, 0, 6, 40, 40, "pilotJob"); //6, 23, 25, 26, 27, 28 + } + else if (type == "Route 2") + { + CheckPointHandle.StartCheckPointRoute(player, Route2, 0, 6, 40, 40, "pilotJob"); + } + else if (type == "Route 3") + { + CheckPointHandle.StartCheckPointRoute(player, Route3, 0, 6, 40, 40, "pilotJob"); + } + else if (type == "Route 4") + { + CheckPointHandle.StartCheckPointRoute(player, Route4, 0, 6, 40, 40, "pilotJob"); + } + else if (type == "Route 5") + { + CheckPointHandle.StartCheckPointRoute(player, Route5, 0, 6, 40, 40, "pilotJob"); + } + else if (type == "Route 6") + { + CheckPointHandle.StartCheckPointRoute(player, Route6, 0, 6, 40, 40, "pilotJob"); + } } } public static void payWage(Player jobber, int wage) { using (var dbContext = new DatabaseContext()) { - jobber.GetUser(dbContext).BankAccount.Balance += wage; - jobber.SendChatMessage($"~y~[JOB] ~w~Du hast ~g~${wage} ~w~bekommen."); - jobber.GetUser(dbContext).PilotSkill++; - dbContext.SaveChanges(); - if (jobber.GetUser(dbContext).PilotSkill == 300) + if (jobber.VehicleSeat == 0) { - 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 Velum Flugzeug (LS Airport) fliegen!"); + jobber.GetUser(dbContext).BankAccount.Balance += wage; + jobber.SendChatMessage($"~y~[JOB] ~w~Du hast ~g~${wage} ~w~bekommen."); + jobber.GetUser(dbContext).PilotSkill++; + dbContext.SaveChanges(); + if (jobber.GetUser(dbContext).PilotSkill == 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 Velum Flugzeug (LS Airport) fliegen!"); + } + } + else + { + JobBase job = JobManager.GetJob(jobber.GetUser().JobId.Value); + job.StopJob(jobber); + CheckPointHandle.DeleteCheckpoints(jobber); + ChatService.SendMessage(jobber, $"~y~[JOB]~s~ Du hast deinen Job ~o~{job.Name}~s~ beendet."); } } }