hanf vielleicht fertig
This commit is contained in:
@@ -18,6 +18,7 @@ using ReallifeGamemode.Server.Core.API;
|
||||
using ReallifeGamemode.Server.Factions.Medic;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using ReallifeGamemode.Server.Log;
|
||||
using ReallifeGamemode.Server.Inventory.Interfaces;
|
||||
|
||||
/**
|
||||
* @overview Life of German Reallife - Managers Interaction (InteractionManager.cs)
|
||||
@@ -758,6 +759,150 @@ namespace ReallifeGamemode.Server.Managers
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("CLIENT:InteractionMenu_LSPD_FriskUser")]
|
||||
public void InteractionMenuLspdFriskUser(Player player, string name)
|
||||
{
|
||||
if (!player.IsLoggedIn())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Player target = PlayerService.GetPlayerByNameOrId(name);
|
||||
if (!target.IsLoggedIn())
|
||||
{
|
||||
ChatService.PlayerNotFound(player);
|
||||
return;
|
||||
}
|
||||
|
||||
using var dbContext = new DatabaseContext();
|
||||
var user = player.GetUser(dbContext);
|
||||
|
||||
if ((user.FactionId != 1 && user.FactionId != 3) || !player.IsDuty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.Position.DistanceTo(target.Position) > 5)
|
||||
{
|
||||
player.SendNotification("~r~Der Spieler ist nicht in deiner Nähe");
|
||||
return;
|
||||
}
|
||||
|
||||
var targetUser = target.GetUser(dbContext);
|
||||
|
||||
var targetItems = InventoryManager.GetUserItems(target, dbContext);
|
||||
List<string> illItemsList = new List<string>();
|
||||
bool illegalItemsFound = false;
|
||||
var price = 0;
|
||||
|
||||
foreach (var targetItem in targetItems)
|
||||
{
|
||||
IItem item = InventoryManager.GetItemById(targetItem.ItemId);
|
||||
if (!item.Legal)
|
||||
{
|
||||
illItemsList.Add($"{targetItem.Amount}x {item.Name}");
|
||||
InventoryManager.RemoveUserItem(targetUser, targetItem, targetItem.Amount);
|
||||
illegalItemsFound = true;
|
||||
price += ((IIllegalItem)item).PriceForConfiscation * targetItem.Amount;
|
||||
logger.LogInformation("Player {0} confiscated the illegal item {1} ({2}, amount: {3}) from player {4}", player.Name, item.Name, item.Id, targetItem.Amount, target.Name);
|
||||
}
|
||||
}
|
||||
|
||||
if (!illegalItemsFound)
|
||||
{
|
||||
player.SendNotification("~g~Der Spieler hat keine illegalen Gegenstände dabei");
|
||||
return;
|
||||
}
|
||||
|
||||
logger.LogInformation("executive factions got {0} dollars from the confiscation", price);
|
||||
var factions = dbContext.Factions.Include(f => f.BankAccount).Where(f => f.Id == 1 || f.Id == 3);
|
||||
foreach (var faction in factions)
|
||||
{
|
||||
faction.BankAccount.Balance += price;
|
||||
}
|
||||
|
||||
dbContext.SaveChanges();
|
||||
|
||||
string illItemsStr = "~y~" + string.Join("~s~,~y~ ", illItemsList) + "~s~";
|
||||
ChatService.SendMessage(player, $"Du hast ~y~{target.Name}~s~ folgende Gegenstände abgenommen: {illItemsStr}");
|
||||
ChatService.SendMessage(target, $"~y~{player.Name}~s~ hat die folgende Gegenstände abgenommen: {illItemsStr}");
|
||||
|
||||
}
|
||||
|
||||
[RemoteEvent("CLIENT:InteractionMenu_LSPD_FriskVehicle")]
|
||||
public void InteractionMenuLspdFriskVehicle(Player player)
|
||||
{
|
||||
if (!player.IsLoggedIn())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
using var dbContext = new DatabaseContext();
|
||||
var user = player.GetUser(dbContext);
|
||||
|
||||
if ((user.FactionId != 1 && user.FactionId != 3) || !player.IsDuty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var vehicle = NAPI.Pools.GetAllVehicles().Where(v => v.Position.DistanceTo(player.Position) <= 5).OrderBy(v => v.Position.DistanceTo(player.Position)).FirstOrDefault();
|
||||
if (vehicle == null)
|
||||
{
|
||||
player.SendNotification("~r~Es befindet sich kein Fahrzeug in deiner Nähe");
|
||||
return;
|
||||
}
|
||||
|
||||
ServerVehicle serverVehicle = vehicle.GetServerVehicle(dbContext);
|
||||
if (serverVehicle == null)
|
||||
{
|
||||
player.SendNotification("~r~Dieses Fahrzeug kann nicht durchsucht werden");
|
||||
return;
|
||||
}
|
||||
|
||||
if (VehicleStreaming.GetLockState(vehicle) || serverVehicle.Locked)
|
||||
{
|
||||
player.SendNotification("~r~Dieses Fahrzeug ist abgeschlossen");
|
||||
return;
|
||||
}
|
||||
|
||||
var targetItems = InventoryManager.GetVehicleItems(vehicle);
|
||||
List<string> illItemsList = new List<string>();
|
||||
bool illegalItemsFound = false;
|
||||
var price = 0;
|
||||
|
||||
foreach (var targetItem in targetItems)
|
||||
{
|
||||
IItem item = InventoryManager.GetItemById(targetItem.ItemId);
|
||||
if (!item.Legal)
|
||||
{
|
||||
illItemsList.Add($"{targetItem.Amount}x {item.Name}");
|
||||
InventoryManager.RemoveVehicleItem(serverVehicle, targetItem, targetItem.Amount, null);
|
||||
illegalItemsFound = true;
|
||||
price += ((IIllegalItem)item).PriceForConfiscation * targetItem.Amount;
|
||||
logger.LogInformation("Player {0} confiscated the illegal item {1} ({2}, amount: {3}) from vehicle {4}", player.Name, item.Name, item.Id, targetItem.Amount, serverVehicle.Id);
|
||||
}
|
||||
}
|
||||
|
||||
if (!illegalItemsFound)
|
||||
{
|
||||
player.SendNotification("~g~Im Kofferraum sind keine illegalen Gegenstände");
|
||||
return;
|
||||
}
|
||||
|
||||
logger.LogInformation("executive factions got {0} dollars from the confiscation", price);
|
||||
|
||||
var factions = dbContext.Factions.Include(f => f.BankAccount).Where(f => f.Id == 1 || f.Id == 3);
|
||||
foreach (var faction in factions)
|
||||
{
|
||||
faction.BankAccount.Balance += price;
|
||||
}
|
||||
|
||||
dbContext.SaveChanges();
|
||||
|
||||
string illItemsStr = "~y~" + string.Join("~s~,~y~ ", illItemsList) + "~s~";
|
||||
ChatService.SendInRange(player.Position, 20, $"{player.Name} hat aus dem Kofferraum folgende Gegenstände beschlagnahmt: {illItemsStr}");
|
||||
}
|
||||
|
||||
[RemoteEvent("CLIENT:InteractionMenu_Pay")]
|
||||
public void InteractionMenu_Pay(Player player, string jsonNameOrId, string stringAmount)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user