Merge branch 'feature/look' into develop

This commit is contained in:
hydrant
2021-04-15 12:39:37 +02:00
9 changed files with 294 additions and 2 deletions

View File

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