PDA

View Full Version : Quest to Learn a Recipe


dagulus2
03-22-2015, 05:48 AM
Is there anyway that you could have an Item (say a book) add a Recipe to a player, either when its read or as a click effect or even simply when you pick it up?

Looked through the forums and it seems to be possible, but I can't find any examples as to how.

ghanja
04-23-2015, 09:25 PM
Wrong forum. Should be in Quest:Q & A, just fyi.


sub EVENT_ITEM_CLICK {
if ($itemid = xxxx) {
$client->LearnRecipe(xx);
}
}


Save with script_xxxx.pl in your /quests/global/items directory.

Ensure the item has a script number which coincides with whatever you put in place of xxxx (for script_xxxx.pl).

Not quite sure if it will work on books, have yet to try it, though at the moment I cannot think of why it wouldn't.

dagulus2
04-24-2015, 07:10 AM
I wondered where this thread had gone, must have posted it prior to drinking my first cup of tea of the morning.

Tried the script, doesn't seem to do anything.

The modified it to:

sub EVENT_ITEM_CLICK {
if ($itemid = 97749) {
$client->LearnRecipe(11238); #Testing /This is probably not the right recipe id for this item
$client->Message(13, "You should have learnt recipe 11238.");
}
}

As far as I can tell, it is not firing when clicked.

NatedogEZ
04-24-2015, 07:23 AM
Missing a .. "=" in the if statement.

dagulus2
04-24-2015, 08:37 AM
Good catch, but I still do not think it's firing.

Is now:

sub EVENT_ITEM_CLICK {

$client->Message(13, "You have clicked this item!");

if ($itemid == 97749) {
$client->LearnRecipe(11238); #Testing /This is probably not the right recipe id for this item
$client->Message(13, "You should have learnt recipe 11238.");
}
}

It brings up the book text, but nothing else seems to happen.

ghanja
04-24-2015, 09:16 AM
Ok, make a statless item, non-book (as I assume you made it a book before) and try:


sub EVENT_ITEM_CLICK {
$client->Message(13, "You have clicked this item!");
if ($itemid == 97749) {
my $booktext = "Blah blah blah";
$client->ReadBook($booktext, 1);
$client->LearnRecipe(11238); #Testing /This is probably not the right recipe id for this item
$client->Message(13, "You should have learnt recipe 11238.");
}
}


I'm still not in a testing environment atm else I would, sorry bud.

dagulus2
04-24-2015, 10:58 AM
Ok, make a statless item, non-book (as I assume you made it a book before) and try:


sub EVENT_ITEM_CLICK {
$client->Message(13, "You have clicked this item!");
if ($itemid == 97749) {
my $booktext = "Blah blah blah";
$client->ReadBook($booktext, 1);
$client->LearnRecipe(11238); #Testing /This is probably not the right recipe id for this item
$client->Message(13, "You should have learnt recipe 11238.");
}
}


I'm still not in a testing environment atm else I would, sorry bud.

Ok, an item with itemstype 0 and clickeffect 12484 and the above script works. Thanks for your help!