Untested, but should do what you want it to:
Code:
sub EVENT_SAY {
my %trade = (0 => ["Undead Potions", "undead", 14180],
1 => ["Dulsehound Potions", "dulsehound", 14188],
2 => ["Grave Dust Potions", "grave dust", 14194],
3 => ["Frosty Marble", "frosty", 132541],
4 => ["Firey Marble", "firey", 132542],
5 => ["Norrath Soldier", "norrath", 132543],
6 => ["Soldier of Norrath Dust", "soldier dust", 132544]);
if ($text =~/Hail/i) {
plugin::Whisper("How are ya friend? I can tell by yer backbone several have been fell at yer feet. Well what I be missing in size I make up for wit dese here swords. Ya see me is looking for " . quest::saylink("Planar Essence", 1) . " to combine wit mah swords to become the most famous dwarf in all Kaladim.");
} elsif($text=~/Planar Essence/i && plugin::check_hasitem($client, 132540)) {
plugin::Whisper("It appears you have ventured into the terrible planes and killed a few of those creatures. Would you be willing to " . quest::saylink("bargain", 1) . " for a few items I have collected from all over the place?");
} elsif($text=~/Bargain/i && plugin::check_hasitem($client, 132540)) {
plugin::Whisper("Wonderful. Here is a list of items that I have and would be willing to trade.");
foreach my $item (keys %trade) {
plugin::Whisper(quest::saylink("link $trade{$item}[1]", 1, $trade{$item}[0]));
}
} elsif ($text=~/^Link/i) {
if (length(substr($text, 5)) > 0) {
foreach my $key (sort {$trade{$a}[0] cmp $trade{$b}[0]} keys %trade) {
if (substr($text, 5) eq $trade{$key}[1]) {
if (plugin::check_hasitem($client, $trade{$key}[2])) {
plugin::Whisper("Sorry, but it appears you already possess a " . quest::varlink($trade{$key}[2]) . ", $name.");
} else {
plugin::Whisper("So you would like to " . quest::saylink("trade $trade{$key}[1]", 1, "trade") . " your " . quest::varlink(132540) . " for my " . quest::varlink($trade{$key}[2]) . "?");
}
}
}
}
} elsif ($text =~/^Trade/i && plugin::check_hasitem($client, 132540)) {
if (length(substr($text, 6)) > 0) {
foreach my $key (keys %trade) {
if (substr($text, 6) eq $trade{$key}[1]) {
if (!plugin::check_hasitem($client, $trade{$key}[2])) {
$client->NukeItem(132540);
quest::summonitem($trade{$key}[2]);
plugin::Whisper("Enjoy your " . quest::varlink($trade{$key}[2]) . ", $name!");
}
}
}
}
}
}