Merge branch 'feature/look' into develop
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using GTANetworkAPI;
|
||||
using Newtonsoft.Json;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
@@ -16,6 +17,42 @@ namespace ReallifeGamemode.Server.Commands
|
||||
{
|
||||
internal class UserCommands : Script
|
||||
{
|
||||
[Command("look", "~m~look")]
|
||||
public void CmdUserLook(Player player)
|
||||
{
|
||||
if (!player.IsLoggedIn()) return;
|
||||
|
||||
Vehicle veh = NAPI.Pools.GetAllVehicles()
|
||||
.Where(v => v.Position.DistanceTo(player.Position) <= 5)
|
||||
.OrderBy(v => v.Position.DistanceTo(player.Position))
|
||||
.FirstOrDefault();
|
||||
|
||||
if (veh == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var lastDriverDic = new Dictionary<string, DateTime>();
|
||||
|
||||
if(VehicleManager.lastDriversInVehicle.ContainsKey(veh))
|
||||
{
|
||||
lastDriverDic = VehicleManager.lastDriversInVehicle[veh];
|
||||
}
|
||||
else
|
||||
{
|
||||
player.SendNotification("~r~Mit diesem Fahrzeug ist noch niemand gefahren");
|
||||
return;
|
||||
}
|
||||
|
||||
var list = lastDriverDic.Select(v => new
|
||||
{
|
||||
Name = v.Key,
|
||||
Time = v.Value
|
||||
}).OrderByDescending(v => v.Time).ToList();
|
||||
|
||||
player.TriggerEvent("lookLastDrivers", JsonConvert.SerializeObject(list));
|
||||
}
|
||||
|
||||
[Command("id", "~m~Benutzung: ~s~/id [Name]")]
|
||||
public void CmdUserId(Player player, String targetname)
|
||||
{
|
||||
@@ -61,7 +98,7 @@ namespace ReallifeGamemode.Server.Commands
|
||||
}
|
||||
else
|
||||
{
|
||||
pVeh = NAPI.Pools.GetAllVehicles().Where(v => v.Position.DistanceTo(player.Position) <= 5).FirstOrDefault();
|
||||
pVeh = NAPI.Pools.GetAllVehicles().Where(v => v.Position.DistanceTo(player.Position) <= 5).OrderBy(v => v.Position.DistanceTo(player.Position)).FirstOrDefault();
|
||||
}
|
||||
|
||||
if (pVeh == null)
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using GTANetworkAPI;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Server.Managers;
|
||||
using ReallifeGamemode.Server.Util;
|
||||
using ReallifeGamemode.Server.WeaponDeal;
|
||||
|
||||
@@ -20,6 +22,13 @@ namespace ReallifeGamemode.Server.Events
|
||||
if (vehicle.HasMarkerBehind())
|
||||
vehicle.RemoveMarkerBehind();
|
||||
|
||||
if (!VehicleManager.lastDriversInVehicle.ContainsKey(vehicle))
|
||||
{
|
||||
VehicleManager.lastDriversInVehicle.Add(vehicle, new Dictionary<string, DateTime>());
|
||||
}
|
||||
|
||||
VehicleManager.lastDriversInVehicle[vehicle][client.Name] = DateTime.Now;
|
||||
|
||||
if (vehicle.GetServerVehicle() is FactionVehicle veh)
|
||||
{
|
||||
User u = client.GetUser();
|
||||
|
||||
@@ -14,6 +14,9 @@ namespace ReallifeGamemode.Server.Managers
|
||||
{
|
||||
public class VehicleManager : Script
|
||||
{
|
||||
|
||||
public static Dictionary<Vehicle, Dictionary<string, DateTime>> lastDriversInVehicle = new Dictionary<Vehicle, Dictionary<string, DateTime>>();
|
||||
|
||||
private static readonly List<string> _enabledMods = new List<string>()
|
||||
{
|
||||
"ninef",
|
||||
|
||||
Reference in New Issue
Block a user