PluginUtils.Delay(10000, () =>
{
client.SendToServer(playerTextPacket);
return;
});
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Lib_K_Relay;
using Lib_K_Relay.Utilities;
using Lib_K_Relay.Interface;
using Lib_K_Relay.Networking;
using Lib_K_Relay.Networking.Packets;
using Lib_K_Relay.Networking.Packets.Client;
using Lib_K_Relay.Networking.Packets.Server;
using Lib_K_Relay.Networking.Packets.DataObjects;
namespace Spam
{
public class Spam : IPlugin
{
private bool _enabled = false;
PlayerTextPacket playerTextPacket;
string str2 = "Yooow!";
public string GetAuthor()
{ return "XthEsimon"; }
public string GetName()
{ return "Spam"; }
public string GetDescription()
{ return "This plugin let's you spam messages!"; }
public string[] GetCommands()
{
return new string[2]
{
"/spam start:stop",
"/status"
};
}
public void Initialize(Proxy proxy)
{
proxy.HookCommand("spam", OnMyPluginCommand);
proxy.HookCommand("status", OnMyPluginCommand2);
proxy.HookPacket(PacketType.TEXT, OnUpdate);
}
public static string RandomString(int length)
{
const string chars = "!.,:;$&";
var random = new Random();
return new string(Enumerable.Repeat(chars, length)
.Select(s => s[random.Next(s.Length)]).ToArray());
}
private void OnCreateSuccess(Client client, Packet packet)
{
if (!_enabled)
{
PluginUtils.Delay(3000, () =>
{
client.SendToClient(PluginUtils.CreateNotification(
client.ObjectId, "Spam Disabled"));
});
}
if (_enabled)
{
PluginUtils.Delay(3000, () =>
{
client.SendToClient(PluginUtils.CreateNotification(
client.ObjectId, "Spam Enabled"));
});
}
}
private void OnMyPluginCommand(Client client, string command, string[] args)
{
if (args.Length == 0) return;
if (args[0] == "start")
{
_enabled = true;
client.SendToClient((Packet)PluginUtils.CreateOryxNotification("Notifier:", "Spam Enabled"));
}
if (args[0] == "stop")
{
_enabled = false;
client.SendToClient((Packet)PluginUtils.CreateOryxNotification("Notifier:", "Spam Disabled"));
}
}
private void OnMyPluginCommand2(Client client, string command, string[] args)
{
if (!_enabled)
{
client.SendToClient((Packet)PluginUtils.CreateOryxNotification("Notifier:", "Spam Disabled"));
}
else if (_enabled)
{
client.SendToClient((Packet)PluginUtils.CreateOryxNotification("Notifier:", "Spam Enabled"));
}
}
private void OnUpdate(Client client, Packet packet)
{
if (!_enabled) return;
playerTextPacket = (PlayerTextPacket)Packet.Create(PacketType.PLAYERTEXT);
playerTextPacket.Text = str2;
PluginUtils.Delay(10000, () =>
{
client.SendToServer(playerTextPacket);
return;
});
}
}
}