added aduty system + added ChatService.BroadcastDutyAdmin + fixes in report system + added paaqos busdriver job

This commit is contained in:
2019-09-03 01:04:02 +02:00
parent 18364264f9
commit a6ff47d073
11 changed files with 471 additions and 27 deletions

View File

@@ -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<CheckpointInstance> Checkpoints = new List<CheckpointInstance>();
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);
}
}
}

View File

@@ -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<Events.TickNametagData> 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);
}
}
}

View File

@@ -122,6 +122,28 @@ namespace ReallifeGamemode.Server.Commands
#endregion #endregion
#region Support #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)] [Command("o", "~m~Benutzung: ~s~/o [Nachricht]", GreedyArg = true)]
public void CmdAdminO(Client player, string message) public void CmdAdminO(Client player, string message)
{ {

View File

@@ -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<Vector3> NewPositions = new List<Vector3>();
[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<Vector3>();
}
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<Vector3>();
}
/*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<Vector3>();
}*/
}
}
}

View File

@@ -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);
}
}
}

View File

@@ -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);*/
}
}

View File

@@ -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<ObjectiveInfo> Objectives = new Queue<ObjectiveInfo>();
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);
}
}
}

View File

@@ -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;
}
}
}

View File

@@ -65,7 +65,7 @@ namespace ReallifeGamemode.Server.Report
return; return;
ChatService.SendMessage(player, "Admin " + admin.Name + " hat dein Ticket angenommen! (Benutze /rc)"); 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++) for (int a = 0; a < listReports.Count; a++)
{ {
@@ -86,6 +86,36 @@ namespace ReallifeGamemode.Server.Report
String adminname = "N/A"; String adminname = "N/A";
ReportManage temp = null; ReportManage temp = null;
//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(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++) for (int a = 0; a < listReports.Count; a++)
{ {
temp = listReports[a]; temp = listReports[a];
@@ -96,29 +126,14 @@ namespace ReallifeGamemode.Server.Report
break; break;
} }
} }
if(!cont)
if (!cont)
{ {
return; return;
} }
Client admin = ClientService.GetClientByNameOrId(adminname); Client admin = ClientService.GetClientByNameOrId(adminname);
if (client.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true)
{
if (text.Equals("quit"))
{
ChatService.SendMessage(client, "~y~(REPORT) Chat vom Admin beendet");
ChatService.SendMessage(admin, "~y~(REPORT) Chat beendet");
listReports.Remove(temp);
return;
}
}
ChatService.SendMessage(client, "~y~" + username + " (REPORT): " + text);
ChatService.SendMessage(admin, "~y~" + username + " (REPORT): " + text); ChatService.SendMessage(admin, "~y~" + username + " (REPORT): " + text);
ChatService.SendMessage(client, "~y~" + username + " (REPORT): " + text);
}
} }
[RemoteEvent("requestReport")] [RemoteEvent("requestReport")]
@@ -126,7 +141,7 @@ namespace ReallifeGamemode.Server.Report
{ {
if (type == "Ticket 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); ReportManage ticket = new ReportManage(user.Name, data);
listReports.Add(ticket); listReports.Add(ticket);
} }
@@ -149,7 +164,7 @@ namespace ReallifeGamemode.Server.Report
if (temp.getUser().Equals(player.Name)) if (temp.getUser().Equals(player.Name))
{ {
ChatService.Broadcast("Ticket von " + player.Name + " gelöscht!"); 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); listReports.Remove(temp);
} }
} }

View File

@@ -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) public static void BroadcastGroup(string message, Group group)
{ {

View File

@@ -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<Client> dutyAdmins = new List<Client>();
}
}