2017-09-27 16:07:43 -04:00
|
|
|
|
#if DEBUG
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using SharedLibrary;
|
|
|
|
|
using SharedLibrary.Interfaces;
|
|
|
|
|
using SharedLibrary.Helpers;
|
|
|
|
|
|
|
|
|
|
namespace IW4MAdmin.Plugins
|
|
|
|
|
{
|
|
|
|
|
public class Tests : IPlugin
|
|
|
|
|
{
|
|
|
|
|
public string Name => "Dev Tests";
|
|
|
|
|
|
|
|
|
|
public float Version => 0.1f;
|
|
|
|
|
|
|
|
|
|
public string Author => "RaidMax";
|
|
|
|
|
|
2017-09-29 22:42:24 -04:00
|
|
|
|
private DateTime Interval;
|
2017-09-27 16:07:43 -04:00
|
|
|
|
|
|
|
|
|
public async Task OnEventAsync(Event E, Server S)
|
|
|
|
|
{
|
|
|
|
|
if (E.Type == Event.GType.Start)
|
|
|
|
|
{
|
|
|
|
|
#region PLAYER_HISTORY
|
|
|
|
|
var rand = new Random(GetHashCode());
|
|
|
|
|
var time = DateTime.UtcNow;
|
|
|
|
|
|
|
|
|
|
await Task.Run(() =>
|
|
|
|
|
{
|
|
|
|
|
if (S.PlayerHistory.Count > 0)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
while (S.PlayerHistory.Count < 48)
|
|
|
|
|
{
|
|
|
|
|
S.PlayerHistory.Enqueue(new PlayerHistory(time, rand.Next(7, 18)));
|
|
|
|
|
time = time.AddMinutes(15);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task OnLoadAsync()
|
|
|
|
|
{
|
|
|
|
|
Interval = DateTime.Now;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task OnTickAsync(Server S)
|
|
|
|
|
{
|
|
|
|
|
if ((DateTime.Now - Interval).TotalSeconds > 5)
|
|
|
|
|
{
|
|
|
|
|
var rand = new Random();
|
|
|
|
|
int index = rand.Next(0, 17);
|
2017-09-29 22:42:24 -04:00
|
|
|
|
var p = new Player($"Test_{index}", $"_test{index}", index, (int)Player.Permission.User)
|
2017-09-27 16:07:43 -04:00
|
|
|
|
{
|
|
|
|
|
Ping = 1
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
p.SetIP("127.0.0.1");
|
|
|
|
|
|
|
|
|
|
if (S.Players.ElementAt(index) != null)
|
|
|
|
|
await S.RemovePlayer(index);
|
|
|
|
|
await S.AddPlayer(p);
|
|
|
|
|
|
|
|
|
|
Interval = DateTime.Now;
|
2017-09-29 22:42:24 -04:00
|
|
|
|
if (S.ClientNum > 0)
|
|
|
|
|
{
|
|
|
|
|
//"K;26d2f66b95184934;1;allies;egor;5c56fef676b3818d;0;axis;1_din;m21_heartbeat_mp;98;MOD_RIFLE_BULLET;torso_lower";
|
|
|
|
|
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)];
|
|
|
|
|
|
|
|
|
|
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",
|
|
|
|
|
attackerPlayer.NetworkID,
|
|
|
|
|
victimPlayer.NetworkID,
|
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",
|
|
|
|
|
victimPlayer.NetworkID,
|
|
|
|
|
victimPlayer.ClientID.ToString(),
|
|
|
|
|
rand.Next(0, 1) == 0 ? "allies" : "axis",
|
|
|
|
|
victimPlayer.Name,
|
|
|
|
|
attackerPlayer.NetworkID,
|
|
|
|
|
attackerPlayer.ClientID.ToString(),
|
|
|
|
|
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);
|
|
|
|
|
}
|
2017-09-29 22:42:24 -04:00
|
|
|
|
}
|
2017-09-27 16:07:43 -04:00
|
|
|
|
}
|
2017-09-29 22:42:24 -04:00
|
|
|
|
|
2017-09-27 16:07:43 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task OnUnloadAsync()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|