View Single Post
  #3  
Old 11-14-2010, 01:38 AM
songie
Sarnak
 
Join Date: Dec 2009
Posts: 43
Default

This is more or less what we use on EQ-Heroes for our instancing, i deleted some parts that use custom code that you can't use but it should show a bit how they work, it should also just work fine but havent tested it in this format. It also uses a credit system, feel free to to use it, i know i had to look around for it and reverse engineer some scripts to get one to work a while ago GL

Code:
# Instance NPC

sub EVENT_SPAWN
{
	### DATA ###
	$NPCName 		= $npc->GetCleanName();
	############
}

sub EVENT_SAY
{
	my $answer1 = quest::saylink("Create your instance", 1); #Multiple Choice Answer 1 go in here
	my $answer3 = quest::saylink("Purchase more instance credits", 1); #Multiple Choice Answer 3 go in here
	my $answer6 = quest::saylink("Destroy my previous instance", 1);
	
	### Instances ###
	my @SoloZonelist = 
				(
					"Befallen", 
					"Crushbone",
					"Runnyeye Citadel", 
					"Najena", 
					"Upperguk", 
					"Estate of Unrest", 
					"Solusek A", 
					"Solusek B", 
					"The Hole", 
					"Castle Mistmoore",
					"Permafrost Caverns",
					"Cazic Thule"
				);
	
	if ($text =~/hail/i)
	{
		if (defined($globals{"Instance_CR"}) && $globals{"Instance_CR"} == 0)	
		{	
			if(!defined($qglobals{"Daily_Credit"}))
			{
				quest::setglobal("Instance_CR","3","5","F");	
				quest::setglobal("Daily_Credit","1","5","H24");
			}
		}
	
		if (!defined($qglobals{"Instance_CR"}))	{	quest::setglobal("Instance_CR","30","5", "F");	}
		my $Instance_cr = $qglobals{"Instance_CR"};		#Player total instance Credit
		$client->Message(7, "-----------");
		$client->Message(14,"$NPCName says: Hi there friend, You wish to construct another instance for training purposes? I can help! Let me see...");
		$client->Message(15,"--Choices--");
		$client->Message(14,"$name says: $answer1 ");
		$client->Message(14,"$name says: $answer3 ");
		$client->Message(7, "-----------");
		$client->Message(14,"$name says: $answer6 ");
		$client->Message(14,"Info: You have currently have $Instance_cr Credits, please note that you recieve 3 instance credits daily for free if you happen to have 0 credit!.");
		$client->Message(7, "-----------");
	}
	
	if ($text =~/\bdestroy my previous instance\b/i) #is used to destroy a solo or group instance
	{
		quest::delglobal("Instance_Number");
		my $QGlobalValue = undef;
		my $instanceID = undef;
		$client->Message(14,"Done!");
	}
	
	elsif($text=~/\bCreate your instance\b/i)	
	{
		my $count = 1;
		my $n = 0;

		while ($SoloZonelist[$n])
		{
			if ($SoloZonelist[$n])
			{
				my $ZoneName = quest::saylink($SoloZonelist[$n]);
				$client->Message(315, "$NPCName says: Go to $ZoneName");
			}
			$n++;
			$count++;
		}
	}
	
	elsif($text=~/\bPurchase more instance credits\b/i)	
	{
		$client->Message(14,"For 100pp i will give you 10 Instance Credits.");
	}
	
	elsif ($text=~/\bBefallen\b/i)				{	@Data = undef;	@Data = ("befallen", 36, 35.22, -75.27, 2.19);		GoToInstance();	}
	elsif ($text=~/\bCrushbone\b/i)				{	@Data = undef;	@Data = ("crushbone", 58, 158, -644, 4);			GoToInstance();	}
	elsif ($text=~/\bRunnyeye Citadel\b/i)		{	@Data = undef;	@Data = ("runnyeye", 11, -21.85, -108.88, 3.75);	GoToInstance();	}
	elsif ($text=~/\bNajena\b/i)				{	@Data = undef;	@Data = ("najena", 44, -22.6, 229.1, -41.8);		GoToInstance();	}
	elsif ($text=~/\bUpperguk\b/i)				{	@Data = undef;	@Data = ("guktop", 65, 7, -36, 4);					GoToInstance();	}
	elsif ($text=~/\bEstate of Unrest\b/i)		{	@Data = undef;	@Data = ("unrest", 63, 52, -38, 3.75);				GoToInstance();	}
	elsif ($text=~/\bSolusek A\b/i)				{	@Data = undef;	@Data = ("soldunga", 31, -485.77, -476.04, 73.72);	GoToInstance();	}
	elsif ($text=~/\bSolusek B\b/i)				{	@Data = undef;	@Data = ("soldungb", 32, -262.7, -423.99, -108.22);	GoToInstance();	}
	elsif ($text=~/\bThe Hole\b/i)				{	@Data = undef;	@Data = ("hole", 39, -1049.98, 640.04, -77.22);		GoToInstance();	}
	elsif ($text=~/\bCastle Mistmoore\b/i)		{	@Data = undef;	@Data = ("mistmoore", 59, 123, -295, -177);			GoToInstance();	}
	elsif ($text=~/\bPermafrost Caverns\b/i)	{	@Data = undef;	@Data = ("permafrost", 73, 0, 0, 3.75);				GoToInstance();	}
	elsif ($text=~/\bCazic Thule\b/i)			{	@Data = undef;	@Data = ("cazicthule", 48, -80, 80, 5.5);			GoToInstance();	}
}

sub GoToInstance
{
	my $limit = $qglobals{"Instance_CR"};

	if ($limit)
	{
		if ($limit > 0)
		{
			if (defined($qglobals{"Instance_Number"}))
			{
				quest::say("Instance found now moving you to the instance!");
				my $instanceID = $qglobals{"Instance_Number"};
				quest::AssignToInstance($instanceID);
				quest::MovePCInstance($Data[1], $instanceID, $Data[2],$Data[3],$Data[4]);
			}
			else
			{
				$client->Message(14,"No instance existed, so creating one");
				quest::setglobal("Instance_CR", $qglobals{"Instance_CR"}-1, 5,"F");
				my $instanceID = quest::CreateInstance($Data[0], 0, -1);
				quest::setglobal("Instance_Number",$instanceID,5,"H20");
				quest::AssignToInstance($instanceID);
				quest::MovePCInstance($Data[1], $instanceID, $Data[2],$Data[3],$Data[4]);
			}
		}
		else
		{
			$client->Message(14, "You have no more credit in your account!");
		}	
	}
}

sub EVENT_ITEM
{
	if($platinum == 100)
	{
		my $Instance_cr = $qglobals{"Instance_CR"};
		quest::setglobal("Instance_CR", $qglobals{"Instance_CR"}+10, 5, "F");
		$client->Message(14,"$NPCName says: 10 instance credits have been added to your account.");
		$client->Message(14,"Info: You have currently have $Instance_cr Credits.");
		quest::write("$NPCName.txt","Playername: $name , has payed 100pp for 10 Credits");	}
	}
}
__________________
--You start casting "Extra Content"--
--You Hit your database for 9.999 Damage, you have slain your Server--
--Please wait reinstalling!--/Sigh
Reply With Quote