make sure flags are excluded from active penalties on player profile
modify how flags "expire"
This commit is contained in:
parent
421e90cf70
commit
16d2ec82b8
@ -266,11 +266,18 @@ namespace IW4MAdmin
|
|||||||
|
|
||||||
else if (E.Type == GameEvent.EventType.Flag)
|
else if (E.Type == GameEvent.EventType.Flag)
|
||||||
{
|
{
|
||||||
|
DateTime? expires = null;
|
||||||
|
|
||||||
|
if (E.Extra is TimeSpan ts)
|
||||||
|
{
|
||||||
|
expires = DateTime.UtcNow + ts;
|
||||||
|
}
|
||||||
|
|
||||||
// todo: maybe move this to a seperate function
|
// todo: maybe move this to a seperate function
|
||||||
var newPenalty = new EFPenalty()
|
var newPenalty = new EFPenalty()
|
||||||
{
|
{
|
||||||
Type = EFPenalty.PenaltyType.Flag,
|
Type = EFPenalty.PenaltyType.Flag,
|
||||||
Expires = DateTime.UtcNow,
|
Expires = expires,
|
||||||
Offender = E.Target,
|
Offender = E.Target,
|
||||||
Offense = E.Data,
|
Offense = E.Data,
|
||||||
Punisher = E.Origin,
|
Punisher = E.Origin,
|
||||||
|
@ -205,7 +205,7 @@ namespace IW4MAdmin.Plugins.Stats.Cheat
|
|||||||
var lifeTimeHits = ClientStats.HitLocations.Sum(_loc => _loc.HitCount);
|
var lifeTimeHits = ClientStats.HitLocations.Sum(_loc => _loc.HitCount);
|
||||||
ClientStats.AverageRecoilOffset = (ClientStats.AverageRecoilOffset * (lifeTimeHits - 1) + hitRecoilAverage) / lifeTimeHits;
|
ClientStats.AverageRecoilOffset = (ClientStats.AverageRecoilOffset * (lifeTimeHits - 1) + hitRecoilAverage) / lifeTimeHits;
|
||||||
|
|
||||||
if (sessionAverageRecoilAmount == 0 && HitCount > Thresholds.LowSampleMinKills)
|
if (sessionAverageRecoilAmount == 0 && HitCount >= Thresholds.LowSampleMinKills)
|
||||||
{
|
{
|
||||||
results.Add(new DetectionPenaltyResult()
|
results.Add(new DetectionPenaltyResult()
|
||||||
{
|
{
|
||||||
|
@ -650,7 +650,7 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
|
|||||||
$"{penalty.Type}-{(int)penalty.Location}-{Math.Round(penalty.Value, 2)}@{penalty.HitCount}" :
|
$"{penalty.Type}-{(int)penalty.Location}-{Math.Round(penalty.Value, 2)}@{penalty.HitCount}" :
|
||||||
$"{penalty.Type}-{Math.Round(penalty.Value, 2)}@{penalty.HitCount}";
|
$"{penalty.Type}-{Math.Round(penalty.Value, 2)}@{penalty.HitCount}";
|
||||||
|
|
||||||
await attacker.Flag(flagReason, penaltyClient).WaitAsync(Utilities.DefaultCommandTimeout, attacker.CurrentServer.Manager.CancellationToken);
|
await attacker.Flag(flagReason, penaltyClient, new TimeSpan(168, 0, 0)).WaitAsync(Utilities.DefaultCommandTimeout, attacker.CurrentServer.Manager.CancellationToken);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -232,7 +232,7 @@ namespace SharedLibraryCore.Database.Models
|
|||||||
/// <param name="flagReason">reason for flagging</param>
|
/// <param name="flagReason">reason for flagging</param>
|
||||||
/// <param name="sender">client performing the flag</param>
|
/// <param name="sender">client performing the flag</param>
|
||||||
/// <returns>game event for the flag</returns>
|
/// <returns>game event for the flag</returns>
|
||||||
public GameEvent Flag(string flagReason, EFClient sender)
|
public GameEvent Flag(string flagReason, EFClient sender, TimeSpan? flagLength = null)
|
||||||
{
|
{
|
||||||
var e = new GameEvent()
|
var e = new GameEvent()
|
||||||
{
|
{
|
||||||
@ -240,6 +240,7 @@ namespace SharedLibraryCore.Database.Models
|
|||||||
Origin = sender,
|
Origin = sender,
|
||||||
Data = flagReason,
|
Data = flagReason,
|
||||||
Message = flagReason,
|
Message = flagReason,
|
||||||
|
Extra = flagLength,
|
||||||
Target = this,
|
Target = this,
|
||||||
Owner = sender.CurrentServer
|
Owner = sender.CurrentServer
|
||||||
};
|
};
|
||||||
@ -667,21 +668,15 @@ namespace SharedLibraryCore.Database.Models
|
|||||||
if (currentFlag != null)
|
if (currentFlag != null)
|
||||||
{
|
{
|
||||||
CurrentServer.Logger.WriteDebug($"Flagging {this} because their AliasLink is flagged, but they are not");
|
CurrentServer.Logger.WriteDebug($"Flagging {this} because their AliasLink is flagged, but they are not");
|
||||||
Flag(currentFlag.Offense, autoKickClient);
|
Flag(currentFlag.Offense, autoKickClient, currentFlag.Expires - DateTime.UtcNow);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
if (Level == Permission.Flagged)
|
if (Level == Permission.Flagged)
|
||||||
{
|
{
|
||||||
var currentAutoFlag = activePenalties
|
|
||||||
.Where(p => p.Type == EFPenalty.PenaltyType.Flag && p.PunisherId == 1)
|
|
||||||
.OrderByDescending(p => p.When)
|
|
||||||
.FirstOrDefault();
|
|
||||||
|
|
||||||
// remove their auto flag status after a week
|
// remove their auto flag status after a week
|
||||||
if (currentAutoFlag != null &&
|
if (!activePenalties.Any(_penalty => _penalty.Type == EFPenalty.PenaltyType.Flag))
|
||||||
(DateTime.UtcNow - currentAutoFlag.When).TotalDays > 7)
|
|
||||||
{
|
{
|
||||||
CurrentServer.Logger.WriteInfo($"Unflagging {this} because the auto flag time has expired");
|
CurrentServer.Logger.WriteInfo($"Unflagging {this} because the auto flag time has expired");
|
||||||
Unflag(Utilities.CurrentLocalization.LocalizationIndex["SERVER_AUTOFLAG_UNFLAG"], autoKickClient);
|
Unflag(Utilities.CurrentLocalization.LocalizationIndex["SERVER_AUTOFLAG_UNFLAG"], autoKickClient);
|
||||||
|
@ -175,11 +175,11 @@ namespace SharedLibraryCore.Services
|
|||||||
Expression<Func<EFPenalty, bool>> filter = (p) => (new EFPenalty.PenaltyType[]
|
Expression<Func<EFPenalty, bool>> filter = (p) => (new EFPenalty.PenaltyType[]
|
||||||
{
|
{
|
||||||
EFPenalty.PenaltyType.TempBan,
|
EFPenalty.PenaltyType.TempBan,
|
||||||
EFPenalty.PenaltyType.Ban
|
EFPenalty.PenaltyType.Ban,
|
||||||
|
EFPenalty.PenaltyType.Flag
|
||||||
}.Contains(p.Type) &&
|
}.Contains(p.Type) &&
|
||||||
p.Active &&
|
p.Active &&
|
||||||
(p.Expires == null || p.Expires > now)) ||
|
(p.Expires == null || p.Expires > now));
|
||||||
(p.Type ==EFPenalty.PenaltyType.Flag && p.Active);
|
|
||||||
|
|
||||||
using (var context = new DatabaseContext(true))
|
using (var context = new DatabaseContext(true))
|
||||||
{
|
{
|
||||||
|
@ -22,7 +22,8 @@ namespace WebfrontCore.Controllers
|
|||||||
return NotFound();
|
return NotFound();
|
||||||
}
|
}
|
||||||
|
|
||||||
var activePenalties = await Manager.GetPenaltyService().GetActivePenaltiesAsync(client.AliasLinkId, client.IPAddress);
|
var activePenalties = (await Manager.GetPenaltyService().GetActivePenaltiesAsync(client.AliasLinkId, client.IPAddress))
|
||||||
|
.Where(_penalty => _penalty.Type != PenaltyType.Flag);
|
||||||
|
|
||||||
var clientDto = new PlayerInfo()
|
var clientDto = new PlayerInfo()
|
||||||
{
|
{
|
||||||
@ -46,8 +47,8 @@ namespace WebfrontCore.Controllers
|
|||||||
.Distinct()
|
.Distinct()
|
||||||
.OrderBy(i => i)
|
.OrderBy(i => i)
|
||||||
.ToList(),
|
.ToList(),
|
||||||
HasActivePenalty = activePenalties.Count > 0,
|
HasActivePenalty = activePenalties.Count() > 0,
|
||||||
ActivePenaltyType = activePenalties.Count > 0 ? activePenalties.First().Type.ToString() : null,
|
ActivePenaltyType = activePenalties.Count() > 0 ? activePenalties.First().Type.ToString() : null,
|
||||||
Online = Manager.GetActiveClients().FirstOrDefault(c => c.ClientId == client.ClientId) != null,
|
Online = Manager.GetActiveClients().FirstOrDefault(c => c.ClientId == client.ClientId) != null,
|
||||||
TimeOnline = (DateTime.UtcNow - client.LastConnection).TimeSpanText(),
|
TimeOnline = (DateTime.UtcNow - client.LastConnection).TimeSpanText(),
|
||||||
LinkedAccounts = client.LinkedAccounts
|
LinkedAccounts = client.LinkedAccounts
|
||||||
|
Loading…
Reference in New Issue
Block a user