2018-04-08 17:50:58 -04:00
|
|
|
|
using SharedLibraryCore;
|
|
|
|
|
using SharedLibraryCore.Objects;
|
|
|
|
|
using SharedLibraryCore.Services;
|
|
|
|
|
using IW4MAdmin.Plugins.Stats.Models;
|
2018-02-10 01:26:38 -05:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
2018-04-08 17:50:58 -04:00
|
|
|
|
namespace IW4MAdmin.Plugins.Stats.Commands
|
2018-02-10 01:26:38 -05:00
|
|
|
|
{
|
|
|
|
|
class TopStats : Command
|
|
|
|
|
{
|
|
|
|
|
public TopStats() : base("topstats", "view the top 5 players on this server", "ts", Player.Permission.User, false) { }
|
|
|
|
|
|
|
|
|
|
public override async Task ExecuteAsync(Event E)
|
|
|
|
|
{
|
|
|
|
|
var statsSvc = new GenericRepository<EFClientStatistics>();
|
2018-03-25 00:32:54 -04:00
|
|
|
|
int serverId = E.Owner.GetHashCode();
|
2018-02-15 23:01:28 -05:00
|
|
|
|
var iqStats = statsSvc.GetQuery(cs => cs.ServerId == serverId);
|
2018-02-10 01:26:38 -05:00
|
|
|
|
|
|
|
|
|
var topStats = iqStats.Where(cs => cs.Skill > 100)
|
2018-03-25 00:32:54 -04:00
|
|
|
|
.Where(cs => cs.TimePlayed >= 3600)
|
|
|
|
|
.Where(cs => cs.Client.Level != Player.Permission.Banned)
|
2018-02-10 01:26:38 -05:00
|
|
|
|
.OrderByDescending(cs => cs.Skill)
|
|
|
|
|
.Take(5)
|
|
|
|
|
.ToList();
|
|
|
|
|
|
|
|
|
|
if (!E.Message.IsBroadcastCommand())
|
|
|
|
|
{
|
|
|
|
|
await E.Origin.Tell("^5--Top Players--");
|
|
|
|
|
|
|
|
|
|
foreach (var stat in topStats)
|
|
|
|
|
await E.Origin.Tell($"^3{stat.Client.Name}^7 - ^5{stat.KDR} ^7KDR | ^5{stat.Skill} ^7SKILL");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
await E.Owner.Broadcast("^5--Top Players--");
|
|
|
|
|
|
|
|
|
|
foreach (var stat in topStats)
|
|
|
|
|
await E.Owner.Broadcast($"^3{stat.Client.Name}^7 - ^5{stat.KDR} ^7KDR | ^5{stat.Skill} ^7SKILL");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|