Fixed FastRestart invalid dvar exception

Fixed decodeURI issue in messageboard
Removed debug message in stats plugin
This commit is contained in:
RaidMax 2017-10-11 16:49:02 -05:00
parent d8b19f289a
commit 0bdec1147b
5 changed files with 44 additions and 19 deletions

View File

@ -191,7 +191,6 @@ namespace IW4MAdmin
public void Start()
{
var a = Utilities.DateTimeSQLite(DateTime.MinValue);
while (Running)
{
for (int i = 0; i < TaskStatuses.Count; i++)

Binary file not shown.

View File

@ -40,6 +40,7 @@ namespace Plugin
{
bool MatchEnded;
DateTime MatchEndTime;
Dictionary<int, int> FastRestarts;
public static ConfigurationManager ConfigManager { get; private set; }
@ -57,6 +58,8 @@ namespace Plugin
if (ConfigManager.GetConfiguration(S).Keys.Count == 0)
ConfigManager.AddProperty(S, new KeyValuePair<string, object>("Enabled", false));
FastRestarts.Add(S.GetHashCode(), 0);
try
{
await S.GetDvarAsync<int>("scr_intermission_time");
@ -64,14 +67,15 @@ namespace Plugin
catch (SharedLibrary.Exceptions.DvarException)
{
await S.SetDvarAsync("scr_intermission_time", 20);
await S.ExecuteCommandAsync("set src_intermission_time 20");
}
}
}
public async Task OnLoadAsync()
{
ConfigManager = new ConfigurationManager(typeof(FastRestartPlugin));
ConfigManager = new ConfigurationManager(typeof(FastRestartPlugin));
FastRestarts = new Dictionary<int, int>();
}
public async Task OnTickAsync(Server S)
@ -84,10 +88,34 @@ namespace Plugin
if (MatchEnded && MatchEndTime == DateTime.MinValue)
MatchEndTime = DateTime.Now;
// I'm pretty sure the timelength from game ended to scoreboard popup is 2000ms
if (MatchEnded && (DateTime.Now - MatchEndTime).TotalSeconds >= ((await S.GetDvarAsync<int>("scr_intermission_time")).Value - 2))
int intermissionTime = 20;
try
{
await S.ExecuteCommandAsync("fast_restart");
var intermissionTimeDvar = await S.GetDvarAsync<int>("scr_intermission_time");
intermissionTime = intermissionTimeDvar.Value;
}
catch(SharedLibrary.Exceptions.DvarException)
{
await S.SetDvarAsync("scr_intermission_time", 20);
}
// I'm pretty sure the timelength from game ended to scoreboard popup is 2000ms
if (MatchEnded && (DateTime.Now - MatchEndTime).TotalSeconds >= intermissionTime - 2)
{
if (FastRestarts[S.GetHashCode()] >= 8)
{
await S.ExecuteCommandAsync("map_restart");
FastRestarts[S.GetHashCode()] = 0;
}
else
{
await S.ExecuteCommandAsync("fast_restart");
FastRestarts[S.GetHashCode()] = FastRestarts[S.GetHashCode()] + 1;
}
MatchEndTime = DateTime.MinValue;
}
}

View File

@ -52,9 +52,9 @@ $.getJSON("_thread?id=" + parseGet('id'), function(Response) {
$('#textNav').append('<a class="themeBlue" href="category?id=' + Response.Thread.threadCategory.id + '">' + Response.Thread.threadCategory.title + '</a> &raquo; ' + decodeURIComponent(Response.Thread.title));
$('.threadStart .userTitle').html(Response.Thread.author.username);
$('.threadStart .timePosted').html(getDate(Response.Thread.creationDate));
$('.threadStart .threadTitle').html(decodeURIComponent(Response.Thread.title));
$('.threadStart .threadTitle').html(Response.Thread.title);
$('.threadStart a.userProfileLink').attr("href", "user?id=" + Response.Thread.author.id);
$('.threadStart .threadContent').html(decodeURIComponent(Response.Thread.formattedContent));
$('.threadStart .threadContent').html(Response.Thread.formattedContent);
if (Response.Thread.author.avatarURL != "")
$('.threadStart .userAvatar').html("").attr("style", "background-image:url('" + Response.Thread.author.avatarURL + "');'");
$('#replyThreadButton').attr("href", "postthread?threadid=" + Response.Thread.id);

View File

@ -248,6 +248,7 @@ namespace StatsPlugin
ResetCounters(E.Origin.ClientID, S.GetPort());
PlayerStats checkForTrusted = statLists.Find(x => x.Port == S.GetPort()).playerStats.GetStats(E.Origin);
//todo: move this out of here!!
if (checkForTrusted.TotalPlayTime >= 4320 && E.Origin.Level < Player.Permission.Trusted)
{
E.Origin.SetLevel(Player.Permission.Trusted);
@ -283,7 +284,7 @@ namespace StatsPlugin
{
CalculateAndSaveSkill(E.Origin, statLists.Find(x => x.Port == S.GetPort()));
ResetCounters(E.Origin.ClientID, S.GetPort());
E.Owner.Logger.WriteInfo("Updated skill for disconnecting client #" + E.Origin.DatabaseID);
E.Owner.Logger.WriteInfo($"Updated skill for disconnecting client {E.Origin}");
}
if (E.Type == Event.GType.Kill)
@ -292,13 +293,7 @@ namespace StatsPlugin
return;
string[] killInfo = E.Data.Split(';');
Player Killer = E.Origin;
StatTracking curServer = statLists.Find(x => x.Port == S.GetPort());
PlayerStats killerStats = curServer.playerStats.GetStats(Killer);
if (killInfo.Length >= 9)
if (killInfo.Length >= 9 && killInfo[0].Contains("ScriptKill"))
{
var killEvent = new KillInfo(E.Origin.DatabaseID, E.Target.DatabaseID, S.CurrentMap.Name, killInfo[7], killInfo[8], killInfo[5], killInfo[6], killInfo[3], killInfo[4])
{
@ -310,11 +305,15 @@ namespace StatsPlugin
ServerStats[S.GetPort()].GetKillQueue().Dequeue();
ServerStats[S.GetPort()].GetKillQueue().Enqueue(killEvent);
//S.Logger.WriteInfo($"{E.Origin.Name} killed {E.Target.Name} with a {killEvent.Weapon} from a distance of {Vector3.Distance(killEvent.KillOrigin, killEvent.DeathOrigin)} with {killEvent.Damage} damage, at {killEvent.HitLoc}");
curServer.playerStats.AddKill(killEvent);
S.Logger.WriteInfo(killEvent.ID.ToString());
var cs= statLists.Find(x => x.Port == S.GetPort());
cs.playerStats.AddKill(killEvent);
return;
}
Player Killer = E.Origin;
StatTracking curServer = statLists.Find(x => x.Port == S.GetPort());
PlayerStats killerStats = curServer.playerStats.GetStats(Killer);
curServer.lastKill[E.Origin.ClientID] = DateTime.Now;
curServer.Kills[E.Origin.ClientID]++;
@ -325,7 +324,6 @@ namespace StatsPlugin
killerStats.KDR = (killerStats.Deaths == 0) ? killerStats.Kills : killerStats.KDR = Math.Round((double)killerStats.Kills / (double)killerStats.Deaths, 2);
curServer.playerStats.UpdateStats(Killer, killerStats);
curServer.killStreaks[Killer.ClientID] += 1;