mirror of
https://github.com/RaidMax/IW4M-Admin.git
synced 2025-06-11 15:52:25 -05:00
moved event API stuff around
finally fixed threading issue (which actually had to do with IW4x log outputs being out of sync (not an issue with my code). What a lot of headache over something that wasn't my fault.
This commit is contained in:
@ -10,7 +10,7 @@ const plugin = {
|
||||
checkForVpn(origin) {
|
||||
let exempt = false;
|
||||
// prevent players that are exempt from being kicked
|
||||
this.vpnExceptionIds.forEach(function(id) {
|
||||
this.vpnExceptionIds.forEach(function (id) {
|
||||
if (id === origin.ClientId) {
|
||||
exempt = true;
|
||||
return false;
|
||||
@ -48,7 +48,7 @@ const plugin = {
|
||||
onEventAsync(gameEvent, server) {
|
||||
// connect event
|
||||
if (gameEvent.Type === 3) {
|
||||
this.checkForVpn(gameEvent.Origin)
|
||||
this.checkForVpn(gameEvent.Origin);
|
||||
}
|
||||
},
|
||||
|
||||
@ -57,7 +57,7 @@ const plugin = {
|
||||
this.logger = manager.GetLogger();
|
||||
},
|
||||
|
||||
onUnloadAsync() {},
|
||||
onUnloadAsync() { },
|
||||
|
||||
onTickAsync(server) {}
|
||||
}
|
||||
onTickAsync(server) { }
|
||||
};
|
@ -53,7 +53,7 @@ namespace IW4MAdmin.Plugins.Stats.Cheat
|
||||
if ((kill.DeathType != IW4Info.MeansOfDeath.MOD_PISTOL_BULLET &&
|
||||
kill.DeathType != IW4Info.MeansOfDeath.MOD_RIFLE_BULLET &&
|
||||
kill.DeathType != IW4Info.MeansOfDeath.MOD_HEAD_SHOT) ||
|
||||
kill.HitLoc == IW4Info.HitLocation.none)
|
||||
kill.HitLoc == IW4Info.HitLocation.none || kill.TimeOffset - LastOffset < 0)
|
||||
return new DetectionPenaltyResult()
|
||||
{
|
||||
ClientPenalty = Penalty.PenaltyType.Any,
|
||||
@ -131,7 +131,6 @@ namespace IW4MAdmin.Plugins.Stats.Cheat
|
||||
}
|
||||
|
||||
double currentStrain = Strain.GetStrain(isDamage, kill.Damage, kill.Distance / 0.0254, kill.ViewAngles, Math.Max(50, kill.TimeOffset - LastOffset));
|
||||
//double currentWeightedStrain = (currentStrain * ClientStats.SPM) / 170.0;
|
||||
LastOffset = kill.TimeOffset;
|
||||
|
||||
if (currentStrain > ClientStats.MaxStrain)
|
||||
|
@ -470,6 +470,9 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
|
||||
Owner = attacker.CurrentServer,
|
||||
Type = GameEvent.EventType.Flag
|
||||
};
|
||||
// because we created an event it must be processed by the manager
|
||||
// even if it didn't really do anything
|
||||
Manager.GetEventHandler().AddEvent(e);
|
||||
await new CFlag().ExecuteAsync(e);
|
||||
break;
|
||||
}
|
||||
@ -834,9 +837,9 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
|
||||
// calculate how much the KDR should weigh
|
||||
// 1.637 is a Eddie-Generated number that weights the KDR nicely
|
||||
double currentKDR = clientStats.SessionDeaths == 0 ? clientStats.SessionKills : clientStats.SessionKills / clientStats.SessionDeaths;
|
||||
double alpha = Math.Sqrt(2) / Math.Min(600, clientStats.Kills + clientStats.Deaths);
|
||||
double alpha = Math.Sqrt(2) / Math.Min(600, Math.Max(clientStats.Kills + clientStats.Deaths, 1));
|
||||
clientStats.RollingWeightedKDR = (alpha * currentKDR) + (1.0 - alpha) * clientStats.KDR;
|
||||
double KDRWeight = clientStats.RollingWeightedKDR != 0 ? Math.Round(Math.Pow(clientStats.RollingWeightedKDR, 1.637 / Math.E), 3) : 0;
|
||||
double KDRWeight = Math.Round(Math.Pow(clientStats.RollingWeightedKDR, 1.637 / Math.E), 3);
|
||||
|
||||
// calculate the weight of the new play time against last 10 hours of gameplay
|
||||
int totalPlayTime = (clientStats.TimePlayed == 0) ?
|
||||
|
@ -76,8 +76,12 @@ namespace IW4MAdmin.Plugins.Stats
|
||||
case GameEvent.EventType.ScriptKill:
|
||||
string[] killInfo = (E.Data != null) ? E.Data.Split(';') : new string[0];
|
||||
if (killInfo.Length >= 13)
|
||||
{
|
||||
// todo: remove me
|
||||
E.Owner.Logger.WriteDebug($"Starting Add script hit (kill) for event with id {E.Id}");
|
||||
await Manager.AddScriptHit(false, E.Time, E.Origin, E.Target, S.GetHashCode(), S.CurrentMap.Name, killInfo[7], killInfo[8],
|
||||
killInfo[5], killInfo[6], killInfo[3], killInfo[4], killInfo[9], killInfo[10], killInfo[11], killInfo[12], killInfo[13]);
|
||||
}
|
||||
break;
|
||||
case GameEvent.EventType.Kill:
|
||||
if (!E.Owner.CustomCallback)
|
||||
@ -90,8 +94,12 @@ namespace IW4MAdmin.Plugins.Stats
|
||||
case GameEvent.EventType.ScriptDamage:
|
||||
killInfo = (E.Data != null) ? E.Data.Split(';') : new string[0];
|
||||
if (killInfo.Length >= 13)
|
||||
{
|
||||
// todo: remove me
|
||||
E.Owner.Logger.WriteDebug($"Starting Add script hit (damage) for event with id {E.Id}");
|
||||
await Manager.AddScriptHit(true, E.Time, E.Origin, E.Target, S.GetHashCode(), S.CurrentMap.Name, killInfo[7], killInfo[8],
|
||||
killInfo[5], killInfo[6], killInfo[3], killInfo[4], killInfo[9], killInfo[10], killInfo[11], killInfo[12], killInfo[13]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ namespace Tests
|
||||
public void AddAndRemoveClientsViaJoinShouldSucceed()
|
||||
{
|
||||
var server = Manager.GetServers().First();
|
||||
var waiters = new Queue<ManualResetEventSlim>();
|
||||
var waiters = new Queue<SemaphoreSlim>();
|
||||
|
||||
int clientStartIndex = 4;
|
||||
int clientNum = 10;
|
||||
@ -103,7 +103,7 @@ namespace Tests
|
||||
public void AddAndRemoveClientsViaRconShouldSucceed()
|
||||
{
|
||||
var server = Manager.GetServers().First();
|
||||
var waiters = new Queue<ManualResetEventSlim>();
|
||||
var waiters = new Queue<SemaphoreSlim>();
|
||||
|
||||
int clientIndexStart = 1;
|
||||
int clientNum = 8;
|
||||
@ -187,7 +187,6 @@ namespace Tests
|
||||
|
||||
|
||||
resetEvent.Wait(5000);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user