View Single Post
  #9  
Old 09-08-2008, 01:18 AM
AndMetal
Developer
 
Join Date: Mar 2007
Location: Ohio
Posts: 648
Default

Quote:
Originally Posted by trevius View Post
I tried making the changes that AndMetal posted, but that gives compile errors. I was getting errors about char*, and I am guessing it is because all other quests use void and none use char* like that. I will have to mess with it a little more, but I think that this looks like it could be a simple change to Theeper's code to make it do what AndMetal (and probably most people) want. I will have to mess with it more, but I think that changing the following line:

Code:
initiator->Message(0, "%s tells you, %c%06X000000000000000000000000000000000000000%s%c",owner->GetCleanName(),0x12, item->ID, item->Name, 0x12);
From a message to a print might do it. Maybe I am thinking too simple though. It is no secret that my understanding of how code works is still horrible lol.

Maybe something like this would work:

Code:
printf("%c%06X000000000000000000000000000000000000000%s%c",owner->GetCleanName(),0x12, item->ID, item->Name, 0x12);
I will have to test this out and see if it does anything.
The reason it should be char is because we want it to return a value that contains characters. If it is void, it won't return anything, it just executes whatever is in the function. We want it to return just the string that needs to be added to the text, rather than output it for us (which is what it currently does).

However, my understanding of all the different *, &, and whatnot is somewhat limited. I thought char* meant a variable length (obviously, I need to pick up a C++ book and read like the first 10 pages), but I guess that might be incorrect if it's not compiling properly. Then again, if it failed to compile in zone/perlparser.cpp, that wouldn't surprise me since I honestly have no idea how that XS crap works

However, in the same token, we could go a different way of accomplishing the same thing: a quest plugin. The downside is that it would require knowing both the exact name of the item from the database and the item ID. The bad thing about this is, if the item name changes in the DB, you have to change it in your script. It's not really the end of the world, but could be annoying.

In any case, this should do the trick (which is just what Theeper came up with in a more user friendly form):
new file, itemlink.pl, in the plugins directory
Code:
# plugin::itemlink(itemid, itemname);
# returns the string needed in conversation to link to an item
sub itemlink {
	my $itemid = shift;
	my $itemname = shift;
	my $unknown = "000000000000000000000000000000000000000"	# if we ever figure out what we can do with this...
	my $string = sprintf("%c%06X%s%s%c",0x12,$itemid,$unknown,$itemname,0x12);
	return $string;
}
1;	# not really sure if this is needed, but it's in most of the other plugin files...
If I can, I may give this a shot on my server tonight to make sure it actually works. And at the least, this can be an easier workaround unless we can find out how to have it done in the source.
__________________
GM-Impossible of 'A work in progress'
A non-legit PEQ DB server
How to create your own non-legit server

My Contributions to the Wiki
Reply With Quote