View Single Post
  #1  
Old 03-28-2017, 04:35 PM
ghanja's Avatar
ghanja
Dragon
 
Join Date: Aug 2012
Location: Hershey, PA
Posts: 499
Default Zone Recommendations with Porting

I'll revisit this, as I whipped this together real quick before running out. But, I wanted to share for now to get it up on the board in the case I would forget later (which wouldn't be unlike me):

Code:
%recommendhash = (
	1 => [[1..9],["crushbone","unrest"]],
	2 => [[10..19],["crushbone","unrest"]],
	3 => [[20..29],["crushbone","unrest"]],
	4 => [[30..39],["crushbone","unrest"]],
	5 => [[40..49],["crushbone","unrest"]],
	6 => [[50..59],["crushbone","unrest"]],
	7 => [[60..69],["crushbone","unrest"]],
	9 => [[70..79],["crushbone","unrest"]],
);

sub EVENT_SAY
{	
	if ($text=~/Hail/i)
	{
		plugin::Whisper("Seeking our custom zones? I can ".quest::saylink("recommend",1)." zones based on your level.");
	}
	elsif ($text=~/recommend/i)
	{
		foreach $key (keys %recommendhash)
		{
			if ($ulevel ~~ @{$recommendhash{$key}[0]})
			{
				$formattedstring = undef;
				for ($i = 0; $i <= ((scalar @{$recommendhash{$key}[1]}) - 1); $i++)
				{
					if ($i < ((scalar @{$recommendhash{$key}[1]}) - 1))
					{
						$formattedstring .= quest::saylink("xxxx".$recommendhash{$key}[1][$i],1,"[".plugin::Zone("LN",$recommendhash{$key}[1][$i])."], ");
					} else {
						$formattedstring .= " and ".quest::saylink("xxxx".$recommendhash{$key}[1][$i],1,"[".plugin::Zone("LN",$recommendhash{$key}[1][$i])."].");
					}
				}
				$hashkey = $key;
				plugin::Whisper("I recommend the following: ".$formattedstring);
			}
		}
		plugin::Whisper("I have no recommended zones for you.") if (!defined $formattedstring);
	}
	elsif ($text=~/^xxxx/) 
	{
		@portargument = split('xxxx', $text);
		plugin::Whisper("$name, stand close to me while I take you there!");
		quest::doanim(42);
		quest::emote ("hands begin to move wildly.");
		quest::zone ($portargument[1]);
	}
}
Requires Kingly's Zone.pl plugin

Only checked for syntax atm and there is likely a more eloquent way to code it, but, was a quickie. Posted in discord figured I'd place here for prosperity.

*Edit: Feel free to modify the hash for whatever ranges of levels that apply to you, as well as the possible zone shortnames for said ranges. Doesn't matter what the keys are (i.e. 1 =>, 2=>, etc.) as they aren't used, I have them in order just because it happened that way while writing it.
Reply With Quote