Add Punktesystem, Anfang Ticketsystem

This commit is contained in:
Mac_Slash
2020-04-08 14:18:52 +02:00
parent e18f6e7e90
commit 176f098b4f

View File

@@ -13,6 +13,7 @@ using System.Text;
using ReallifeGamemode.Database; using ReallifeGamemode.Database;
using ReallifeGamemode.Services; using ReallifeGamemode.Services;
using ReallifeGamemode.Server.Types; using ReallifeGamemode.Server.Types;
using System.Buffers;
/** /**
* @overview Life of German Reallife - Managers Interaction (InteractionManager.cs) * @overview Life of German Reallife - Managers Interaction (InteractionManager.cs)
@@ -369,6 +370,58 @@ namespace ReallifeGamemode.Server.Managers
veh.Delete(); veh.Delete();
} }
} }
[RemoteEvent("CLIENT:InteractionMenu_LSPD_Ticket3")]
public void InteractionMenu_LSPD_Ticket3(Player player, string jsonNameOrId, string jsoAmount, string jsonReason)
{
string nameOrId = (string)JsonConvert.DeserializeObject(jsonNameOrId);
int amount = Int32.Parse((string)JsonConvert.DeserializeObject(jsoAmount));
string reason = (string)JsonConvert.DeserializeObject(jsonReason);
Player target = PlayerService.GetPlayerByNameOrId(nameOrId);
string playername = NAPI.Player.GetPlayerName(player);
string targetname = NAPI.Player.GetPlayerName(target);
player.SendNotification($"~w~Du hast ~y~{targetname} ~w~ein Ticket in Höhe von ~b~{amount}$ ~w~gestellt. Grund: ~g~{reason}~w~.");
target.SendNotification($"~b~{player.GetUser().FactionRank.RankName} | {playername} ~w~hat dir ein Ticket in Höhe von ~y~{amount}$ ~w~gestellt.", true);
target.SendNotification($"~w~Grund: ~g~{reason}~w~. ~x~Strafticket im Interaktionsmenü annehmen.", true);
//target.SendChatMessage("Du kannst mit '/accept ticket' das Strafticket annehmen.");
}
[RemoteEvent("CLIENT:InteractionMenu_LSPD_Points3")]
public void InteractionMenu_LSPD_Points3(Player player, string jsonNameOrId, string jsoAmount, string jsonReason)
{
string nameOrId = (string)JsonConvert.DeserializeObject(jsonNameOrId);
int amount = Int32.Parse((string)JsonConvert.DeserializeObject(jsoAmount));
string reason = (string)JsonConvert.DeserializeObject(jsonReason);
Player target = PlayerService.GetPlayerByNameOrId(nameOrId);
string playername = NAPI.Player.GetPlayerName(player);
string targetname = NAPI.Player.GetPlayerName(target);
using (var dbContext = new DatabaseContext())
{
User target2 = target.GetUser(dbContext);
target2.Points += amount;
dbContext.SaveChanges();
}
player.SendNotification($"~w~Du hast ~y~{targetname} ~b~{amount} ~w~Strafpunkte gegeben. Grund: ~g~{reason}~w~.");
target.SendNotification($"~b~{player.GetUser().FactionRank.RankName} | {playername} ~w~hat dir ~y~{amount} ~w~Strafpunkte gegeben.", true);
if(target.GetUser().Points >= 8)
{
target.SendNotification($"~w~Grund: ~g~{reason}~w~. ~x~Du hast nun ~r~8/8 ~x~Strafpunkten.", true);
target.SendNotification($"~w~Dir wird ~r~Auo- ~w~und ~r~Motorradführerschein ~w~entzogen.", true);
using (var dbContext = new DatabaseContext())
{
User target2 = target.GetUser(dbContext);
target2.Points = 0;
target2.DriverLicenseVehicle = false;
target2.DriverLicenseBike = false;
dbContext.SaveChanges();
}
}
else
{
target.SendNotification($"~w~Grund: ~g~{reason}~w~. ~x~Du hast nun ~y~{target.GetUser().Points}/8 ~x~Strafpunkten.", true);
}
}
#endregion #endregion
#region Spielerinteraktionen PFEILTASTE-LINKS #region Spielerinteraktionen PFEILTASTE-LINKS
[RemoteEvent("openTradeInventory")] [RemoteEvent("openTradeInventory")]