Thread: Turn-in trouble
View Single Post
  #2  
Old 08-07-2007, 12:27 PM
John Adams
Demi-God
 
Join Date: Jul 2006
Posts: 1,552
Default

Search the forums here for the plugin called "check_handin.pl". I am not sure when the emulator started using this method to check for handins, but the documentation is severly lacking in that area - the question has come up a lot lately.

The perl script itself should be in the folder named "plugins" from the CVS, but in case you can't find it:

Code:
# plugin::check_handin($item1 => #required_amount,...);
# autoreturns extra unused items on success
sub check_handin {
    my $hashref = shift;
    my %required = @_;
    foreach my $req (keys %required) {
	if ((!defined $hashref->{$req}) || ($hashref->{$req} != $required{$req})) {
            return(0);
	}
    }
    foreach my $req (keys %required) {
	delete $hashref->{$req};
    }
    return 1;
}

sub return_items {    
    my $hashref = shift;
    foreach my $k (keys(%{$hashref})) {
	next if($k == 0);
	my $r;
	for($r = 0; $r < $hashref->{$k}; $r++) {
		quest::summonitem($k);
	}
	delete $hashref->{$k};
    }
}

1;
To use it, here's an example (one of my personal favorite quest NPCs - Schmendrik!):
Code:
sub EVENT_ITEM {
  # 28044 :  Lord Bergurgle's Crown
  if (plugin::check_handin(\%itemcount,28044=>1)) {
    quest::emote("shoves the crown into a scorch marked leather satchel and cackles uncontrollably as madness twists his features and flames dance in his eyes. 'You, $name, have reduced the Riptides into chaos! Without a king to keep them in control they will ravage the settlements surrounding this lake! After the slaughter I shall return and easily burn the remainder of the villages and fishing shanties to the ground! None shall escape the fires of the Tyrant!!'");
    quest::summonitem(28045); # 28045  Oil of Fennin Ro
    quest::spawn2(51138,0,0,111,3627.3,51,192.4);

    #my $entid=quest::unique_spawn(51138,0,0,111,3627.3,51,192.4); # Natasha Whitewater, spawns in the hut nearby (loc to be adjusted)
    #my $mob=$entity_list->GetMobID($entid);
    #my $mobnpc=$mob->CastToNPC();
    #$mobnpc->AddToHateList($npc,1); # she attacks Shmendrik
  }

  plugin::return_items(\%itemcount); # return unused items
}
There are plenty of quests in the CVS that use this method, and I am pretty sure it'll handle multiple handins just as easily as one.
Reply With Quote