[+] Add Driving License to Interaction Menu and as 'Object' to show other Players via the Interaction menu

This commit is contained in:
Lukas Moungos
2019-11-02 18:36:17 +01:00
parent e3c3949f1b
commit c46c778a47
14 changed files with 296 additions and 26 deletions

View File

@@ -0,0 +1,28 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Text;
namespace ReallifeGamemode.Server.DrivingSchool
{
public class Licenses
{
[JsonProperty("drivingLicenseCar")]
public bool CarLicense { get; set; }
[JsonProperty("drivingLicenseBike")]
public bool BikeLicense { get; set; }
[JsonProperty("flightLicensePlane")]
public bool PlaneLicense { get; set; }
public Licenses(bool CarLicense, bool BikeLicense, bool PlaneLicense)
{
this.CarLicense = CarLicense;
this.BikeLicense = BikeLicense;
this.PlaneLicense = PlaneLicense;
}
}
}

View File

@@ -14,6 +14,7 @@ using ReallifeGamemode.Database;
using ReallifeGamemode.Database.Models;
using ReallifeGamemode.Server.Util;
using ReallifeGamemode.Server.Inventory.Interfaces;
using ReallifeGamemode.Server.DrivingSchool;
/**
* @overview Life of German Reallife - Event Key (Key.cs)
* @author VegaZ
@@ -111,6 +112,8 @@ namespace ReallifeGamemode.Server.Events
Paycheck paycheck = null;
if (Economy.Paychecks.ContainsKey(u.Id)) paycheck = Economy.Paychecks[u.Id];
Licenses licenses = new Licenses(u.DriverLicenseVehicle, u.DriverLicenseBike, u.FlyingLicensePlane);
var accountData = new
{
regDate = u.RegistrationDate.ToShortDateString(),
@@ -120,7 +123,8 @@ namespace ReallifeGamemode.Server.Events
group = u.Group?.Name ?? "Keine",
groupRank = u.GroupRank.GetName(),
job = JobManager.GetJob(u.JobId ?? 0)?.Name ?? "Keiner",
paycheck
paycheck,
licenses
};
string faction = u.FactionLeader ? u.Faction.Name : null;

View File

@@ -99,6 +99,54 @@ namespace ReallifeGamemode.Server.Managers
}
}
}
[RemoteEvent("CLIENT:InteractionMenu_EndShow")]
public void InteractionMenuEndShow(Client client)
{
client.ResetData("ShowActive");
}
[RemoteEvent("CLIENT:InteractionMenu_Show")]
public void InteractionMenuShow(Client player, string type, string nameOrId)
{
if (type != "License")
return;
Client target = ClientService.GetClientByNameOrId(nameOrId);
if (target == null || !target.IsLoggedIn())
{
ChatService.PlayerNotFound(player);
return;
}
User targetUser = target.GetUser();
User playerUser = player.GetUser();
if (type == "License")
{
if (!playerUser.DriverLicenseBike && !playerUser.DriverLicenseVehicle && !playerUser.FlyingLicensePlane)
{
ChatService.ErrorMessage(player, "Sie besitzen keine Scheine");
return;
}
if (player.Position.DistanceTo(target.Position) > 5)
{
ChatService.ErrorMessage(player, "Spieler zu weit entfernt");
return;
}
if (target.HasData("ShowActive"))
{
ChatService.ErrorMessage(player, "Spieler ist beschäftigt");
return;
}
target.SetData("ShowActive", true);
List<bool> licenses = new List<bool>();
licenses.Add(playerUser.DriverLicenseVehicle);
licenses.Add(playerUser.DriverLicenseBike);
licenses.Add(playerUser.FlyingLicensePlane);
target.TriggerEvent("ShowLicenses", player.Name, licenses.ToArray());
}
}
[RemoteEvent("CLIENT:InteractionMenu_Invite")]
public void InteractionMenuInviteFaction(Client player, string type, string nameOrId)