Fixed FastRestart invalid dvar exception
Fixed decodeURI issue in messageboard Removed debug message in stats plugin
This commit is contained in:
parent
d8b19f289a
commit
0bdec1147b
@ -191,7 +191,6 @@ namespace IW4MAdmin
|
|||||||
|
|
||||||
public void Start()
|
public void Start()
|
||||||
{
|
{
|
||||||
var a = Utilities.DateTimeSQLite(DateTime.MinValue);
|
|
||||||
while (Running)
|
while (Running)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < TaskStatuses.Count; i++)
|
for (int i = 0; i < TaskStatuses.Count; i++)
|
||||||
|
Binary file not shown.
@ -40,6 +40,7 @@ namespace Plugin
|
|||||||
{
|
{
|
||||||
bool MatchEnded;
|
bool MatchEnded;
|
||||||
DateTime MatchEndTime;
|
DateTime MatchEndTime;
|
||||||
|
Dictionary<int, int> FastRestarts;
|
||||||
|
|
||||||
public static ConfigurationManager ConfigManager { get; private set; }
|
public static ConfigurationManager ConfigManager { get; private set; }
|
||||||
|
|
||||||
@ -57,6 +58,8 @@ namespace Plugin
|
|||||||
if (ConfigManager.GetConfiguration(S).Keys.Count == 0)
|
if (ConfigManager.GetConfiguration(S).Keys.Count == 0)
|
||||||
ConfigManager.AddProperty(S, new KeyValuePair<string, object>("Enabled", false));
|
ConfigManager.AddProperty(S, new KeyValuePair<string, object>("Enabled", false));
|
||||||
|
|
||||||
|
FastRestarts.Add(S.GetHashCode(), 0);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await S.GetDvarAsync<int>("scr_intermission_time");
|
await S.GetDvarAsync<int>("scr_intermission_time");
|
||||||
@ -64,14 +67,15 @@ namespace Plugin
|
|||||||
|
|
||||||
catch (SharedLibrary.Exceptions.DvarException)
|
catch (SharedLibrary.Exceptions.DvarException)
|
||||||
{
|
{
|
||||||
await S.SetDvarAsync("scr_intermission_time", 20);
|
await S.ExecuteCommandAsync("set src_intermission_time 20");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task OnLoadAsync()
|
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)
|
public async Task OnTickAsync(Server S)
|
||||||
@ -84,10 +88,34 @@ namespace Plugin
|
|||||||
if (MatchEnded && MatchEndTime == DateTime.MinValue)
|
if (MatchEnded && MatchEndTime == DateTime.MinValue)
|
||||||
MatchEndTime = DateTime.Now;
|
MatchEndTime = DateTime.Now;
|
||||||
|
|
||||||
// I'm pretty sure the timelength from game ended to scoreboard popup is 2000ms
|
int intermissionTime = 20;
|
||||||
if (MatchEnded && (DateTime.Now - MatchEndTime).TotalSeconds >= ((await S.GetDvarAsync<int>("scr_intermission_time")).Value - 2))
|
|
||||||
|
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;
|
MatchEndTime = DateTime.MinValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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> » ' + decodeURIComponent(Response.Thread.title));
|
$('#textNav').append('<a class="themeBlue" href="category?id=' + Response.Thread.threadCategory.id + '">' + Response.Thread.threadCategory.title + '</a> » ' + decodeURIComponent(Response.Thread.title));
|
||||||
$('.threadStart .userTitle').html(Response.Thread.author.username);
|
$('.threadStart .userTitle').html(Response.Thread.author.username);
|
||||||
$('.threadStart .timePosted').html(getDate(Response.Thread.creationDate));
|
$('.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 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 != "")
|
if (Response.Thread.author.avatarURL != "")
|
||||||
$('.threadStart .userAvatar').html("").attr("style", "background-image:url('" + Response.Thread.author.avatarURL + "');'");
|
$('.threadStart .userAvatar').html("").attr("style", "background-image:url('" + Response.Thread.author.avatarURL + "');'");
|
||||||
$('#replyThreadButton').attr("href", "postthread?threadid=" + Response.Thread.id);
|
$('#replyThreadButton').attr("href", "postthread?threadid=" + Response.Thread.id);
|
||||||
|
@ -248,6 +248,7 @@ namespace StatsPlugin
|
|||||||
ResetCounters(E.Origin.ClientID, S.GetPort());
|
ResetCounters(E.Origin.ClientID, S.GetPort());
|
||||||
|
|
||||||
PlayerStats checkForTrusted = statLists.Find(x => x.Port == S.GetPort()).playerStats.GetStats(E.Origin);
|
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)
|
if (checkForTrusted.TotalPlayTime >= 4320 && E.Origin.Level < Player.Permission.Trusted)
|
||||||
{
|
{
|
||||||
E.Origin.SetLevel(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()));
|
CalculateAndSaveSkill(E.Origin, statLists.Find(x => x.Port == S.GetPort()));
|
||||||
ResetCounters(E.Origin.ClientID, 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)
|
if (E.Type == Event.GType.Kill)
|
||||||
@ -292,13 +293,7 @@ namespace StatsPlugin
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
string[] killInfo = E.Data.Split(';');
|
string[] killInfo = E.Data.Split(';');
|
||||||
|
if (killInfo.Length >= 9 && killInfo[0].Contains("ScriptKill"))
|
||||||
Player Killer = E.Origin;
|
|
||||||
StatTracking curServer = statLists.Find(x => x.Port == S.GetPort());
|
|
||||||
PlayerStats killerStats = curServer.playerStats.GetStats(Killer);
|
|
||||||
|
|
||||||
|
|
||||||
if (killInfo.Length >= 9)
|
|
||||||
{
|
{
|
||||||
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])
|
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().Dequeue();
|
||||||
ServerStats[S.GetPort()].GetKillQueue().Enqueue(killEvent);
|
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}");
|
//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);
|
var cs= statLists.Find(x => x.Port == S.GetPort());
|
||||||
S.Logger.WriteInfo(killEvent.ID.ToString());
|
cs.playerStats.AddKill(killEvent);
|
||||||
return;
|
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.lastKill[E.Origin.ClientID] = DateTime.Now;
|
||||||
curServer.Kills[E.Origin.ClientID]++;
|
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);
|
killerStats.KDR = (killerStats.Deaths == 0) ? killerStats.Kills : killerStats.KDR = Math.Round((double)killerStats.Kills / (double)killerStats.Deaths, 2);
|
||||||
|
|
||||||
|
|
||||||
curServer.playerStats.UpdateStats(Killer, killerStats);
|
curServer.playerStats.UpdateStats(Killer, killerStats);
|
||||||
|
|
||||||
curServer.killStreaks[Killer.ClientID] += 1;
|
curServer.killStreaks[Killer.ClientID] += 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user