diff --git a/ReallifeGamemode.Client/Jobs/BusDriver/CheckpointBusfahrer.cs b/ReallifeGamemode.Client/Jobs/BusDriver/CheckpointBusfahrer.cs new file mode 100644 index 00000000..289463c9 --- /dev/null +++ b/ReallifeGamemode.Client/Jobs/BusDriver/CheckpointBusfahrer.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Text; +using RAGE; +using RAGE.Elements; + +namespace ReallifeGamemode.Client.Jobs.BusDriver +{ + public static class CheckpointHelper + { + public static List Checkpoints = new List(); + + public static void ClearAllCheckpoints() + { + while (Checkpoints.Count != 0) + { + Checkpoints[Checkpoints.Count - 1].Delete(); + Checkpoints.Remove(Checkpoints[Checkpoints.Count - 1]); + } + } + + public static void ClearCheckpoint(CheckpointInstance checkpointInstance) + { + checkpointInstance.Delete(); + } + + public static CheckpointInstance IsNearCheckpoint(float distance) + { + return Checkpoints.Find(checkpoint => checkpoint.Checkpoint.Position.DistanceTo2D(Player.LocalPlayer.Position) <= distance); + } + } + + public class CheckpointInstance + { + public Checkpoint Checkpoint { get; set; } = null; + public bool RecentlyPlaced = true; + public float Size = 5f; + + public CheckpointInstance(Vector3 position, float size) + { + Checkpoint = new Checkpoint(1, position.Subtract(new Vector3(0, 0, 1)), size, new Vector3(), new RGBA(255, 255, 255, 155), true, 0); + Size = size; + CheckpointHelper.Checkpoints.Add(this); + } + + public void Delete() + { + Checkpoint.Destroy(); + CheckpointHelper.Checkpoints.Remove(this); + RAGE.Game.Audio.PlaySoundFrontend(1, "Beep_Red", "DLC_HEIST_HACKING_SNAKE_SOUNDS", true); + } + } +} diff --git a/ReallifeGamemode.Client/Jobs/BusDriver/Main.cs b/ReallifeGamemode.Client/Jobs/BusDriver/Main.cs new file mode 100644 index 00000000..baf3b1f5 --- /dev/null +++ b/ReallifeGamemode.Client/Jobs/BusDriver/Main.cs @@ -0,0 +1,76 @@ +using System; +using System.Collections.Generic; +using System.Text; +using RAGE; + + +namespace ReallifeGamemode.Client.Jobs.BusDriver +{ + public class Main : Events.Script + { + public static CheckpointInstance NextObjective { get; set; } = null; + + public static int tick = 0; + public static int around_one_sec = 80; + + public static bool check_for_key_press = true; + + public Main() + { + Chat.Output("Loaded Clientside"); + Events.Add("load_objective", LoadObjective); + Events.Add("clear_all_markers", ClearJobCheckPoints); + Events.Tick += OnUpdate; + } + + private void OnUpdate(List nametags) + { + tick++; + + if (tick >= around_one_sec) + { + HeartBeat(); + } + } + + public void HeartBeat() + { + tick = 0; + check_for_key_press = true; + + + if (NextObjective != null) + { + CheckpointInstance checkpointInstance = CheckpointHelper.IsNearCheckpoint(3f); + + if (checkpointInstance != null) + { + NextObjective = null; + CheckpointHelper.ClearCheckpoint(checkpointInstance); + Events.CallRemote("marker_completed"); + } + } + } + + public static void ClearJobCheckPoints(object[] args) + { + CheckpointHelper.ClearAllCheckpoints(); + } + + public static void LoadObjective(object[] args) + { + Vector3 markerPosition = (Vector3)args[0]; + float markerSize = Convert.ToSingle(args[1]); + + if (markerPosition == null) + return; + + if (NextObjective != null) + { + CheckpointHelper.ClearCheckpoint(NextObjective); + } + + NextObjective = new CheckpointInstance(markerPosition, markerSize); + } + } +} diff --git a/ReallifeGamemode.Server/Commands/AdminCommands.cs b/ReallifeGamemode.Server/Commands/AdminCommands.cs index 288f5033..7cfdd5bb 100644 --- a/ReallifeGamemode.Server/Commands/AdminCommands.cs +++ b/ReallifeGamemode.Server/Commands/AdminCommands.cs @@ -122,6 +122,28 @@ namespace ReallifeGamemode.Server.Commands #endregion #region Support + + [Command("aduty", "~m~Benutzung: ~s~/aduty")] + public void CmdAduty(Client player) + { + if (!player.GetUser()?.IsAdmin(AdminLevel.SUPPORTER) ?? true) + { + ChatService.NotAuthorized(player); + return; + } + + if (!UserHelper.dutyAdmins.Contains(player)) + { + UserHelper.dutyAdmins.Add(player); + ChatService.Broadcast("~y~" + player.Name + " hat sich zum Support angemeldet"); + } else + { + UserHelper.dutyAdmins.Remove(player); + ChatService.Broadcast("~y~" + player.Name + " hat sich vom Support abgemeldet"); + } + + } + [Command("o", "~m~Benutzung: ~s~/o [Nachricht]", GreedyArg = true)] public void CmdAdminO(Client player, string message) { diff --git a/ReallifeGamemode.Server/Job/BusDriver/Commands.cs b/ReallifeGamemode.Server/Job/BusDriver/Commands.cs new file mode 100644 index 00000000..a830f958 --- /dev/null +++ b/ReallifeGamemode.Server/Job/BusDriver/Commands.cs @@ -0,0 +1,120 @@ +using System; +using System.Collections.Generic; +using System.Text; +using GTANetworkAPI; + +namespace ReallifeGamemode.Server.Job.BusDriver +{ + public class Commands : Script + { + public static List NewPositions = new List(); + + [Command("job", "~r~Verwende: ~w~ /job [JobName]")] + public void CMD_Job(Client player, string JobName) + { + if (player.HasData("BusJob")) + { + NAPI.Notification.SendNotificationToPlayer(player, "Du hast schon einen Job!"); + } + if (!player.HasData("BusJob") && (JobName == "Busfahrer")) + { + player.SetData("BusJob", true); + NAPI.Notification.SendNotificationToPlayer(player, "Du hast den Job Busfahrer angenommen"); + } + } + + [Command("jobs")] + public void CMD_Jobs(Client player) + { + NAPI.Chat.SendChatMessageToPlayer(player, "Jobs: Busfahrer"); + } + + [Command("quitjob")] + public void CMD_QuitJob(Client player) + { + player.ResetData("BusJob"); + NAPI.Notification.SendNotificationToPlayer(player, "Du hast deinen Job gekündigt"); + } + + [Command("stopjob")] + public void CMD_StopJob(Client player) + { + if (!player.HasData("BusJobAn")) // Wenn Spieler keinen Job angefangen hat + { + NAPI.Notification.SendNotificationToPlayer(player, "Du hast keinen Job begonnen"); + return; + } + else if (player.HasData("BusJobAn")) // Wenn Spieler Job angefangen hat + { + NAPI.Notification.SendNotificationToPlayer(player, "Du hast deinen Job beendet. Deinen Lohn erhälst du am Payday."); + player.ResetData("BusJobAn"); + player.TriggerEvent("clear_all_blips"); + } + } + + [Command("startjob")] + public void CMD_AddPosition(Client client, string route, float size) + { + if (route == "1" && client.HasData("BusJob")) + { + NAPI.Notification.SendNotificationToPlayer(client, "Du hast die Route 1 ausgewählt, fahre jetzt die Haltestellen ab."); + client.SetData("BusJobAn", true); + NewPositions.Add(new Vector3(308.0671, -762.0952, 29.21954)); + NewPositions.Add(new Vector3(-105.5951, -1684.548, 29.23948)); + NewPositions.Add(new Vector3(-1056.246, -2552.576, 13.66063)); + NewPositions.Add(new Vector3(200.3088, -1978.828, 19.3329)); + NewPositions.Add(new Vector3(358.6138, -1785.821, 28.92113)); + NewPositions.Add(new Vector3(281.8594, -1462.503, 29.13148)); + NewPositions.Add(new Vector3(77.72239, -1212.086, 29.12294)); + NewPositions.Add(new Vector3(218.1398, -850.9549, 30.16619)); + JobInfo jobInfo = new JobInfo(); + foreach (Vector3 vector in NewPositions) + { + jobInfo.AddObjective(vector, size); + } + jobInfo.StartJob(client); + NewPositions = new List(); + } + else if (route == "2" && client.HasData("BusJob")) + { + NAPI.Notification.SendNotificationToPlayer(client, "Du hast die Route 2 ausgewählt, fahre jetzt die Haltestellen ab."); + client.SetData("BusJobAn", true); + NewPositions.Add(new Vector3(403.4488, -786.5514, 29.2046)); + NewPositions.Add(new Vector3(351.5793, -1064.582, 29.40059)); + NewPositions.Add(new Vector3(787.6898, -1364.566, 26.41318)); + NewPositions.Add(new Vector3(942.0541, -1447.974, 31.14204)); + NewPositions.Add(new Vector3(866.8322, -997.5225, 30.48207)); + NewPositions.Add(new Vector3(785.4254, -781.3905, 26.33277)); + NewPositions.Add(new Vector3(235.0964, -857.1152, 29.74256)); + JobInfo jobInfo = new JobInfo(); + foreach (Vector3 vector in NewPositions) + { + jobInfo.AddObjective(vector, size); + } + jobInfo.StartJob(client); + NewPositions = new List(); + } + /*else if (route == "3" && client.HasData("BusJob")) // Platzhalter für weitere Routen + { + NAPI.Notification.SendNotificationToPlayer(client, "Du hast die Route 3 ausgewählt, fahre jetzt die Haltestellen ab."); + client.SetData("BusJobAn", true); + NewPositions.Add(new Vector3(306.163, -767.4735, 29.20587)); + NewPositions.Add(new Vector3(76.55303, -1468.593, 29.23081)); + NewPositions.Add(new Vector3(-105.5951, -1684.548, 29.23948)); + NewPositions.Add(new Vector3(-1056.246, -2552.576, 13.66063)); + NewPositions.Add(new Vector3(200.3088, -1978.828, 19.3329)); + NewPositions.Add(new Vector3(358.6138, -1785.821, 28.92113)); + NewPositions.Add(new Vector3(281.8594, -1462.503, 29.13148)); + NewPositions.Add(new Vector3(77.72239, -1212.086, 29.12294)); + NewPositions.Add(new Vector3(218.1398, -850.9549, 30.16619)); + JobInfo jobInfo = new JobInfo(); + foreach (Vector3 vector in NewPositions) + { + jobInfo.AddObjective(vector, size); + } + jobInfo.StartJob(client); + NewPositions = new List(); + }*/ + } + } +} diff --git a/ReallifeGamemode.Server/Job/BusDriver/Events.cs b/ReallifeGamemode.Server/Job/BusDriver/Events.cs new file mode 100644 index 00000000..16666103 --- /dev/null +++ b/ReallifeGamemode.Server/Job/BusDriver/Events.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Text; +using GTANetworkAPI; + +namespace ReallifeGamemode.Server.Job.BusDriver +{ + public class Events : Script + { + // Client Events + + [RemoteEvent("marker_completed")] + public void RemoteEvent_MarkerCompleted(Client client) + { + if (!client.HasData("Job")) + return; + + JobInfo jobInfo = client.GetData("Job"); + jobInfo.CheckObjective(client); + } + } +} diff --git a/ReallifeGamemode.Server/Job/BusDriver/JobBlips.cs b/ReallifeGamemode.Server/Job/BusDriver/JobBlips.cs new file mode 100644 index 00000000..6e2255ba --- /dev/null +++ b/ReallifeGamemode.Server/Job/BusDriver/JobBlips.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Text; +using GTANetworkAPI; + +namespace ReallifeGamemode.Server.Job.BusDriver +{ + public class JobBlips : Script + { + // Route 1 + Blip Blip = NAPI.Blip.CreateBlip(513, new Vector3(308.0671, -762.0952, 29.21954), 1, 4, "Haltestelle(R1)", 255, 0, true); + Blip Blip2 = NAPI.Blip.CreateBlip(513, new Vector3(-105.5951, -1684.548, 29.23948), 1, 4, "Haltestelle(R1)", 255, 0, true); + Blip Blip3 = NAPI.Blip.CreateBlip(513, new Vector3(-1056.246, -2552.576, 13.66063), 1, 4, "Haltestelle(R1)", 255, 0, true); + Blip Blip4 = NAPI.Blip.CreateBlip(513, new Vector3(200.3088, -1978.828, 19.3329), 1, 4, "Haltestelle(R1)", 255, 0, true); + Blip Blip5 = NAPI.Blip.CreateBlip(513, new Vector3(358.6138, -1785.821, 28.92113), 1, 4, "Haltestelle(R1)", 255, 0, true); + Blip Blip6 = NAPI.Blip.CreateBlip(513, new Vector3(281.8594, -1462.503, 29.13148), 1, 4, "Haltestelle(R1)", 255, 0, true); + Blip Blip7 = NAPI.Blip.CreateBlip(513, new Vector3(77.72239, -1212.086, 29.12294), 1, 4, "Haltestelle(R1)", 255, 0, true); + Blip Blip8 = NAPI.Blip.CreateBlip(513, new Vector3(218.1398, -850.9549, 30.16619), 1, 4, "Haltestelle(R1)", 255, 0, true); + + //Route 2 + Blip Blip9 = NAPI.Blip.CreateBlip(513, new Vector3(403.4488, -786.5514, 29.2046), 1, 27, "Haltestelle(R2)", 255, 0, true); + Blip Blip11 = NAPI.Blip.CreateBlip(513, new Vector3(787.6898, -1364.566, 26.41318), 1, 27, "Haltestelle(R2)", 255, 0, true); + Blip Blip12 = NAPI.Blip.CreateBlip(513, new Vector3(942.0541, -1447.974, 31.14204), 1, 27, "Haltestelle(R2)", 255, 0, true); + Blip Blip13 = NAPI.Blip.CreateBlip(513, new Vector3(866.8322, -997.5225, 30.48207), 1, 27, "Haltestelle(R2)", 255, 0, true); + Blip Blip14 = NAPI.Blip.CreateBlip(513, new Vector3(785.4254, -781.3905, 26.33277), 1, 27, "Haltestelle(R2)", 255, 0, true); + Blip Blip15 = NAPI.Blip.CreateBlip(513, new Vector3(351.5793, -1064.582, 29.40059), 1, 27, "Haltestelle(R2)", 255, 0, true); + Blip Blip16 = NAPI.Blip.CreateBlip(513, new Vector3(235.0964, -857.1152, 29.74256), 1, 27, "Haltestelle(R2)", 255, 0, true); + + // Route 3 // Platzhalter weitere Blips Routen + /*Blip Blip17 = NAPI.Blip.CreateBlip(513, new Vector3(306.163, -767.4735, 29.20587), 1, 49, "Haltestelle(R3)", 255, 0, true); + Blip Blip18 = NAPI.Blip.CreateBlip(513, new Vector3(76.55303, -1468.593, 29.23081), 1, 49, "Haltestelle(R3)", 255, 0, true); + Blip Blip19 = NAPI.Blip.CreateBlip(513, new Vector3(-105.5951, -1684.548, 29.23948), 1, 49, "Haltestelle(R3)", 255, 0, true); + Blip Blip20 = NAPI.Blip.CreateBlip(513, new Vector3(-1056.246, -2552.576, 13.66063), 1, 49, "Haltestelle(R3)", 255, 0, true); + Blip Blip21 = NAPI.Blip.CreateBlip(513, new Vector3(200.3088, -1978.828, 19.3329), 1, 49, "Haltestelle(R3)", 255, 0, true); + Blip Blip22 = NAPI.Blip.CreateBlip(513, new Vector3(358.6138, -1785.821, 28.92113), 1, 49, "Haltestelle(R3)", 255, 0, true); + Blip Blip23 = NAPI.Blip.CreateBlip(513, new Vector3(281.8594, -1462.503, 29.13148), 1, 49, "Haltestelle(R3)", 255, 0, true); + Blip Blip24 = NAPI.Blip.CreateBlip(513, new Vector3(77.72239, -1212.086, 29.12294), 1, 49, "Haltestelle(R3)", 255, 0, true); + Blip Blip25 = NAPI.Blip.CreateBlip(513, new Vector3(218.1398, -850.9549, 30.16619), 1, 49, "Haltestelle(R3)", 255, 0, true);*/ + } +} diff --git a/ReallifeGamemode.Server/Job/BusDriver/JobInfoCheckPoints.cs b/ReallifeGamemode.Server/Job/BusDriver/JobInfoCheckPoints.cs new file mode 100644 index 00000000..4cc381e5 --- /dev/null +++ b/ReallifeGamemode.Server/Job/BusDriver/JobInfoCheckPoints.cs @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; +using System.Text; +using GTANetworkAPI; + +namespace ReallifeGamemode.Server.Job.BusDriver +{ + public class JobInfo + { + public Queue Objectives = new Queue(); + public Client Owner { get; set; } + + + public void AddObjective(Vector3 position, float size) + { + ObjectiveInfo objectiveInfo = new ObjectiveInfo(); + objectiveInfo.Position = position; + objectiveInfo.Size = size; + + Objectives.Enqueue(objectiveInfo); + } + + public void StartJob(Client client) + { + Owner = client; + NextObjective(client); + + client.SetData("Job", this); + } + + public void NextObjective(Client client) + { + ObjectiveInfo next_objective = Objectives.Peek(); + client.TriggerEvent("load_objective", next_objective.Position, next_objective.Size); + } + + public void CheckObjective(Client client) + { + ObjectiveInfo current_objective = Objectives.Peek(); + + if (!current_objective.IsInObjective(client)) + return; + + Objectives.Dequeue(); + + if (Objectives.Count == 0) + { + client.SendNotification("Du hast alle ~r~Haltestellen ~w~ abgefahren."); + client.SendNotification("Fahre zurück zum Busbahnhof und bringe deinen Bus zurück."); + client.TriggerEvent("clear_all_markers"); + + return; + } + + NextObjective(client); + } + } +} diff --git a/ReallifeGamemode.Server/Job/BusDriver/ObjectiveInfo.cs b/ReallifeGamemode.Server/Job/BusDriver/ObjectiveInfo.cs new file mode 100644 index 00000000..eb9f57ae --- /dev/null +++ b/ReallifeGamemode.Server/Job/BusDriver/ObjectiveInfo.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Text; +using GTANetworkAPI; + +namespace ReallifeGamemode.Server.Job.BusDriver +{ + public class ObjectiveInfo + { + public Vector3 Position { get; set; } + public float Size { get; set; } + + public bool IsInObjective(Client client) + { + return (client.Position.DistanceTo2D(Position) <= Size) ? true : false; + } + } +} diff --git a/ReallifeGamemode.Server/Report/Report.cs b/ReallifeGamemode.Server/Report/Report.cs index a0a59d3f..7a094eeb 100644 --- a/ReallifeGamemode.Server/Report/Report.cs +++ b/ReallifeGamemode.Server/Report/Report.cs @@ -65,7 +65,7 @@ namespace ReallifeGamemode.Server.Report return; ChatService.SendMessage(player, "Admin " + admin.Name + " hat dein Ticket angenommen! (Benutze /rc)"); - ChatService.BroadcastAdmin(admin.Name + " hat das Ticket von " + player.Name + " angenommen", AdminLevel.ADMIN); + ChatService.BroadcastDutyAdmin(admin.Name + " hat das Ticket von " + player.Name + " angenommen"); for (int a = 0; a < listReports.Count; a++) { @@ -86,39 +86,54 @@ namespace ReallifeGamemode.Server.Report String adminname = "N/A"; ReportManage temp = null; - for (int a = 0; a < listReports.Count; a++) - { - temp = listReports[a]; - if (temp.getUser().Equals(client.Name)) - { - cont = true; - adminname = listReports[a].getAdmin(); - break; - } - } - - if (!cont) - { - return; - } - - Client admin = ClientService.GetClientByNameOrId(adminname); - + //Für Admin if (client.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) { + for (int a = 0; a < listReports.Count; a++) + { + temp = listReports[a]; + if (temp.getAdmin().Equals(client.Name)) + { + username = listReports[a].getUser(); + break; + } + } + Client user = ClientService.GetClientByNameOrId(username); + if (text.Equals("quit")) { - ChatService.SendMessage(client, "~y~(REPORT) Chat vom Admin beendet"); - ChatService.SendMessage(admin, "~y~(REPORT) Chat beendet"); + ChatService.SendMessage(user, "~y~(REPORT) Chat vom Admin beendet"); + ChatService.SendMessage(client, "~y~(REPORT) Chat beendet"); listReports.Remove(temp); return; } + else{ + ChatService.SendMessage(client, "~y~" + username + " (REPORT): " + text); + ChatService.SendMessage(user, "~y~" + username + " (REPORT): " + text); + } + } + //Für User + else + { + for (int a = 0; a < listReports.Count; a++) + { + temp = listReports[a]; + if (temp.getUser().Equals(client.Name)) + { + cont = true; + adminname = listReports[a].getAdmin(); + break; + } + } + if(!cont) + { + return; + } + Client admin = ClientService.GetClientByNameOrId(adminname); + ChatService.SendMessage(admin, "~y~" + username + " (REPORT): " + text); + ChatService.SendMessage(client, "~y~" + username + " (REPORT): " + text); } - - ChatService.SendMessage(client, "~y~" + username + " (REPORT): " + text); - ChatService.SendMessage(admin, "~y~" + username + " (REPORT): " + text); - } [RemoteEvent("requestReport")] @@ -126,7 +141,7 @@ namespace ReallifeGamemode.Server.Report { if (type == "Ticket Report") { - ChatService.BroadcastAdmin("Eingehendes Ticket von " + user.Name + ": " + data + " (Benutze /showtickets)", AdminLevel.ADMIN); + ChatService.BroadcastDutyAdmin("Eingehendes Ticket von " + user.Name + ": " + data + " (Benutze /showtickets)"); ReportManage ticket = new ReportManage(user.Name, data); listReports.Add(ticket); } @@ -149,7 +164,7 @@ namespace ReallifeGamemode.Server.Report if (temp.getUser().Equals(player.Name)) { ChatService.Broadcast("Ticket von " + player.Name + " gelöscht!"); - ChatService.BroadcastAdmin(user.Name + " hat das Ticket von " + player.Name + " gelöscht", AdminLevel.ADMIN); + ChatService.BroadcastDutyAdmin(user.Name + " hat das Ticket von " + player.Name + " gelöscht"); listReports.Remove(temp); } } diff --git a/ReallifeGamemode.Server/Services/ChatService.cs b/ReallifeGamemode.Server/Services/ChatService.cs index be1109e6..a3a113a4 100644 --- a/ReallifeGamemode.Server/Services/ChatService.cs +++ b/ReallifeGamemode.Server/Services/ChatService.cs @@ -86,6 +86,13 @@ namespace ReallifeGamemode.Server.Services } }); } + public static void BroadcastDutyAdmin(string message) + { + foreach (Client admin in UserHelper.dutyAdmins) + { + ChatService.SendMessage(admin, message); + } + } public static void BroadcastGroup(string message, Group group) { diff --git a/ReallifeGamemode.Server/Util/UserHelper.cs b/ReallifeGamemode.Server/Util/UserHelper.cs new file mode 100644 index 00000000..e0d6de98 --- /dev/null +++ b/ReallifeGamemode.Server/Util/UserHelper.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Collections; +using GTANetworkAPI; + +namespace ReallifeGamemode.Server.Util +{ + static class UserHelper + { + public static List dutyAdmins = new List(); + } +}