added top player stats

fix for some commands returning multiple matches found when target not required
This commit is contained in:
RaidMax
2018-05-28 20:30:31 -05:00
parent 897ec0d0c1
commit 2204686b08
137 changed files with 426 additions and 41 deletions

View File

@ -1,5 +1,8 @@
using SharedLibraryCore;
using SharedLibraryCore.Objects;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace IW4ScriptCommands.Commands
@ -12,6 +15,48 @@ namespace IW4ScriptCommands.Commands
public override async Task ExecuteAsync(GameEvent E)
{
List<string> teamAssignments = new List<string>();
var clients = E.Owner.GetPlayersAsList().Select(c => new
{
Num = c.ClientNumber,
Elo = IW4MAdmin.Plugins.Stats.Plugin.Manager.GetClientStats(c.ClientId, E.Owner.GetHashCode()).EloRating,
CurrentTeam = IW4MAdmin.Plugins.Stats.Plugin.Manager.GetClientStats(c.ClientId, E.Owner.GetHashCode()).Team
})
.OrderByDescending(c => c.Elo)
.ToList();
int team = 0;
for (int i = 0; i < clients.Count(); i++)
{
if (i == 0)
{
team = 1;
continue;
}
if (i == 1)
{
team = 2;
continue;
}
if (i == 2)
{
team = 2;
continue;
}
if (i % 2 == 0)
{
if (team == 1)
team = 2;
else
team = 1;
}
teamAssignments.Add($"{clients[i].Num},{team}");
}
string args = string.Join(",", teamAssignments);
await E.Owner.SetDvarAsync("sv_iw4madmin_commandargs", args);
await E.Owner.ExecuteCommandAsync("sv_iw4madmin_command balance");
await E.Origin.Tell("Balance command sent");
}

View File

@ -13,6 +13,7 @@
<ItemGroup>
<ProjectReference Include="..\..\SharedLibraryCore\SharedLibraryCore.csproj" />
<ProjectReference Include="..\Stats\Stats.csproj" />
</ItemGroup>
<ItemGroup>