using System;
using OXGaming.TibiaAPI;
using OXGaming.TibiaAPI.Network.ClientPackets;
using OXGaming.TibiaAPI.Network.ServerPackets;
using OXGaming.TibiaAPI.Constants;
class Program
{
static void Main()
{
// First, we'll need to create our `Client` object and a boolean flag to determine if we are hasted:
var isAutoHasteEnabled = false;
using var client = new OXGaming.TibiaAPI.Client();
// Enable client packet modification so we can block `Text` client packets with our command identifier.
client.Connection.IsClientPacketModificationEnabled = true;
// Now let's create the `Talk` client packet we'll use to cast the haste spell:
var hasteSpell = new OXGaming.TibiaAPI.Network.ClientPackets.Talk(client)
{
MessageMode = OXGaming.TibiaAPI.Constants.MessageModeType.Say,
Text = "utani hur"
};
// Next, we need to intercept the `Talk` client packet so we can check for our commands:
client.Connection.OnReceivedClientTalkPacket += (packet) =>
{
var data = (OXGaming.TibiaAPI.Network.ClientPackets.Talk)packet;
if (data.Text.StartsWith("/"))
{
if (data.Text == "/on")
{
isAutoHasteEnabled = true;
}
else if (data.Text == "/off")
{
isAutoHasteEnabled = false;
}
return false; // block any packet that starts with our command identifier in case of typos
}
return true; // all other messages can be forwarded as normal
};
// Then, we need to intercept the `PlayerState` server packet to check if we need to cast our haste spell:
client.Connection.OnReceivedServerPlayerStatePacket += (packet) =>
{
var data = (OXGaming.TibiaAPI.Network.ServerPackets.PlayerState)packet;
// The 7th bit of the `State` integer is the haste flag; if it's not set then the player isn't hasted.
if (isAutoHasteEnabled && (data.State & 64) == 0)
{
client.Connection.SendToServer(hasteSpell);
}
return true;
};
client.StartConnection();
Console.Read();
}
}