A template plugin for TazUO that demonstrates the CUO_API plugin interface.
- Click the "Fork" button at the top of this repository
- Clone your fork to your local machine:
git clone https://github.com/YOUR-USERNAME/SimplePlugin.git cd SimplePlugin - Rename the project and namespace to match your plugin name
- Start coding your plugin!
- Clone this repository:
git clone https://github.com/TazmanianTad/SimplePlugin.git cd SimplePlugin - Remove the existing git history and start fresh:
rm -rf .git git init git add . git commit -m "Initial commit"
- .NET 9 SDK
- TazUO client with plugin support
- The
cuoapi.dllfile (included in this repository)
- Open the solution in your preferred IDE (Visual Studio, Rider, VS Code)
- Build the project:
dotnet build -c Release
- The compiled plugin DLL will be in
SimplePlugin/bin/Release/net9/
- Copy the compiled
SimplePlugin.dllto your TazUO plugins directory - Launch TazUO
- The plugin will load automatically and you should see "Simple plugin loaded" in the console
SimplePlugin/
├── SimplePlugin/
│ ├── Actions.cs # Event handlers and callbacks
│ ├── Engine.cs # Main plugin engine and initialization
│ ├── Packet.cs # Packet creation/manipulation utilities
│ ├── SPlugin.cs # Entry point
│ └── SimplePlugin.csproj # Project configuration
├── cuoapi.dll # TazUO API library
└── README.md
The plugin template includes stubs for all CUO_API callbacks in Actions.cs:
OnPacketReceived- Intercept packets from server to clientOnPacketSent- Intercept packets from client to server
OnHotkey- Handle keyboard hotkeysOnMouse- Handle mouse events
OnPlayerPositionChanged- Track player movementOnInitialize- Called when plugin loadsOnConnected- Called when connecting to serverOnDisconnected- Called when disconnectingOnClientClosing- Called when client closesOnFocusGained- Window focus gainedOnFocusLost- Window focus lost
The plugin can call back into the TazUO client using these functions (defined in Engine.cs):
_sendToClient- Inject packets to the client_sendToServer- Send packets to the server_getPacketLength- Get packet length by ID_getPlayerPosition- Get current player coordinates_castSpell- Cast a spell by index_getStaticImage- Get static image/art data_tick- Execute on game tick_requestMove- Request player movement_setTitle- Set window title_getUOFilePath- Get UO installation path
public static unsafe bool OnPacketReceived(ref byte[] data, ref int length)
{
byte id = data[0];
Console.WriteLine($"Received packet 0x{id:X2}, length: {length}");
return true; // Let client process the packet
}public static unsafe bool OnPacketSent(ref byte[] data, ref int length)
{
byte id = data[0];
// Block movement packets (0x02)
if (id == 0x02)
{
Console.WriteLine("Blocked movement packet");
return false; // Block the packet
}
return true; // Allow other packets
}- Implement callbacks: Add your logic to the callback methods in
Actions.cs - Add new classes: Create additional helper classes as needed
- Use the Packet class: Build and send custom packets using the
Packetutility - Update plugin info: Modify the console messages to reflect your plugin name
To debug your plugin:
- Build in Debug configuration
- Attach your debugger to the TazUO process
- Set breakpoints in your plugin code
- Launch TazUO
Console output will appear in the TazUO console window.
This is a template repository. Feel free to modify it for your needs. If you create improvements to the base template structure, consider contributing back!
See LICENSE file for details.