1
0
mirror of https://github.com/RaidMax/IW4M-Admin.git synced 2025-06-11 15:52:25 -05:00

Added high ping kick functionality to Welcome Plugin

Added response to RCON command if applicable
Added more maps into the map config
This commit is contained in:
RaidMax
2017-06-07 17:08:29 -04:00
parent bd99add434
commit 11d37d4cd6
17 changed files with 116 additions and 130 deletions

View File

@ -1,12 +1,18 @@
using System;
using SharedLibrary;
using System.Collections.Generic;
using SharedLibrary.Interfaces;
using System.Threading.Tasks;
using SharedLibrary.Network;
namespace Welcome_Plugin
{
public class Plugin : IPlugin
{
Dictionary<int, float> PlayerPings;
int PingAverageCount;
public string Author
{
get
@ -33,17 +39,33 @@ namespace Welcome_Plugin
public async Task OnLoadAsync()
{
return;
PlayerPings = new Dictionary<int, float>();
PingAverageCount = 1;
}
public async Task OnUnloadAsync()
{
return;
PlayerPings.Clear();
PlayerPings = null;
}
public async Task OnTickAsync(Server S)
{
return;
int MaxPing = (await S.GetDvarAsync<int>("sv_maxping")).Value;
if (MaxPing == 0)
return;
foreach (int PlayerID in PlayerPings.Keys)
{
var Player = S.Players.Find(p => p.DatabaseID == PlayerID);
PlayerPings[PlayerID] = PlayerPings[PlayerID] + (Player.Ping - PlayerPings[PlayerID]) / PingAverageCount;
if (PlayerPings[PlayerID] > MaxPing)
await Player.Kick($"Your average ping of ^5{PlayerPings[PlayerID]} ^7is too high for this server", null);
}
if (PingAverageCount > 100)
PingAverageCount = 1;
}
public async Task OnEventAsync(Event E, Server S)
@ -58,7 +80,7 @@ namespace Welcome_Plugin
await newPlayer.Tell($"Welcome ^5{newPlayer.Name}^7, this your ^5{newPlayer.TimesConnected()} ^7time connecting!");
if (newPlayer.Level == Player.Permission.Flagged)
await E.Owner.ToAdmins($"^1NOTICE: ^7Flagged player ^5{newPlayer.Name}^7 has joined!");
await E.Owner.ToAdmins($"^1NOTICE: ^7Flagged player ^5{newPlayer.Name}^7 has joined!");
else
{
@ -72,8 +94,15 @@ namespace Welcome_Plugin
{
E.Owner.Manager.GetLogger().WriteError("Could not open file Plugins/GeoIP.dat for Welcome Plugin");
}
}
PlayerPings.Add(E.Origin.DatabaseID, 1.0f);
}
if (E.Type == Event.GType.Disconnect)
{
PlayerPings.Remove(E.Origin.DatabaseID);
}
}
}