2017-09-27 16:07:43 -04:00
|
|
|
|
#if DEBUG
|
|
|
|
|
using System;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading.Tasks;
|
2017-11-25 20:29:58 -05:00
|
|
|
|
|
2018-04-19 18:52:48 -04:00
|
|
|
|
using SharedLibraryCore;
|
|
|
|
|
using SharedLibraryCore.Interfaces;
|
|
|
|
|
using SharedLibraryCore.Helpers;
|
2017-09-27 16:07:43 -04:00
|
|
|
|
|
|
|
|
|
namespace IW4MAdmin.Plugins
|
|
|
|
|
{
|
|
|
|
|
public class Tests : IPlugin
|
|
|
|
|
{
|
|
|
|
|
public string Name => "Dev Tests";
|
|
|
|
|
|
|
|
|
|
public float Version => 0.1f;
|
|
|
|
|
|
|
|
|
|
public string Author => "RaidMax";
|
|
|
|
|
|
2018-04-19 18:52:48 -04:00
|
|
|
|
public async Task OnEventAsync(GameEvent E, Server S)
|
2017-09-27 16:07:43 -04:00
|
|
|
|
{
|
2018-04-19 18:52:48 -04:00
|
|
|
|
if (E.Type == GameEvent.EventType.Start)
|
2017-09-27 16:07:43 -04:00
|
|
|
|
{
|
|
|
|
|
#region PLAYER_HISTORY
|
|
|
|
|
var rand = new Random(GetHashCode());
|
|
|
|
|
var time = DateTime.UtcNow;
|
|
|
|
|
|
|
|
|
|
await Task.Run(() =>
|
|
|
|
|
{
|
|
|
|
|
if (S.PlayerHistory.Count > 0)
|
|
|
|
|
return;
|
|
|
|
|
|
2017-11-02 12:49:45 -04:00
|
|
|
|
while (S.PlayerHistory.Count < 144)
|
2017-09-27 16:07:43 -04:00
|
|
|
|
{
|
|
|
|
|
S.PlayerHistory.Enqueue(new PlayerHistory(time, rand.Next(7, 18)));
|
2017-11-02 12:49:45 -04:00
|
|
|
|
time = time.AddMinutes(PlayerHistory.UpdateInterval);
|
2017-09-27 16:07:43 -04:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
#endregion
|
2017-11-13 18:17:10 -05:00
|
|
|
|
|
|
|
|
|
#region PLUGIN_INFO
|
2017-11-16 18:09:19 -05:00
|
|
|
|
Console.WriteLine("|Name |Alias|Description |Requires Target|Syntax |Required Level|");
|
|
|
|
|
Console.WriteLine("|--------------| -----| --------------------------------------------------------| -----------------| -------------| ----------------|");
|
2017-11-13 18:17:10 -05:00
|
|
|
|
foreach (var command in S.Manager.GetCommands().OrderByDescending(c => c.Permission).ThenBy(c => c.Name))
|
|
|
|
|
{
|
2017-11-16 18:09:19 -05:00
|
|
|
|
Console.WriteLine($"|{command.Name}|{command.Alias}|{command.Description}|{command.RequiresTarget}|{command.Syntax.Substring(8).EscapeMarkdown()}|{command.Permission}|");
|
2017-11-13 18:17:10 -05:00
|
|
|
|
}
|
|
|
|
|
#endregion
|
2017-09-27 16:07:43 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-19 18:52:48 -04:00
|
|
|
|
public Task OnLoadAsync(IManager manager) => Task.CompletedTask;
|
2017-09-27 16:07:43 -04:00
|
|
|
|
|
2018-04-26 02:13:04 -04:00
|
|
|
|
public Task OnTickAsync(Server S)
|
2017-09-27 16:07:43 -04:00
|
|
|
|
{
|
2018-04-26 02:13:04 -04:00
|
|
|
|
return Task.CompletedTask;
|
2018-04-19 18:52:48 -04:00
|
|
|
|
/*
|
2018-02-07 00:19:06 -05:00
|
|
|
|
if ((DateTime.Now - Interval).TotalSeconds > 1)
|
2017-09-27 16:07:43 -04:00
|
|
|
|
{
|
|
|
|
|
var rand = new Random();
|
|
|
|
|
int index = rand.Next(0, 17);
|
2017-11-25 20:29:58 -05:00
|
|
|
|
var p = new Player()
|
2017-09-27 16:07:43 -04:00
|
|
|
|
{
|
2017-11-29 19:35:50 -05:00
|
|
|
|
Name = $"Test_{index}",
|
2018-02-10 23:33:42 -05:00
|
|
|
|
NetworkId = (long)$"_test_{index}".GetHashCode(),
|
2017-11-25 20:29:58 -05:00
|
|
|
|
ClientNumber = index,
|
|
|
|
|
Ping = 1,
|
2018-02-10 23:33:42 -05:00
|
|
|
|
IPAddress = $"127.0.0.{index}".ConvertToIP()
|
2017-09-27 16:07:43 -04:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (S.Players.ElementAt(index) != null)
|
|
|
|
|
await S.RemovePlayer(index);
|
2018-02-10 23:33:42 -05:00
|
|
|
|
// await S.AddPlayer(p);
|
|
|
|
|
|
2017-11-02 18:20:10 -04:00
|
|
|
|
|
2017-09-27 16:07:43 -04:00
|
|
|
|
Interval = DateTime.Now;
|
2017-09-29 22:42:24 -04:00
|
|
|
|
if (S.ClientNum > 0)
|
|
|
|
|
{
|
|
|
|
|
var victimPlayer = S.Players.Where(pl => pl != null).ToList()[rand.Next(0, S.ClientNum - 1)];
|
|
|
|
|
var attackerPlayer = S.Players.Where(pl => pl != null).ToList()[rand.Next(0, S.ClientNum - 1)];
|
|
|
|
|
|
2017-11-25 20:29:58 -05:00
|
|
|
|
await S.ExecuteEvent(new Event(Event.GType.Say, $"test_{attackerPlayer.ClientNumber}", victimPlayer, attackerPlayer, S));
|
2017-11-02 18:20:10 -04:00
|
|
|
|
|
2017-09-29 22:42:24 -04:00
|
|
|
|
string[] eventLine = null;
|
|
|
|
|
|
2017-10-04 19:01:04 -04:00
|
|
|
|
for (int i = 0; i < 1; i++)
|
2017-09-29 22:42:24 -04:00
|
|
|
|
{
|
2017-10-04 19:01:04 -04:00
|
|
|
|
if (S.GameName == Server.Game.IW4)
|
2017-09-29 22:42:24 -04:00
|
|
|
|
{
|
2017-10-04 19:01:04 -04:00
|
|
|
|
|
|
|
|
|
// attackerID ; victimID ; attackerOrigin ; victimOrigin ; Damage ; Weapon ; hitLocation ; meansOfDeath
|
|
|
|
|
var minimapInfo = StatsPlugin.MinimapConfig.IW4Minimaps().MapInfo.FirstOrDefault(m => m.MapName == S.CurrentMap.Name);
|
|
|
|
|
if (minimapInfo == null)
|
|
|
|
|
return;
|
|
|
|
|
eventLine = new string[]
|
|
|
|
|
{
|
2017-09-29 22:42:24 -04:00
|
|
|
|
"ScriptKill",
|
2018-02-10 23:33:42 -05:00
|
|
|
|
attackerPlayer.NetworkId.ToString(),
|
|
|
|
|
victimPlayer.NetworkId.ToString(),
|
2017-10-03 19:17:35 -04:00
|
|
|
|
new Vector3(rand.Next(minimapInfo.MaxRight, minimapInfo.MaxLeft), rand.Next(minimapInfo.MaxBottom, minimapInfo.MaxTop), rand.Next(0, 100)).ToString(),
|
|
|
|
|
new Vector3(rand.Next(minimapInfo.MaxRight, minimapInfo.MaxLeft), rand.Next(minimapInfo.MaxBottom, minimapInfo.MaxTop), rand.Next(0, 100)).ToString(),
|
2017-09-29 22:42:24 -04:00
|
|
|
|
rand.Next(50, 105).ToString(),
|
|
|
|
|
((StatsPlugin.IW4Info.WeaponName)rand.Next(0, Enum.GetValues(typeof(StatsPlugin.IW4Info.WeaponName)).Length - 1)).ToString(),
|
|
|
|
|
((StatsPlugin.IW4Info.HitLocation)rand.Next(0, Enum.GetValues(typeof(StatsPlugin.IW4Info.HitLocation)).Length - 1)).ToString(),
|
|
|
|
|
((StatsPlugin.IW4Info.MeansOfDeath)rand.Next(0, Enum.GetValues(typeof(StatsPlugin.IW4Info.MeansOfDeath)).Length - 1)).ToString()
|
2017-10-04 19:01:04 -04:00
|
|
|
|
};
|
2017-09-29 22:42:24 -04:00
|
|
|
|
|
2017-10-04 19:01:04 -04:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
eventLine = new string[]
|
|
|
|
|
{
|
2017-09-29 22:42:24 -04:00
|
|
|
|
"K",
|
2018-02-10 23:33:42 -05:00
|
|
|
|
victimPlayer.NetworkId.ToString(),
|
2017-11-25 20:29:58 -05:00
|
|
|
|
victimPlayer.ClientNumber.ToString(),
|
2017-09-29 22:42:24 -04:00
|
|
|
|
rand.Next(0, 1) == 0 ? "allies" : "axis",
|
|
|
|
|
victimPlayer.Name,
|
2018-02-10 23:33:42 -05:00
|
|
|
|
attackerPlayer.NetworkId.ToString(),
|
2017-11-25 20:29:58 -05:00
|
|
|
|
attackerPlayer.ClientNumber.ToString(),
|
2017-09-29 22:42:24 -04:00
|
|
|
|
rand.Next(0, 1) == 0 ? "allies" : "axis",
|
|
|
|
|
attackerPlayer.Name.ToString(),
|
|
|
|
|
((StatsPlugin.IW4Info.WeaponName)rand.Next(0, Enum.GetValues(typeof(StatsPlugin.IW4Info.WeaponName)).Length - 1)).ToString(), // Weapon
|
2017-10-03 19:17:35 -04:00
|
|
|
|
rand.Next(50, 105).ToString(), // Damage
|
2017-09-29 22:42:24 -04:00
|
|
|
|
((StatsPlugin.IW4Info.MeansOfDeath)rand.Next(0, Enum.GetValues(typeof(StatsPlugin.IW4Info.MeansOfDeath)).Length - 1)).ToString(), // Means of Death
|
|
|
|
|
((StatsPlugin.IW4Info.HitLocation)rand.Next(0, Enum.GetValues(typeof(StatsPlugin.IW4Info.HitLocation)).Length - 1)).ToString(), // Hit Location
|
2017-10-04 19:01:04 -04:00
|
|
|
|
};
|
|
|
|
|
}
|
2017-09-29 22:42:24 -04:00
|
|
|
|
|
2017-10-04 19:01:04 -04:00
|
|
|
|
var _event = Event.ParseEventString(eventLine, S);
|
|
|
|
|
await S.ExecuteEvent(_event);
|
|
|
|
|
}
|
2018-02-07 00:19:06 -05:00
|
|
|
|
}
|
2017-09-27 16:07:43 -04:00
|
|
|
|
}
|
2018-04-19 18:52:48 -04:00
|
|
|
|
*/
|
2017-09-27 16:07:43 -04:00
|
|
|
|
}
|
|
|
|
|
|
2018-04-19 18:52:48 -04:00
|
|
|
|
public Task OnUnloadAsync() => Task.CompletedTask;
|
2017-09-27 16:07:43 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|