[K Relay] 059's AntiLag updated

All credits to 059 for AntiLag. Credits to Kronks and all the contibutors for K Relay.
If you still haven't updated to latest version of K Relay, now is a great time to do so. I've included a separate download for the newest version of K Relay, compiled and ready for use. This download also includes AntiLag.
If there are still any plugins that haven't been updated, you may request for updating them in this thread. Please include a link to the original post in your request.
If you're switching versions, you might need to redownload einaras' Enter Full Realms plugin.
AntiLag
Code:
using Lib_K_Relay;
using Lib_K_Relay.Interface;
using Lib_K_Relay.Networking;
using Lib_K_Relay.Networking.Packets;
using Lib_K_Relay.Networking.Packets.Server;
namespace AntiLag
{
public class AntiLag : IPlugin
{
public string GetAuthor()
{
return "059";
}
public string GetName()
{
return "AntiLag";
}
public string GetDescription()
{
return "Blocks certain packets which contribute significantly to lagging your client.";
}
public string[] GetCommands()
{
return new string[0];
}
public void Initialize(Proxy proxy)
{
proxy.HookPacket(PacketType.SHOWEFFECT, OnShowEffect);
proxy.HookPacket(PacketType.ALLYSHOOT, OnAllyShoot);
proxy.HookPacket(PacketType.DAMAGE, OnDamage);
}
private void OnShowEffect(Client client, Packet packet)
{
ShowEffectPacket sep = (ShowEffectPacket)packet;
switch ((int)sep.EffectType)
{
case 5:
if (sep.TargetId != client.ObjectId)
packet.Send = false;
break;
case 1:
case 2:
case 6:
case 7:
case 8:
case 9:
case 10:
case 12:
case 17:
case 18:
case 19:
packet.Send = false;
break;
}
}
private void OnAllyShoot(Client client, Packet packet)
{
packet.Send = false;
}
private void OnDamage(Client client, Packet packet)
{
DamagePacket dp = (DamagePacket)packet;
if (dp.ObjectId != client.ObjectId)
packet.Send = false;
}
}
}
Edit: People didn't seem too thrilled about me removing all the commands so I created a second version with commands for toggling everything.
AntiLag v2
Code:
using Lib_K_Relay;
using Lib_K_Relay.Interface;
using Lib_K_Relay.Utilities;
using Lib_K_Relay.Networking;
using Lib_K_Relay.Networking.Packets;
using Lib_K_Relay.Networking.Packets.Server;
namespace AntiLag
{
public class AntiLag : IPlugin
{
private bool[] active = { true, true, true};
public string GetAuthor()
{
return "059";
}
public string GetName()
{
return "AntiLag";
}
public string GetDescription()
{
return "Blocks certain packets which contribute significantly to lagging your client.\n\n/al ally toggles allied projectiles\n/al damage toggles the damage display on allies\n/al particle toggles particle effects succh as necromancer skull\n/al toggles them all";
}
public string[] GetCommands()
{
return new string[]
{
"/al <ally:damage:particle>"
};
}
public void Initialize(Proxy proxy)
{
proxy.HookPacket(PacketType.SHOWEFFECT, OnShowEffect);
proxy.HookPacket(PacketType.ALLYSHOOT, OnAllyShoot);
proxy.HookPacket(PacketType.DAMAGE, OnDamage);
proxy.HookCommand("al", OnCommand);
}
private void OnCommand(Client client, string command, string[] args)
{
if (args.Length == 0)
{
active[0] = !active[0];
active[1] = !active[1];
active[2] = !active[2];
}
else if (args[0] == "ally")
active[0] = !active[0];
else if (args[0] == "damage")
active[1] = !active[1];
else if (args[0] == "particle")
active[2] = !active[2];
string msg = "Allied Projectiles: " + active[0].ToString() + ", Damage Display: " + active[1].ToString() +", Particle Effects: " + active[2].ToString();
client.SendToClient(PluginUtils.CreateOryxNotification("AntiLag", msg));
}
private void OnShowEffect(Client client, Packet packet)
{
if (active[2])
{
ShowEffectPacket sep = (ShowEffectPacket)packet;
switch ((int)sep.EffectType)
{
case 5:
if (sep.TargetId != client.ObjectId)
packet.Send = false;
break;
case 1:
case 2:
case 6:
case 7:
case 8:
case 9:
case 10:
case 12:
case 17:
case 18:
case 19:
packet.Send = false;
break;
}
}
}
private void OnAllyShoot(Client client, Packet packet)
{
if (active[0])
packet.Send = false;
}
private void OnDamage(Client client, Packet packet)
{
if (active[1])
{
DamagePacket dp = (DamagePacket)packet;
if (dp.ObjectId != client.ObjectId)
packet.Send = false;
}
}
}
}
Virus scans:
Jotti 0/19
Virustotal 0/56
Jotti 0/19
Virustotal 0/56
Jotti 0/19
Virustotal 0/56
Yes, I'm planning to make everyone use the same version so we won't have to release 2 separate versions for every plugin, thanks to Riigged.

![=]](/forum/images/emotions/=].gif)
