I've taken code from several places to create instances that will be public for a charge. The instances (and their qglobals) expire after 24 hours. Some users noticed that they entered a public instance towards the end of the timer and after the instance expired, they got booted. Is there a way to refresh the timer each time a person enters a public instance without changing the instance ID? Or does that even matter? Does a server reboot (which I have every 24 hrs) affect instances? If so, that would put the qglobals and instance to expire at different times.
Anyways, I'd basically like the instances to stay up all the time (even after server reboots), and that players don't get booted when the instance expires. Here is copy of the code which I'm sure some people could make use of, and hopefully even build on it, and help me to fix these minor issues.
Code:
sub EVENT_SAY {
my $Cx = $client->GetX();
my $Cy = $client->GetY();
my $Cz = $client->GetZ();
my $npc_name = $npc->GetCleanName();
my $zoneid1 = "Instance1$zonesn$zoneid";
my $zoneid2 = "Instance2$zonesn$zoneid";
my $Enter1Inst = quest::saylink("Enter Instance 1", 1);
my $Enter2Inst = quest::saylink("Enter Instance 2", 1);
my $ExitInst = quest::saylink("Exit Instance", 1);
if ($text =~/hail/i)
{
$client->Message(315, "$npc_name says, 'Please make a choice:'");
$client->Message(315, "$Enter1Inst");
$client->Message(315, "$Enter2Inst");
$client->Message(315, "$ExitInst");
} # End hail
if ($text =~/Enter Instance 1/i)
{
$client->Message(315, "$npc_name says, 'Give me 1000 platinum to enter $zonesn Instance Version (1)'");
} # End Instance 1
if ($text =~/Enter Instance 2/i)
{
$client->Message(315, "$npc_name says, 'Give me 2000 platinum to enter $zonesn Instance Version (2)'");
} # End Instance 2
if ($text =~ /^Exit Instance$/i)
{
$client->Message(315, " " );
$client->Message(315, "Moving player $name to a non-instance version of $zoneln.");
quest::movepc($zoneid,$Cx,$Cy,$Cz);
}
} # End sub EVENT_SAY
sub EVENT_ITEM
{
my $Cx = $client->GetX();
my $Cy = $client->GetY();
my $Cz = $client->GetZ();
my $npc_name = $npc->GetCleanName();
my $zoneid1 = "Instance1$zonesn$zoneid";
my $zoneid2 = "Instance2$zonesn$zoneid";
if ($platinum == 1000) # IF 1k+ plat for instance 2
{
$client->Message(315, "$npc_name says, 'Checking Instance 1.'");
if (defined($qglobals{"$zoneid1"}))
{
my $instance_1 = $qglobals{"$zoneid1"};
quest::AssignToInstance($instance_1);
quest::MovePCInstance($zoneid, $instance_1, $Cx, $Cy, $Cz);
$client->Message(315, "$npc_name says, 'Moving you to $zonesn Instance (1) now.'");
}
else
{
$client->Message(315, "$npc_name says, 'No instance exist, creating one ...'");
my $instanceID = quest::CreateInstance("$zonesn", 0, 86400);
quest::AssignToInstance($instanceID);
quest::setglobal("$zoneid1",$instanceID,7,"H24");
quest::MovePCInstance($zoneid, $instanceID, $Cx, $Cy, $Cz);
$client->Message(315, "$npc_name says, 'Moving you to $zonesn Instance (1) now.'");
}
} # End plat > 1000
elsif ($platinum == 2000) # IF 2k+ plat for instance 2
{
$client->Message(315, "$npc_name says, 'Checking Instance 2.'");
if (defined($qglobals{"$zoneid2"}))
{
my $instance_2 = $qglobals{"$zoneid2"};
quest::AssignToInstance($instance_2);
quest::MovePCInstance($zoneid, $instance_2, $Cx, $Cy, $Cz);
$client->Message(315, "$npc_name says, 'Moving you to $zonesn Instance (2) now.'");
}
else
{
$client->Message(315, "$npc_name says, 'No instance exist, creating one ...'");
my $instanceID = quest::CreateInstance("$zonesn", 0, 86400);
quest::AssignToInstance($instanceID);
quest::setglobal("$zoneid2",$instanceID,7,"H24");
quest::MovePCInstance($zoneid, $instanceID, $Cx, $Cy, $Cz);
$client->Message(315, "$npc_name says, 'Moving you to $zonesn Instance (2) now.'");
}
} # End plat > 2000
else # If not enough plat, return everything.
{
plugin::return_items(\%itemcount);
}
} # End sub EVENT_ITEM