Go Back   RunUO - Ultima Online Emulation > RunUO > Utility Support > PlayUO (Krrios' Client)

PlayUO (Krrios' Client) Support & Etc for Krrios's UO Client.

Reply
 
Thread Tools Display Modes
Old 02-07-2006, 01:08 PM   #1 (permalink)
 
Join Date: Apr 2005
Age: 49
Posts: 19
Question Little Help needed writing a plugin

Hi there.

Im trying to write a plugin, that calculates the price of an item using a database server.

Anyone can tell me how I can show up a target selector. I mean that the mouse cursor switches to the targeting symbol and the user can click on an item to choose it.

Thank you very much for your help.

Greetings from Europe
blubber is offline   Reply With Quote
Old 02-07-2006, 05:44 PM   #2 (permalink)
 
Join Date: Apr 2005
Age: 49
Posts: 19
Default

Hi, I just began so there is almost nothing.
Code:
public class PriceCalc : Plugin
	{
		public override bool OnCommandEntered(string s)
		{
			if(s == ". price")
			{
				Client.Engine.AddTextMessage("Select Item");
				Client.Engine.AddTarget();
			}
			return base.OnCommandEntered (s);
		}
	}
I'm not sure about the "Client.Engine.AddTarget()" All of those Methods I found require a target parameter. But I am looking for a function, that throws a target back
blubber is offline   Reply With Quote
Old 02-14-2006, 01:06 AM   #3 (permalink)
 
Join Date: Dec 2005
Posts: 1
Default

I don't look on here very often.. So don't expect a quick reply to any questions.

But you need to make a new object that implements Client.Targeting.ITargetHandler

It will need to have a constructor (can just be blank)
void OnTarget(object)
void OnCancel(TargetCancelType)

The onTarget will recieve the object that is targeted. You should check that is it an Item before typecasting it.

Then you will need to make an object with Plugin as the parent, just like you already have. But instead of Engine.AddTarget, you will need

Engine.TargetHandler = new MyTargetHandler();

Ok?
Alask is offline   Reply With Quote
Old 03-02-2006, 05:18 AM   #4 (permalink)
Account Terminated
 
Join Date: Sep 2002
Location: New York
Age: 22
Posts: 476
Default

I'll help by offering some rough code;

Code:
	class FindItemPrice : Plugin
	{
		public override bool OnCommandEntered(string s)
		{
			if (s == ". getitemprice")
			{
				Engine.AddTextMessage("Target the items whos price you'd like to get.");
				Engine.TargetHandler = new CustomTargetHandler();
			}
			return base.OnCommandEntered(s);
		}
	}

	class CustomTargetHandler : ITargetHandler
	{
		public void OnCancel(TargetCancelType why)
		{
		}

		public void OnTarget(object targeted)
		{
			Item targetedItem;

			if (targeted is Item)
			{
				targetedItem = targeted as Item;
				// Do your stuff here.
			}
			else
				Engine.AddTextMessage("That is not an item.");
		}
	}
Dipset is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 RC5