Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2016
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 43.77 KB | None | 0 0
  1. #NOTE!
  2. #Sync this between treecontroller.pl and this file!!
  3.  
  4. sub EVENT_CONNECT {
  5.     if (($status == 1)) {
  6.         quest::settimer("Leaderboard", 3);
  7.         quest::setglobal("TokenCounter", 0, 5, "F");
  8.     }
  9.     if ($client->GetLanguageSkill(0) < 100) {
  10.         quest::setlanguage(0, 100);
  11.     }
  12.     if ($client->GetSkill(40) < 200) {
  13.         quest::setskill(40, 200);
  14.     }
  15.     if (plugin::HasItem(64513)) {
  16.         plugin::Message("You still have some hot coffee, it will cool down soon!");
  17.         quest::settimer("Cool13501", 900);
  18.     }
  19.     if (plugin::HasItem(4045)) {
  20.         plugin::Message("The silver will harden soon.");
  21.         quest::settimer("cool13529", 1800);
  22.     }
  23.     if (plugin::HasItem(4043)) {
  24.         plugin::Message("The blazing embers will cool soon.");
  25.         quest::settimer("cool4043", 900);
  26.        
  27.     }
  28. }
  29.  
  30. sub EVENT_ZONE {
  31.     if ($client->GetHP() < 1) {
  32.         my @killverbs = ("slain","annihilated","destroyed","wrecked","laid to rest","vanquished","defeated","ended","totaled","killed","snuffed out","beaten","knocked off");
  33.         quest::gmsay("Alas, $name has been ".$killverbs[quest::ChooseRandom(0..$#killverbs)]." by ".$client->GetTarget()->GetCleanName()."!", 335, 1, 0, 0);
  34.         if (!defined $qglobals{"deaths"}) {
  35.             quest::setglobal("deaths",1,5,"F");
  36.         }
  37.         else {
  38.             quest::setglobal("deaths",$qglobals{"deaths"}+1,5,"F");
  39.         }
  40.     }
  41. }
  42.  
  43.  
  44. sub EVENT_TIMER {
  45.     my @array = split(' ', $qglobals{"Alt Bind"});
  46.     if ($timer eq "gotoclz") {
  47.         quest::stoptimer ("gotoclz");
  48.         $client->Message (12, "Please wait while you are moved.");
  49.         quest::movepc(190,0,0,0,0);
  50.     }
  51.     elsif ($timer eq "gotojail") {
  52.         quest::stoptimer ("gotojail");
  53.         #$client->Message (12, "You are being moved due to suspect of running an incompatible and/or unpatched client!");
  54.         #quest::movepc(45,0,0,0,220);
  55.     }
  56.     elsif ($timer eq "Zoned") {
  57.         quest::stoptimer("Zoned");
  58.         if ($zonesn=~/Nexus/i && !defined $qglobals{"NexusBind"}) {
  59.             quest::selfcast(35);
  60.             quest::setglobal("NexusBind", 1, 5, "F");
  61.         }
  62.     }
  63.     elsif ($timer eq "Leaderboard") {
  64.         quest::stoptimer("Leaderboard");
  65.         my %hash = plugin::LeaderboardTypeHash();
  66.         foreach my $type (sort {$a cmp $b} keys %hash) {
  67.             $client->Message(315, quest::saylink("#leaderboard $type", 1, "Top 10 Players in $type"));
  68.         }
  69.         if ($status < 100) {
  70.             plugin::GetLeaderboard(%qglobals);
  71.         }
  72.         quest::settimer("Leaderboard", 3600);
  73.     }
  74.     elsif ($timer eq "Cool13501") {
  75.         my $amount = plugin::CountItem(64513);
  76.         quest::stoptimer("Cool13501");
  77.         plugin::Message("Your coffee has cooled down and turned into " . quest::varlink(3239) . "!");
  78.         plugin::DeleteItem(64513, $amount);
  79.         quest::summonitem(3239, $amount);
  80.     }
  81.     elsif ($timer eq "cool4043") {
  82.         my $amount = plugin::CountItem(4043);
  83.         quest::stoptimer("cool4043");
  84.         plugin::Message("The embers stop burning.");
  85.         plugin::DeleteItem(4043, $amount);
  86.         quest::summonitem(4044, $amount);
  87.     }
  88.     elsif ($timer eq "cool13529") {
  89.         my $amount = plugin::CountItem(4045);
  90.         quest::stoptimer("cool13529");
  91.         plugin::Message("The silver hardens.");
  92.         plugin::DeleteItem(4045, $amount);
  93.         quest::summonitem(33789, $amount);
  94.     }
  95.     if ($timer eq "TokenTimer") {
  96.     quest::setglobal("TokenCounter", ($qglobals{"TokenCounter"} + 1), 5, "F");
  97.     quest::gmsay("Your token counter incremented: " . $qglobals{"TokenCounter"}); # Will send white text to all players in the current zone with an admin status of >= 80
  98.     if ( $qglobals{"TokenCounter"} == 60 ) {
  99.     $client->AddCrystals(1, 0);
  100.     $client->Message (15, "You've earned a loyalty token!");
  101.     quest::setglobal("TokenCounter", 0, 4, "F");
  102.     }
  103.     }
  104.     elsif ($timer =~ /WardTimer/i) { #Ward Timer for placable object
  105.    
  106.         #We don't stop this timer unless the object ceases to exist
  107.         my @arg = split('WardTimer', $timer);
  108.         my $id = $arg[1];
  109.         #quest::gmsay("tick tock $id", 15);
  110.         $object = $entity_list->GetObjectByID($client->GetEntityVariable("WardID" . $id));
  111.         if(defined($object) &&  plugin::HasRadius($id))
  112.         {
  113.             my $triggered = 0;
  114.             if(plugin::GetRadiusData($id, "npcflag"))
  115.             {
  116.                 #do stuff
  117.                 my @npcs = $entity_list->GetNPCList();
  118.                 foreach my $singlenpc (@npcs)
  119.                 {
  120.                     my $rad = plugin::GetRadiusData($id, "radius");
  121.                     if(int($object->GetX()) > int($singlenpc->GetX())-$rad && int($object->GetX()) < int($singlenpc->GetX())+$rad &&
  122.                     int($object->GetY()) > int($singlenpc->GetY())-$rad && int($object->GetY()) < int($singlenpc->GetY())+$rad && !$singlenpc->IsPet())
  123.                   {                
  124.                     if(plugin::GetRadiusData($id, "remove"))
  125.                     {
  126.                         $triggered = 1;
  127.                     }
  128.                     if(plugin::GetRadiusData($id, "spell_id"))
  129.                     {
  130.                         $client->SpellFinished(plugin::GetRadiusData($id, "spell_id"), $singlenpc);
  131.                     }
  132.                    
  133.                     if(plugin::GetRadiusData($id, "spell_id2"))
  134.                     {
  135.                         $client->SpellFinished(plugin::GetRadiusData($id, "spell_id2"), $singlenpc);
  136.                     }
  137.                    
  138.                     if(plugin::GetRadiusData($id, "spell_id3"))
  139.                     {
  140.                         $client->SpellFinished(plugin::GetRadiusData($id, "spell_id3"), $singlenpc);
  141.                     }
  142.                   }
  143.                   else
  144.                   {
  145.                         #   quest::gmsay("No radius!", 15);
  146.                   }
  147.                 }
  148.             }
  149.             else
  150.             {
  151.                 my @clients = $entity_list->GetClientList();
  152.                 foreach my $singleclient (@clients)
  153.                 {
  154.                     my $rad = plugin::GetRadiusData($id, "radius");
  155.                     if(int($object->GetX()) > int($singleclient->GetX())-$rad && int($object->GetX()) < int($singleclient->GetX())+$rad &&
  156.                     int($object->GetY()) > int($singleclient->GetY())-$rad && int($object->GetY()) < int($singleclient->GetY())+$rad)
  157.                   {
  158.                     if(plugin::GetRadiusData($id, "remove"))
  159.                     {
  160.                         $triggered = 1;
  161.                     }
  162.                    
  163.                     if(plugin::GetRadiusData($id, "spell_id"))
  164.                     {
  165.                         $client->SpellFinished(plugin::GetRadiusData($id, "spell_id"), $singleclient);
  166.                     }
  167.                    
  168.                     if(plugin::GetRadiusData($id, "spell_id2"))
  169.                     {
  170.                         $client->SpellFinished(plugin::GetRadiusData($id, "spell_id2"), $singleclient);
  171.                     }
  172.                    
  173.                     if(plugin::GetRadiusData($id, "spell_id3"))
  174.                     {
  175.                         $client->SpellFinished(plugin::GetRadiusData($id, "spell_id3"), $singleclient);
  176.                     }
  177.                    
  178.                   }
  179.                   else
  180.                   {
  181.                         #quest::gmsay("No radius!", 15);
  182.                   }
  183.                 }
  184.             }
  185.             if($triggered)
  186.             {
  187.                 $object->Depop();
  188.                 quest::stoptimer($timer);
  189.             }
  190.            
  191.         }
  192.         else #stop the timer
  193.         {
  194.             #quest::gmsay("No Timer!", 15);
  195.             quest::stoptimer($timer);
  196.         }
  197.     }
  198. }
  199.  
  200. sub EVENT_DISCOVER_ITEM {
  201.     if ($status < 150) {
  202.         quest::gmsay("$name has discovered " . quest::varlink($itemid) . ".", 335, 1, 0, 0);
  203.     }
  204.     if (!defined $qglobals{"discovereditems"}) {
  205.         quest::setglobal("discovereditems",1,5,"F");
  206.     }
  207.     else {
  208.         quest::setglobal("discovereditems",$qglobals{"discovereditems"}+1,5,"F");
  209.     }
  210. }
  211.  
  212. sub EVENT_FORAGE_FAILURE {
  213.     if (!defined $qglobals{"foragefails"}) {
  214.         quest::setglobal("foragefails",1,5,"F");
  215.     }
  216.     else {
  217.         quest::setglobal("foragefails",$qglobals{"foragefails"}+1,5,"F");
  218.     }
  219. }
  220.  
  221. sub EVENT_FORAGE_SUCCESS {
  222.     if (!defined $qglobals{"foragesuccesses"}) {
  223.         quest::setglobal("foragesuccesses",1,5,"F");
  224.     }
  225.     else {
  226.         quest::setglobal("foragesuccesses",$qglobals{"foragesuccesses"}+1,5,"F");
  227.     }
  228. }
  229.  
  230. sub EVENT_DUEL_LOSE {
  231.     if (!defined $qglobals{"duelslost"}) {
  232.         quest::setglobal("duelslost",1,5,"F");
  233.     }
  234.     else {
  235.         quest::setglobal("duelslost",$qglobals{"duelslost"}+1,5,"F");
  236.     }
  237. }
  238.  
  239. sub EVENT_DUEL_WIN {
  240.     if (!defined $qglobals{"duelswon"}) {
  241.         quest::setglobal("duelswon",1,5,"F");
  242.     }
  243.     else {
  244.         quest::setglobal("duelswon",$qglobals{"duelswon"}+1,5,"F");
  245.     }
  246. }
  247.  
  248. sub EVENT_COMBINE_SUCCESS {
  249.     my @skillidarray = (59,60,61,63,64,65,68,69);
  250.     my @skillnames = ("Alchemy","Cooking","Tailoring","Blacksmithing","Woodworking","Brewing","Jewelcrafting","Crafting");
  251.     my $counter = 0;
  252.     foreach $individualskill (@skillidarray) {
  253.         $skillglobal = "skill".$individualskill."";
  254.         if (!defined $qglobals{$skillglobal}) {
  255.             quest::setglobal($skillglobal, $client->GetRawSkill($individualskill), 5, "F");
  256.         }
  257.         else {
  258.             if ($client->GetRawSkill($individualskill) > $qglobals{$skillglobal}) {
  259.                 quest::setglobal($skillglobal, $client->GetRawSkill($individualskill), 5, "F");
  260.                 if (($client->GetRawSkill($individualskill) % 10) == 0) {
  261.                     quest::gmsay("After much work, $name has obtained a skill level of ".$client->GetRawSkill($individualskill)." in ".$skillnames[$counter]."!", 335, 1, 0, 0);
  262.                 }
  263.             }
  264.             elsif ($client->GetRawSkill($individualskill) < $qglobals{$skillglobal}) {
  265.                 #$client->Message (15, "ERROR: We've lost QGLOBAL record of your ".$skillnames[$counter]." skill level!  Resynchronizing...");
  266.                 quest::setglobal($skillglobal, $client->GetRawSkill($individualskill), 5, "F");
  267.             }
  268.         }
  269.         $counter++;
  270.     }  
  271.     if ($status < 150) {
  272.         my $savevalue = "".$recipe_name.$recipe_id."";
  273.         if (!defined $qglobals{$savevalue}) {
  274.             quest::gmsay("$name has discovered the recipe for '$recipe_name'.", 335, 1, 0, 0);
  275.             quest::targlobal($savevalue, $charid, "F", 0, 0, 0);
  276.         }
  277.     }
  278.     if ($recipe_id == 13501) {
  279.         plugin::Message("Drink your coffee before it gets cold!");
  280.         quest::settimer("Cool13501", 900);
  281.     }
  282.     if ($recipe_id == 13529) {
  283.         plugin::Message("The silver will harden soon.");
  284.         quest::settimer("cool13529", 1800);
  285.     }
  286.     if (!defined $qglobals{"tscombines"}) {
  287.         quest::setglobal("tscombines",1,5,"F");
  288.     }
  289.     else {
  290.         quest::setglobal("tscombines",$qglobals{"tscombines"}+1,5,"F");
  291.     }
  292.    
  293.    
  294.     @row = plugin::GetRecipeTrivial($recipe_id);
  295.    
  296.     if($client->GetSkill($row[1]) < $row[0])
  297.     {
  298.         $client->SetEXP($client->GetEXP() + $client->CalcEXP(18), 0);
  299.     }
  300.     if(plugin::HasRecipe($recipe_id))
  301.     {
  302.         my $randomreturn = plugin::RandomRange(0, 200);
  303.         my $rare = 0;
  304.        
  305.         if(plugin::GetRecipeData($recipe_id, "legendaryresult") && $rare == 0)
  306.         {
  307.             if($randomreturn < plugin::GetRecipeData($recipe_id, "legendarychance") * 2)
  308.             {  
  309.                 $client->Message(15, "Great! You find " . plugin::GetRecipeData($recipe_id, "legendaryqty") . " " . plugin::GetRecipeData($recipe_id, "legendarytext") . "!");
  310.                 $client->SummonItem(plugin::GetRecipeData($recipe_id, "legendaryresult"), plugin::GetRecipeData($recipe_id, "legendaryqty"));
  311.                 $rare = 1;
  312.             }
  313.         }
  314.        
  315.         if(plugin::GetRecipeData($recipe_id, "epicresult") && $rare == 0)
  316.         {
  317.             if($randomreturn < plugin::GetRecipeData($recipe_id, "uncommonchance") * 2)
  318.             {  
  319.                 $client->Message(15, "Amazing discovery! You find " . plugin::GetRecipeData($recipe_id, "epicqty") . " " . plugin::GetRecipeData($recipe_id, "epictext") . "!");
  320.                 $client->SummonItem(plugin::GetRecipeData($recipe_id, "epicresult"), plugin::GetRecipeData($recipe_id, "epicqty"));
  321.                 $rare = 1;
  322.             }
  323.         }
  324.        
  325.         if(plugin::GetRecipeData($recipe_id, "urareresult") && $rare == 0)
  326.         {
  327.             if($randomreturn < plugin::GetRecipeData($recipe_id, "urarechance") * 2)
  328.             {  
  329.                 $client->Message(15, "Wow! You find " . plugin::GetRecipeData($recipe_id, "urareqty") . " " . plugin::GetRecipeData($recipe_id, "uraretext") . "!");
  330.                 $client->SummonItem(plugin::GetRecipeData($recipe_id, "urareresult"), plugin::GetRecipeData($recipe_id, "urareqty"));
  331.                 $rare = 1;
  332.             }
  333.         }
  334.        
  335.         if(plugin::GetRecipeData($recipe_id, "rareresult") && $rare == 0)
  336.         {
  337.             if($randomreturn < plugin::GetRecipeData($recipe_id, "rarechance") * 2)
  338.             {  
  339.                 $client->Message(15, "You find " . plugin::GetRecipeData($recipe_id, "rareqty") . " " . plugin::GetRecipeData($recipe_id, "raretext") . "!");
  340.                 $client->SummonItem(plugin::GetRecipeData($recipe_id, "rareresult"), plugin::GetRecipeData($recipe_id, "rareqty"));
  341.                 $rare = 1;
  342.             }
  343.         }
  344.         if(plugin::GetRecipeData($recipe_id, "uncommonresult") && $rare == 0)
  345.         {
  346.             if($randomreturn < plugin::GetRecipeData($recipe_id, "uncommonchance") * 2)
  347.             {  
  348.                 $client->Message(15, "You find... " . plugin::GetRecipeData($recipe_id, "uncommonqty") . " " . plugin::GetRecipeData($recipe_id, "uncommontext") . "!");
  349.                 $client->SummonItem(plugin::GetRecipeData($recipe_id, "uncommonresult"), plugin::GetRecipeData($recipe_id, "uncommonqty"));
  350.                 $rare = 1;
  351.             }
  352.         }
  353.         if($rare == 0)
  354.         {
  355.             $client->Message(15, "Nice! You find " . plugin::GetRecipeData($recipe_id, "qty") . " " . plugin::GetRecipeData($recipe_id, "text") . "!");
  356.             $client->SummonItem(plugin::GetRecipeData($recipe_id, "result"), plugin::GetRecipeData($recipe_id, "qty"));
  357.         }
  358.     }
  359. }
  360.  
  361. sub EVENT_COMBINE_FAILURE {
  362.     my @skillidarray = (59,60,61,63,64,65,68,69);
  363.     my @skillnames = ("Alchemy","Cooking","Tailoring","Blacksmithing","Woodworking","Brewing","Jewelcrafting","Pottery");
  364.     my $counter = 0;
  365.     foreach $individualskill (@skillidarray) {
  366.         $skillglobal = "skill".$individualskill."";
  367.         if (!defined $qglobals{$skillglobal}) {
  368.             quest::setglobal($skillglobal, $client->GetRawSkill($individualskill), 5, "F");
  369.         }
  370.         else {
  371.             if ($client->GetRawSkill($individualskill) > $qglobals{$skillglobal}) {
  372.                 quest::setglobal($skillglobal, $client->GetRawSkill($individualskill), 5, "F");
  373.                 if (($client->GetRawSkill($individualskill) % 10) == 0) {
  374.                     quest::gmsay("After much work, $name has obtained a skill level of ".$client->GetRawSkill($individualskill)." in ".$skillnames[$counter]."!", 335, 1, 0, 0);
  375.                 }
  376.             }
  377.             elsif ($client->GetRawSkill($individualskill) < $qglobals{$skillglobal}) {
  378.                 #$client->Message (15, "ERROR: We've lost QGLOBAL record of your ".$skillnames[$counter]." skill level!  Resynchronizing...");
  379.                 quest::setglobal($skillglobal, $client->GetRawSkill($individualskill), 5, "F");
  380.             }
  381.         }
  382.         $counter++;
  383.     }
  384.     if (!defined $qglobals{"tsfailures"}) {
  385.         quest::setglobal("tsfailures",1,5,"F");
  386.     }
  387.     else {
  388.         quest::setglobal("tfailures",$qglobals{"tsfailures"}+1,5,"F");
  389.     }
  390. }
  391.  
  392. sub EVENT_ENTERZONE {
  393.     quest::settimer("Zoned", 5);
  394.     quest::settimer ("TokenTimer", 60); ## Token Timer
  395.     my @approvedzonelist = (    "xuolia", "nexus", "saquia", "marblepalace", "malefix", "airplane", "drybone",
  396.                                 "shipmvu", "cemetary", "sewers", "enochia", "malsyrian", "miserymire","daggerdepth",
  397.                                 "maridmanor","sleeper","qeynos","mmca","innothuleb","airplane","chapel",
  398.                                 "chapeldark","citymist","firiona","gukd","qcat");
  399.     my @startingzonelist = ("clz", "theater", "purgatory");
  400.     my $gm_status = $client->GetGM();
  401.     if ((!$gm_status) && ($status < 80)) {
  402.         if (!defined $qglobals{$zonesn}) {
  403.             #quest::gmsay("$name has discovered the zone $zoneln.", 335, 1, 0, 0);
  404.             quest::targlobal($zonesn, 1, "F", 0, 0, 0);
  405.         }
  406.         if ($zonesn ~~ @approvedzonelist)   {
  407.             if ((defined $qglobals{"newtoon"}) && ($qglobals{"newtoon"} == 1) ) {
  408.                 quest::settimer("gotoclz", 2);
  409.             }
  410.         }
  411.         elsif ($zonesn eq "kerraridge") {
  412.             quest::movepc(247,260.98,-448.03,3.75,64.5);
  413.         }
  414.         elsif (!($zonesn ~~ @startingzonelist)) {
  415.             quest::settimer("gotojail",2);
  416.         }
  417.     }
  418.     else {
  419.         #$client->Message (15, "NOTICE: Staff member detected.  Ignoring zone rules.");
  420.     }
  421.    
  422.     if(!defined($qglobals{"HasScribedUse"}))
  423.     {
  424.         quest::setglobal("HasScribedUse", 1, 5, "F");
  425.         if(!$client->HasSpellScribed(7651))
  426.         {
  427.             $client->ScribeSpell(7651, $client->GetFreeSpellBookSlot());
  428.         }
  429.         quest::traindisc(132313);
  430.     }
  431.     if(!$entity_list->GetNPCByNPCTypeID(1000503))
  432.     {
  433.         quest::spawn2(1000503, 0, 0, 0, 0, 0, 0);
  434.     }
  435.    
  436. }
  437.  
  438. sub EVENT_CLICKDOOR {
  439.     if($status >= 80){
  440.         plugin::Doors_Manipulation_EVENT_CLICKDOOR(); # Door Manipulation Plugin
  441.     }
  442. }
  443.  
  444. sub EVENT_SAY {
  445.  
  446.     @args = split(' ', $text);
  447.     if ($status >= 80) {
  448.         plugin::Doors_Manipulation_EVENT_SAY(); # Door Shit
  449.         #@args = split(' ', $text);
  450.         if ($text=~/#dis/i) {
  451.             $client->Message (15, "Distance from " . $client->GetTarget()->GetCleanName() . " to you.");
  452.             $client->Message (15, "X: " . ($client->GetTarget()->GetX() - $client->GetX())  . " Y: " . ($client->GetTarget()->GetY() - $client->GetY())  . "  Z: " . ($client->GetTarget()->GetZ() - $client->GetZ()));
  453.         }
  454.         elsif ($text=~/#stats/i) {
  455.             $client->Message (15, "MinDMG: ".$client->GetTarget()->CastToNPC()->GetMinDMG()." -- MaxDMG: ".$client->GetTarget()->CastToNPC()->GetMaxDMG()."");
  456.             $client->Message (15, "Beard Color: ".$client->GetTarget()->GetBeardColor()." -- Bodytype: ".$client->GetTarget()->GetBodyType()." -- Eye 1 Color ".$client->GetTarget()->GetEyeColor1()." -- Eye 2 Color: ".$client->GetTarget()->GetEyeColor2()."");
  457.             $client->Message (15, "Luclin Face Type: ".$client->GetTarget()->GetLuclinFace()."");
  458.         }
  459.         elsif ($text=~/#gmcon/i) {
  460.             $client->Message (15, "DEBUG: ".$client->CalcEXP(4)."");
  461.             ## $pc->GetLevelCon($npc->GetLevel())
  462.         }
  463.         elsif($args[0]=~/#groundspawn/i){
  464.             if ($args[1]) {
  465.                 my $itemdrop = $args[1];
  466.                 my $CX = $client->GetX();
  467.                 my $CY = $client->GetY();
  468.                 my $CZ = $client->GetZ();
  469.                 my $CH = $client->GetHeading();
  470.                 $connect = plugin::LoadMysql();
  471.                 $sth = $connect->prepare("SELECT idfile FROM items WHERE id = $itemdrop");
  472.                 $sth->execute();
  473.                 my $graphic = $sth->fetchrow_array();
  474.                 $sth = $connect->do("INSERT INTO `ground_spawns` VALUES ('', $zoneid, 0, $CX, $CY, $CZ, $CX, $CY, $CH, '".$graphic."_ACTORDEF', $itemdrop, 1, 'Auto', 300000)");
  475.                 $client->Message(315, "Groundspawn added to $zonesn!");
  476.             }
  477.             else { $client->Message(315,"Groundspawn: Item ID required!"); }
  478.         }
  479.         elsif($args[0]=~/#treespawn/i && $status > 150){
  480.             if ($args[1] && $args[2] && $args[3] && $args[4]) {
  481.                 plugin::InsertStaticTreeProcedure($text, $client);
  482.                 $client->Message(13, "TreeSpawn added to $zonesn at your location!");
  483.             }
  484.             else { $client->Message(13,"Format: #treespawn itemid respawntimer basegrowth addsize"); }
  485.         }
  486.         elsif (($text=~/#gmwho/i) && ($status >= 250)) {
  487.             my %classhash = (
  488.                 1   => "Warrior",
  489.                 2   => "Cleric",
  490.                 3   => "Paladin",
  491.                 4   => "Ranger",
  492.                 5   => "Shadow Knight",
  493.                 6   => "Druid",
  494.                 7   => "Monk",
  495.                 8   => "Bard",
  496.                 9   => "Rogue",
  497.                 10  => "Shaman",
  498.                 11  => "Necromancer",
  499.                 12  => "Wizard",
  500.                 13  => "Magician",
  501.                 14  => "Enchanter",
  502.                 15  => "Beastlord",
  503.                 16  => "Berserker",
  504.             );
  505.             my %racehash = (
  506.                 1   =>  "Human",
  507.                 2   =>  "Babarian",
  508.                 3   =>  "Erudite",
  509.                 4   =>  "Wood Elf",
  510.                 5   =>  "High Elf",
  511.                 6   =>  "Dark Elf",
  512.                 7   =>  "Half Elf",
  513.                 8   =>  "Dwarf",
  514.                 9   =>  "Troll",
  515.                 10  =>  "Ogre",
  516.                 11  =>  "Halfling",
  517.                 12  =>  "Gnome",
  518.                 128 =>  "Iksar",
  519.                 130 =>  "Vah Shir",
  520.                 330 =>  "Froglok",
  521.             );
  522.             my @clientsarray = $entity_list->GetClientList();
  523.             $client->Message (11, "(GM List) Players in Zone:");
  524.             $client->Message (11, "----------------------------------");
  525.             foreach my $singleclient (@clientsarray) {
  526.                 my $clientguildname;
  527.                 my $longip = $singleclient->GetIP();
  528.                 $firstoctet = $longip % 256;
  529.                 $longip -= $firstoctet;
  530.                 $longip /= 256;
  531.                 $secondoctet = $longip % 256;
  532.                 $longip -= $secondoctet;
  533.                 $longip /= 256;
  534.                 $thirdoctet = $longip % 256;
  535.                 $longip -= $thirdoctet;
  536.                 $longip /= 256;
  537.                 if (quest::getguildnamebyid($singleclient->GuildID())) {
  538.                     $clientguildname = "".quest::getguildnamebyid($singleclient->GuildID())."";
  539.                 } else { $clientguildname = "UNGUILDED"; }
  540.                 my $dottedip = "$firstoctet.$secondoctet.$thirdoctet.$longip";
  541.                 my $wholist =   "[".$singleclient->GetLevel()." ".plugin::customclass($singleclient->GetClass(),$singleclient->GetDeity()).
  542.                                 "] ".$singleclient->GetName()." (".$classhash{$singleclient->GetClass()}.") (".
  543.                                 $racehash{$singleclient->GetRace()}.") <".$clientguildname."> [IP: ".$dottedip."]";
  544.                 $client->Message (11, "".$wholist."");
  545.             }
  546.             $client->Message (11, "There are ".scalar (@clientsarray)." players in zone!");
  547.         }
  548.     }
  549.     if ($text=~/^#Update/i && $status < 100) {         
  550.             plugin::GetLeaderboard(%qglobals);
  551.             plugin::ShowLeaderboard("HP");
  552.         }
  553.     if ($args[0]=~/#Leaderboard/i) {
  554.        
  555.         if(!defined($args[1]))
  556.         {
  557.             my %hash = plugin::LeaderboardTypeHash();
  558.             foreach my $type (sort {$a cmp $b} keys %hash) {
  559.                 $client->Message(315, quest::saylink("#leaderboard $type", 1, "Top 10 Players in $type"));
  560.             }
  561.         }
  562.         elsif($args[1] =~ /update/i && $status < 100)
  563.         {
  564.             plugin::GetLeaderboard(%qglobals);
  565.         }
  566.         plugin::ShowLeaderboard(substr($text, 13));
  567.  
  568.     }
  569.    
  570.     if($args[0] =~/^#house/i)
  571.     {
  572.         if($args[1] =~ /check/i)
  573.         {
  574.             $client->SetEntityVariable("DoorCommand", "Info");
  575.             quest::signalwith(1000505, $client->GetID());
  576.         }
  577.         if($args[1] =~ /buy/i)
  578.         {
  579.             $client->SetEntityVariable("DoorCommand", "BuyHouse");
  580.             quest::signalwith(1000505, $client->GetID());
  581.         }
  582.         if($args[1] =~ /purchase/i)
  583.         {
  584.             $client->SetEntityVariable("DoorCommand", "PurchaseHouse");
  585.             quest::signalwith(1000505, $client->GetID());
  586.         }
  587.         if($args[1] =~ /sell/i)
  588.         {
  589.             $client->SetEntityVariable("DoorCommand", "SellHouse");
  590.             quest::signalwith(1000505, $client->GetID());
  591.         }
  592.         if($args[1] =~ /relinquish/i)
  593.         {
  594.             $client->SetEntityVariable("DoorCommand", "RelinquishHouse");
  595.             quest::signalwith(1000505, $client->GetID());
  596.         }
  597.         if($args[1] =~ /payrent/i)
  598.         {
  599.             $client->SetEntityVariable("DoorCommand", "PayRent");
  600.             quest::signalwith(1000505, $client->GetID());
  601.         }
  602.        
  603.     }
  604.    
  605.     if($args[0] =~/^#object/i)
  606.     {
  607.         if(defined($args[3]) && defined($args[2]) && defined($args[1]))
  608.         {
  609.             $client->SetEntityVariable("DoorCommand",  $args[0] . " " . $args[1] . " " . $args[2] . " " . $args[3]);
  610.         }
  611.         elsif(defined($args[1]) && defined($args[2]))
  612.         {
  613.             $client->SetEntityVariable("DoorCommand",  $args[0] . " " . $args[1] . " " . $args[2]);
  614.         }
  615.         elsif(defined($args[1]))
  616.         {
  617.             $client->SetEntityVariable("DoorCommand",  $args[0] . " " . $args[1]);
  618.         }
  619.         else
  620.         {
  621.             $client->SetEntityVariable("DoorCommand",  $args[0]);
  622.         }
  623.         quest::signalwith(1000505, $client->GetID());
  624.     }
  625.  
  626.     if ($args[0] eq "#tree") {         
  627.         if($args[1] =~ /harvest/i)
  628.         {
  629.             $object = $entity_list->GetObjectByID($client->GetEntityVariable("TreeID"));           
  630.             if(defined($object))
  631.             {
  632.                 if($zonesn eq "neighborhood" && !$object->GetEntityVariable("IsStaticTree"))
  633.                 {
  634.                     $client->SetEntityVariable("DoorCommand", "HarvestItem");
  635.                     quest::signalwith(1000505, $client->GetID());
  636.                 }
  637.                 else
  638.                 {
  639.                     if(plugin::IsTree($object->GetItemID()))
  640.                     {
  641.                         my $randomroll = plugin::RandomRange($object->GetEntityVariable("TreeGrowth") / 40, $object->GetEntityVariable("TreeGrowth") / 15);
  642.                         my $randomreturn = plugin::RandomRange(0, 200);
  643.                         if($randomroll < 1)
  644.                         {
  645.                             $client->Message(15, "You feel like you're a poor excuse for a gardener. You get your seed back.");
  646.                             $client->SummonItem($object->GetItemID(), 1);
  647.                         }
  648.                         else
  649.                         {
  650.                             my $rare = 0;
  651.                             if(plugin::GetTreeData($object->GetItemID(), "rareresult"))
  652.                             {
  653.                                 if($randomreturn < plugin::GetTreeData($object->GetItemID(), "rarechance") * 2)
  654.                                 {  
  655.                                     $client->Message(15, "[RARE] You find $randomroll " . plugin::GetTreeData($object->GetItemID(), "raretext") . " in addition to your yield!");
  656.                                     $client->SummonItem(plugin::GetTreeData($object->GetItemID(), "rareresult"), $randomroll);
  657.                                     $rare = 1;
  658.                                 }
  659.                             }
  660.                             if(plugin::GetTreeData($object->GetItemID(), "uncommonresult") && $rare == 0)
  661.                             {
  662.                                 if($randomreturn < plugin::GetTreeData($object->GetItemID(), "uncommonchance") * 2)
  663.                                 {  
  664.                                     $client->Message(15, "[UNCOMMON] You find $randomroll " . plugin::GetTreeData($object->GetItemID(), "uncommontext") . " in addition to your yield!");
  665.                                     $client->SummonItem(plugin::GetTreeData($object->GetItemID(), "uncommonresult"), $randomroll);
  666.                                     $rare = 1;
  667.                                 }
  668.                             }
  669.                            
  670.                             if($rare == 0)
  671.                             {
  672.                                 $client->Message(15, "[COMMON] You harvest the " . plugin::GetTreeData($object->GetItemID(), "plant") .". You gain $randomroll " . plugin::GetTreeData($object->GetItemID(), "text") . " from your yield.");
  673.                                 $client->SummonItem(plugin::GetTreeData($object->GetItemID(), "result"), $randomroll);
  674.                             }
  675.                            
  676.                             if($object->GetEntityVariable("TreeGrowth") >= $randomreturn)
  677.                             {
  678.                                 $client->Message(15, "You dig amongst the dirt and find something extra. It's a miracle of growth!");
  679.                                 $client->SummonItem($object->GetItemID(), 1);
  680.                             }
  681.                         }
  682.                        
  683.                         if(!$object->GetEntityVariable("IsStaticTree"))
  684.                         {
  685.                             plugin::DeleteTreeProcedure($object);
  686.                         }
  687.                         else
  688.                         {
  689.                             quest::signalwith(1000503, $object->GetID());
  690.                         }
  691.                     }
  692.                     else
  693.                     {
  694.                         $client->Message(13, "That's not a tree..");
  695.                     }
  696.                 }
  697.             }
  698.             else
  699.             {
  700.                     $client->Message(13, "Please select a plant to harvest.");
  701.             }
  702.         }
  703.         if($args[1] =~ /pickup/i)
  704.         {  
  705.             $object = $entity_list->GetObjectByID($client->GetEntityVariable("TreeID"));
  706.             if(defined($object))
  707.             {
  708.                 if($zonesn eq "neighborhood")
  709.                 {
  710.                     $client->SetEntityVariable("DoorCommand", "PickupItem");
  711.                     quest::signalwith(1000505, $client->GetID());
  712.                 }
  713.                 else
  714.                 {
  715.                 #   if($object->GetEntityVariable("Owner") != $client->AccountID() && !$client->GetGM())
  716.                 #   {
  717.                 #       $client->Message(13, "Hmm, you think it'd be wise to not mess with another person's property..");
  718.                 #   }
  719.                     if(!plugin::IsTree($object->GetItemID()))
  720.                     {
  721.                         $client->Message(15, "You pick up the house item laying on the ground.");
  722.                         quest::summonitem($object->GetItemID(), 1);
  723.                         plugin::DeleteTreeProcedure($object);
  724.                     }
  725.                     else
  726.                     {
  727.                         $client->Message(13, "That's a plant. Try harvesting it.");
  728.                     }
  729.                 }
  730.             }
  731.             else
  732.             {
  733.                     $client->Message(13, "Please select a plant to harvest.");
  734.             }
  735.         }
  736.         elsif($args[1] =~ /check/i)
  737.         {
  738.             $object = $entity_list->GetObjectByID($client->GetEntityVariable("TreeID"));
  739.             if(defined($object))
  740.             {
  741.                     $client->Message(15, "You tend to your plant.");
  742.                     $client->Message(15, " :: Water:" . $object->GetEntityVariable("TreeWater"));
  743.                     $client->Message(15, " :: Growth:" . $object->GetEntityVariable("TreeGrowth"));
  744.             }
  745.             else
  746.             {
  747.                 $client->Message(13, "Please select a plant to check.");
  748.             }
  749.         }
  750.         elsif($args[1] =~ /clickeffect/i)
  751.         {
  752.             $object = $entity_list->GetObjectByID($client->GetEntityVariable("TreeID"));
  753.             if(defined($object))
  754.             {
  755.                 if($client->AccountID() == $object->GetEntityVariable("Owner"))
  756.                 {
  757.                     if(plugin::HasEffect($object->GetItemID()) || $object->GetEntityVariable("ClickEffect"))
  758.                     {
  759.                         if(plugin::HasEffect($object->GetItemID()) && defined $qglobals{"Reuse" . $object->GetItemID()})
  760.                         {
  761.                             if(plugin::GetEffectData($object->GetItemID(), "reuse"))
  762.                             {
  763.                                 if(time() - $qglobals{"Reuse" . $object->GetItemID()} < plugin::GetEffectData($object->GetItemID(), "reuse"))
  764.                                 {
  765.                                     $client->Message(13, "Reuse timer not expired for the effect " . plugin::GetEffectData($object->GetItemID(), "text") . ".");
  766.                                     return 0;  
  767.                                 }
  768.                             }
  769.                         }
  770.                         $client->Message(15, "You activate the ability " . (plugin::HasEffect($object->GetItemID()) ? plugin::GetEffectData($object->GetItemID(), "text") : "that is on" . " on the object!"));
  771.                         #$client->Message(15, plugin::HasEffect($object->GetItemID()) ? plugin::GetEffectData($object->GetItemID(), "spell_id") : (defined($object->GetEntityVariable("ClickEffect")) ? $object->GetEntityVariable("ClickEffect") : 0));
  772.                         $client->SpellFinished(plugin::HasEffect($object->GetItemID()) ? plugin::GetEffectData($object->GetItemID(), "spell_id") : (defined($object->GetEntityVariable("ClickEffect")) ? $object->GetEntityVariable("ClickEffect") : 0), $client);
  773.                        
  774.                         if(plugin::HasEffect($object->GetItemID()))
  775.                         {
  776.                             if(defined(plugin::GetEffectData($object->GetItemID(), "reuse")))
  777.                             {
  778.                                 quest::setglobal("Reuse" . $object->GetItemID(), time(), 5, "F");
  779.                             }
  780.                         }
  781.                     }
  782.                 }
  783.                 else
  784.                 {
  785.                     $client->Message(13, "This isn't yours to activate! Please select an object to activate that is on your plot.")
  786.                 }
  787.             }
  788.             else
  789.             {
  790.                 $client->Message(13, "Please select an object to activate that is on your plot.");
  791.             }
  792.         }
  793.         elsif($args[1] =~ /water/i)
  794.         {
  795.             $object = $entity_list->GetObjectByID($client->GetEntityVariable("TreeID"));
  796.             if(defined($object))
  797.             {
  798.                 $client->Message(15, "You kneel beside the plant to water it...");
  799.                 $slot = plugin::check_hasitem_inslot($client, 2046);
  800.                
  801.                 if($slot != 65535)
  802.                 {
  803.                     $client->DeleteItemInInventory($slot, 1, 1);
  804.                     $client->SummonItem(16598, 1);
  805.                     $total = $object->GetEntityVariable("TreeWater") + 1;
  806.                     $client->Message(15, "... and the soil absorbs the water thirstily! Moisture Content: $total");
  807.                     $object->SetEntityVariable("TreeWater", $object->GetEntityVariable("TreeWater") + 1);
  808.                     plugin::UpdateTreeProcedure($object);                  
  809.                 }
  810.                 else
  811.                 {
  812.                     $client->Message(15, "... but you don't have a bottle of water!");
  813.                 }
  814.             }
  815.             else
  816.             {
  817.                 $client->Message(13, "Please select a plant to check.");
  818.             }
  819.         }
  820.     }
  821.     if($text=~/#gmzone/i){  
  822.         plugin::SendToInstance("public", "overthere", 1, 1836, 3098, -50, "GM_Zone3", 604800);  # Send to Overthere for Weapons/Spells Preview
  823.     }
  824.         if ($text =~/^#Online Month$/i)
  825.         {
  826.             my $GET_SECONDS     = (60 * 60 * 24 * 30);  # 1 Month (Minutes)
  827.             my $GET_MINUTES     = $GET_SECONDS / 60;    # 1 Month (Seconds)
  828.             my $GET_ONLINE_IP   = GET_IP_ONLINE($GET_MINUTES);
  829.             my $GET_ONLINE_CHAR = GET_PLAYERS_ONLINE($GET_SECONDS);
  830.             #$client->Message(2, "IP Log Online Month: $GET_ONLINE_IP");
  831.             $client->Message(2, "Players online this month: $GET_ONLINE_CHAR");
  832.         }
  833.  
  834.         if ($text =~/^#Online Week$/i)
  835.         {
  836.             my $GET_SECONDS     = (60 * 60 * 24 * 7);   # 1 Week (Minutes)
  837.             my $GET_MINUTES     = $GET_SECONDS / 60;    # 1 Week (Seconds)
  838.             my $GET_ONLINE_IP   = GET_IP_ONLINE($GET_MINUTES);
  839.             my $GET_ONLINE_CHAR = GET_PLAYERS_ONLINE($GET_SECONDS);
  840.             #$client->Message(2, "IP Log Online Week: $GET_ONLINE_IP");
  841.             $client->Message(2, "Players online this week: $GET_ONLINE_CHAR");
  842.         }
  843.  
  844.         if ($text =~/^#Online Today$/i)
  845.         {
  846.             my $GET_SECONDS     = (60 * 60 * 24 * 1);   # 1 Day (Minutes)
  847.             my $GET_MINUTES     = $GET_SECONDS / 60;    # 1 Day (Seconds)
  848.             my $GET_ONLINE_IP   = GET_IP_ONLINE($GET_MINUTES);
  849.             my $GET_ONLINE_CHAR = GET_PLAYERS_ONLINE($GET_SECONDS);
  850.             #$client->Message(2, "IP Log Online Today: $GET_ONLINE_IP");
  851.             $client->Message(2, "Players online today: $GET_ONLINE_CHAR");
  852.         }
  853.  
  854.         if ($text =~/^#Online 30$/i)
  855.         {
  856.             my $GET_SECONDS     = (30 * 60 * 1 * 1);    # 30 Minutes (Minutes)
  857.             my $GET_MINUTES     = $GET_SECONDS / 60;    # 30 Minutes (Seconds)
  858.             my $GET_ONLINE_IP   = GET_IP_ONLINE($GET_MINUTES);
  859.             my $GET_ONLINE_CHAR = GET_PLAYERS_ONLINE($GET_SECONDS);
  860.             #$client->Message(2, "IP Log Online 30 Minutes: $GET_ONLINE_IP");
  861.             $client->Message(2, "Players online in the last 30 minutes: $GET_ONLINE_CHAR");
  862.         }
  863.         if ($text=~/#namepet/i) {
  864.     my $pet_ent = $entity_list->GetMobByID($client->GetPetID());
  865.    
  866.     my @arg = split(" ", $text);
  867.    
  868.     my $pet_name = fixname($arg[1]);
  869.    
  870.     if (length($pet_name) > 10 || length($pet_name) < 3) {
  871.         $client->Message(13, "Pet name invalid!");
  872.         return;
  873.     }
  874.    
  875.     if ($pet_ent) {
  876.         $pet_ent->TempName($pet_name);
  877.     }
  878. }
  879.  
  880.     }
  881.  
  882.  
  883.  
  884. sub EVENT_LOOT {
  885.     if ($looted_id == 4043) {
  886.     quest::settimer("cool4043", 900);
  887.     }
  888.     if (!defined $qglobals{"looteditems"}) {
  889.         quest::setglobal("looteditems",1,5,"F");
  890.     }
  891.     else {
  892.         quest::setglobal("looteditems",$qglobals{"looteditems"}+1,5,"F");
  893.     }
  894. }
  895.  
  896. sub EVENT_LEVEL_UP {
  897.     if ($status < 150) {
  898.         if ((defined $qglobals{"noobie"}) && ($qglobals{"noobie"} >= 1)) {
  899.             quest::gmsay(   "Rejoice, $name is now a level $ulevel ".plugin::customclass($client->GetClass(),$client->GetDeity()).
  900.                             "!", 335, 1, 0, 0);
  901.         }
  902.     }
  903. }  
  904.  
  905. sub EVENT_TRADE {
  906.     if (!defined $qglobals{"tradeditems"}) {
  907.         quest::setglobal("tradeditems",1,5,"F");
  908.     }
  909.     else {
  910.         quest::setglobal("tradeditems",$qglobals{"tradeditems"}+1,5,"F");
  911.     }
  912. }
  913.  
  914. sub EVENT_SIGNAL {
  915.     if ($signal == 4398) {
  916.         quest::popup ("Blank Map",
  917.             "<br> <br>You unroll your map and look down at it. Would you like to mark your location?<br>
  918.             <br> <br>",50010,1); ## global player signals begin with 500 to avoid conflict with zone specific player.pl
  919.     }
  920. }
  921.  
  922. sub EVENT_POPUPRESPONSE {
  923.     my $space = " ";
  924.     my $xvar = int($client->GetX());
  925.     my $x = int($client->GetX());
  926.     my $yvar = int($client->GetY());
  927.     my $y = int($client->GetY());
  928.     my $zvar = int($client->GetZ());
  929.     my $z = int($client->GetZ());
  930.     $global = "$xvar$space$yvar$space$zvar$space$zoneid";
  931.    
  932.     if ($popupid == 50010) {
  933.     $client->Message(15,"You mark a large red X on your map.");
  934.     $client->SetGlobal("Alt Bind", $global, 5, "F");
  935.     plugin::DeleteItem(4398);
  936.     quest::summonitem(4149);
  937.     }
  938. }
  939.  
  940.  
  941. sub EVENT_PLAYER_PICKUP
  942. {
  943.     $object = $entity_list->GetObjectByID($picked_up_entity_id);
  944.    
  945.    
  946.     if($client->GetGM())
  947.     {
  948.         $client->Message(15, "[GM] This is model " . $object->GetModelName());
  949.     }
  950.    
  951.     if(plugin::IsTree($object->GetItemID()))
  952.     {
  953.         #$object = $entity_list->GetObjectByID($picked_up_entity_id);
  954.         if(defined($object))
  955.         {
  956.             $client->Message(15, "This is a " . plugin::GetTreeData($object->GetItemID(), "plant") . " plant. What would you like to do with it?");
  957.             $client->Message(15, quest::saylink("#tree harvest", 1, "   ::Harvest"));
  958.             $client->Message(15, quest::saylink("#tree check", 1, "   ::Check"));
  959.             $client->Message(15, quest::saylink("#tree water", 1, "   ::Water"));
  960.             $client->SetEntityVariable("TreeID", $object->GetID());
  961.         }
  962.         return 1;
  963.     }
  964.     elsif(plugin::HasRadius($object->GetItemID()))
  965.     {
  966.         $client->Message(15, "This is a " . plugin::GetRadiusData($object->GetItemID(), "name") . ".");
  967.         if($object->GetEntityVariable("WardOwner"))
  968.         {
  969.             if(!$entity_list->GetClientByID($object->GetEntityVariable("WardOwner")))
  970.             {
  971.                 $object->Depop();
  972.             }
  973.        
  974.         }
  975.         return 1;
  976.     }
  977.     elsif(defined($object->GetEntityVariable("DBID")) && !defined($object->GetEntityVariable("UpLevel")))
  978.     {
  979.         $client->Message(15, "This is a house item. What would you like to do with it?");
  980.         $client->Message(15, quest::saylink("#tree pickup", 1, "   ::Pickup"));
  981.         if(plugin::HasEffect($object->GetItemID()) || $object->GetEntityVariable("ClickEffect"))
  982.         {
  983.             $client->Message(15, quest::saylink("#tree clickeffect", 1, "   ::Activate Effect"));
  984.         }
  985.         $client->SetEntityVariable("TreeID", $object->GetID());
  986.         $client->SetEntityVariable("Effect", $object->GetID());
  987.         if($zonesn eq "neighborhood" && $object->GetItemID() != 1801)
  988.         {
  989.             $client->Message(15, quest::saylink("#object", 1, "   ::Neighborhood Object Commands"));
  990.         }
  991.         return 1;
  992.     }
  993.     #$client->Message(13, "Is your client locking up?");
  994.     return 0;
  995. }
  996.  
  997. sub EVENT_CAST
  998. {
  999.  
  1000.  
  1001.     if($spell_id == 7651)
  1002.     {
  1003.    
  1004.         if($zonesn eq "neighborhood" && !plugin::HasRadius($client->GetEntityVariable("PlacingItemID")))
  1005.         {
  1006.             if($client->GetEntityVariable("PlacingItemID") != 12673)
  1007.             {
  1008.             $client->SetEntityVariable("DoorCommand", "PlaceItem");
  1009.             quest::signalwith(1000505, $client->GetID());
  1010.             }
  1011.         }
  1012.         else
  1013.         {
  1014.             if(plugin::HasRadius($client->GetEntityVariable("PlacingItemID")))
  1015.             {
  1016.                 my $object = $entity_list->GetObjectByID($client->GetEntityVariable("WardID" . $client->GetEntityVariable("PlacingItemID")));
  1017.                 my $radiusobj = $client->GetEntityVariable("PlacingItemID");
  1018.                 if(plugin::GetRadiusData($radiusobj, "reqclass") != 0 && plugin::GetRadiusData($radiusobj, "reqclass") != $client->GetClass())
  1019.                 {
  1020.                     if(plugin::GetRadiusData($radiusobj, "errmsgclass") && plugin::GetRadiusData($radiusobj, "errmsgclass") ne "")
  1021.                     {
  1022.                         $client->Message(15, plugin::GetRadiusData($radiusobj, "errmsgclass"));
  1023.                     }
  1024.                 }
  1025.                 elsif(plugin::GetRadiusData($radiusobj, "reqdeity") != 0 && plugin::GetRadiusData($radiusobj, "reqdeity") != $client->GetDeity())
  1026.                 {
  1027.                     if(plugin::GetRadiusData($radiusobj, "errmsgdeity") && plugin::GetRadiusData($radiusobj, "errmsgdeity") ne "")
  1028.                     {
  1029.                         $client->Message(15, plugin::GetRadiusData($radiusobj, "errmsgdeity"));
  1030.                     }
  1031.                 }
  1032.                 elsif(plugin::GetRadiusData($radiusobj, "reqlevel") != 0 && $client->GetLevel() < plugin::GetRadiusData($radiusobj, "reqlevel"))
  1033.                 {
  1034.                     if(plugin::GetRadiusData($radiusobj, "errmsglevel") && plugin::GetRadiusData($radiusobj, "errmsglevel") ne "")
  1035.                     {
  1036.                         $client->Message(15, plugin::GetRadiusData($radiusobj, "errmsglevel"));
  1037.                     }
  1038.                 }
  1039.                 elsif(defined($object))
  1040.                 {
  1041.                     if(plugin::GetRadiusData($radiusobj, "errmsgplaced") && plugin::GetRadiusData($radiusobj, "errmsgplaced") ne "")
  1042.                     {
  1043.                         $client->Message(15, plugin::GetRadiusData($radiusobj, "errmsgplaced"));
  1044.                     }
  1045.                 }
  1046.                 else
  1047.                 {
  1048.                     $slot = plugin::check_hasitem_inslot($client, $client->GetEntityVariable("PlacingItemID"));
  1049.                     if($slot != 65535)
  1050.                     {
  1051.                         $client->DeleteItemInInventory($slot, 1, 1);
  1052.                         $spawnid = quest::creategroundobject($client->GetEntityVariable("PlacingItemID"), $client->GetTargetRingX(), $client->GetTargetRingY(), $client->GetTargetRingZ(), $client->GetHeading(), plugin::GetRadiusData($radiusobj, "expire")); #This spawns the ward, which lasts 60 seconds. Stores in $spawnid
  1053.                         $object = $entity_list->GetObjectByID($spawnid);
  1054.                         $object->SetEntityVariable("WardOwner", $client->GetID());
  1055.                         $object->SetSize($client->GetEntityVariable("PlacingSize") ? $client->GetEntityVariable("PlacingSize") : 100);
  1056.                         quest::settimer("WardTimer" . $client->GetEntityVariable("PlacingItemID"), plugin::GetRadiusData($radiusobj, "timer")); #Starts a timer with string "WardTimer" as $timer
  1057.                         my $triggered = 0;
  1058.                         if(plugin::GetRadiusData($radiusobj, "npcflag"))
  1059.                         {
  1060.                             #do stuff
  1061.                             my @npcs = $entity_list->GetNPCList();
  1062.                             foreach my $singlenpc (@npcs)
  1063.                             {
  1064.                                 my $rad = plugin::GetRadiusData($radiusobj, "radius");
  1065.                                 if(int($object->GetX()) > int($singlenpc->GetX())-$rad && int($object->GetX()) < int($singlenpc->GetX())+$rad &&
  1066.                                 int($object->GetY()) > int($singlenpc->GetY())-$rad && int($object->GetY()) < int($singlenpc->GetY())+$rad)
  1067.                               {                
  1068.                                 if(plugin::GetRadiusData($radiusobj, "remove"))
  1069.                                 {
  1070.                                     $triggered = 1;
  1071.                                 }
  1072.                                 if(plugin::GetRadiusData($radiusobj, "spell_id"))
  1073.                                 {
  1074.                                     $client->SpellFinished(plugin::GetRadiusData($radiusobj, "spell_id"), $singlenpc);
  1075.                                 }
  1076.                                
  1077.                                 if(plugin::GetRadiusData($radiusobj, "spell_id2"))
  1078.                                 {
  1079.                                     $client->SpellFinished(plugin::GetRadiusData($radiusobj, "spell_id2"), $singlenpc);
  1080.                                 }
  1081.                                
  1082.                                 if(plugin::GetRadiusData($radiusobj, "spell_id3"))
  1083.                                 {
  1084.                                     $client->SpellFinished(plugin::GetRadiusData($radiusobj, "spell_id3"), $singlenpc);
  1085.                                 }
  1086.                               }
  1087.                               else
  1088.                               {
  1089.                                     #   quest::gmsay("No radius!", 15);
  1090.                               }
  1091.                             }
  1092.                         }
  1093.                         else
  1094.                         {
  1095.                             my @clients = $entity_list->GetClientList();
  1096.                             foreach my $singleclient (@clients)
  1097.                             {
  1098.                                 my $rad = plugin::GetRadiusData($radiusobj, "radius");
  1099.                                 if(int($object->GetX()) > int($singleclient->GetX())-$rad && int($object->GetX()) < int($singleclient->GetX())+$rad &&
  1100.                                 int($object->GetY()) > int($singleclient->GetY())-$rad && int($object->GetY()) < int($singleclient->GetY())+$rad)
  1101.                               {
  1102.                                 if(plugin::GetRadiusData($radiusobj, "remove"))
  1103.                                 {
  1104.                                     $triggered = 1;
  1105.                                 }
  1106.                                
  1107.                                 if(plugin::GetRadiusData($radiusobj, "spell_id"))
  1108.                                 {
  1109.                                     $client->SpellFinished(plugin::GetRadiusData($radiusobj, "spell_id"), $singleclient);
  1110.                                 }
  1111.                                
  1112.                                 if(plugin::GetRadiusData($radiusobj, "spell_id2"))
  1113.                                 {
  1114.                                     $client->SpellFinished(plugin::GetRadiusData($radiusobj, "spell_id2"), $singleclient);
  1115.                                 }
  1116.                                
  1117.                                 if(plugin::GetRadiusData($radiusobj, "spell_id3"))
  1118.                                 {
  1119.                                     $client->SpellFinished(plugin::GetRadiusData($radiusobj, "spell_id3"), $singleclient);
  1120.                                 }
  1121.                                
  1122.                               }
  1123.                               else
  1124.                               {
  1125.                                     #quest::gmsay("No radius!", 15);
  1126.                               }
  1127.                             }
  1128.                         }
  1129.                         if($triggered)
  1130.                         {
  1131.                             $object->Depop();
  1132.                             quest::stoptimer("WardTimer" . $client->GetEntityVariable("PlacingItemID"));
  1133.                         }
  1134.                        
  1135.                         $client->SetEntityVariable("WardID" . $client->GetEntityVariable("PlacingItemID"), $spawnid);
  1136.                     }
  1137.                     else
  1138.                     {
  1139.                     $client->Message(15, "You have run out of " . plugin::GetRadiusData($radiusobj, "name"). "!");
  1140.                     }
  1141.                 }
  1142.             }
  1143.             else
  1144.             {
  1145.                 if(!defined($client->GetEntityVariable("PlacingItemID")))
  1146.                 {
  1147.                 $client->Message(15, "Please select an item to use in the world before casting this ability.");
  1148.                 }
  1149.                 else
  1150.                 {
  1151.                     $slot = plugin::check_hasitem_inslot($client, $client->GetEntityVariable("PlacingItemID"));
  1152.                     if (plugin::CheckTreeRadius($client->GetTargetRingX(), $client->GetTargetRingY())) {
  1153.                         $client->Message(15, "There is an object too close, choose another location.");
  1154.                         return;
  1155.                     }
  1156.                    
  1157.                     if($slot != 65535)
  1158.                     {
  1159.                         $client->DeleteItemInInventory($slot, 1, 1);
  1160.                        
  1161.                         $spawnid = quest::creategroundobject($client->GetEntityVariable("PlacingItemID"), $client->GetTargetRingX(), $client->GetTargetRingY(), $client->GetTargetRingZ(), $client->GetHeading(), 0);   #62671 original ID
  1162.                         #quest::gmsay("SpawnID is $spawnid", 15);
  1163.                         $object = $entity_list->GetObjectByID($spawnid);
  1164.                         $object->SetSize(($client->GetEntityVariable("PlacingGrowth") / 5) + $client->GetEntityVariable("PlacingSize"));
  1165.                         $object->SetSolidType(0);
  1166.                         $object->SetEntityVariable("TreeGrowth", $client->GetEntityVariable("PlacingGrowth") / 5);
  1167.                         $object->SetEntityVariable("TreeWater", 0);
  1168.                         $object->SetEntityVariable("TreeDisease", 0);
  1169.                         $object->SetEntityVariable("TreeSize", $client->GetEntityVariable("PlacingSize"));
  1170.                         $object->SetEntityVariable("PlacingEffect", (plugin::HasEffect($object->GetItemID()) ? plugin::GetEffectData($object->GetItemID(), "spell_id") : (defined($object->GetEntityVariable("ClickEffect")) ? $object->GetEntityVariable("ClickEffect") : 0)));
  1171.                         $object->SetEntityVariable("Owner", $client->AccountID());
  1172.                         plugin::InsertTreeProcedure($object);
  1173.                         quest::signalwith(1000503,$spawnid);
  1174.                     }
  1175.                     else
  1176.                     {
  1177.                         $client->Message(15, "You need to highlight a useable item!");
  1178.                     }
  1179.                 }
  1180.             }
  1181.         }
  1182.     }
  1183. }
  1184.  
  1185.  
  1186.  
  1187. sub GET_PLAYERS_ONLINE
  1188. {
  1189.     my $GET_ONLINE      = 0;
  1190.     my $connect         = LoadMySQLConnection();
  1191.     my $query           =   "
  1192.                             SELECT count(last_login)
  1193.                             FROM character_data
  1194.                             WHERE UNIX_TIMESTAMP() - ($_[0]) < last_login
  1195.                             ";
  1196.     # $client->Message(7, "$query");
  1197.     my $query_handle = $connect->prepare($query);
  1198.     $query_handle->execute();
  1199.     if ($query_handle->rows)
  1200.     {
  1201.         my $ref     = $query_handle->fetchrow_hashref();
  1202.         $GET_ONLINE = $ref->{'count(last_login)'};
  1203.     }
  1204.  
  1205.     $query_handle->finish();
  1206.     $connect->disconnect();
  1207.     return $GET_ONLINE;
  1208. } # End GET_PLAYERS_ONLINE
  1209.  
  1210.  
  1211. sub GET_IP_ONLINE
  1212. {
  1213.     my $GET_ONLINE      = 0;
  1214.     my $connect         = LoadMySQLConnection();
  1215.     my $query           =   "
  1216.                             SELECT count(lastused)
  1217.                             FROM account_ip
  1218.                             WHERE TIMESTAMPDIFF(MINUTE, lastused, NOW()) < $_[0]
  1219.                             ";
  1220.     # $client->Message(7, "$query");
  1221.     my $query_handle = $connect->prepare($query);
  1222.     $query_handle->execute();
  1223.     if ($query_handle->rows)
  1224.     {
  1225.         my $ref     = $query_handle->fetchrow_hashref();
  1226.         $GET_ONLINE = $ref->{'count(lastused)'};
  1227.     }
  1228.     $query_handle->finish();
  1229.     $connect->disconnect();
  1230.     return $GET_ONLINE;
  1231. } # End GET_IP_ONLINE
  1232.  
  1233.  
  1234. sub LoadMySQLConnection
  1235. {
  1236.     use DBI;
  1237.     use DBD::mysql;
  1238.     # GET DB, USER, AND PASS FROM CONFIG FILE
  1239.     my $confile = "eqemu_config.xml"; #default config file
  1240.     # open(F, "<$confile") or die "Unable to open config: $confile\n";
  1241.     open(F, "<$confile") or quest::gmsay("GM: sub LoadMySQLConnection() 'open' FAILED !!!!", 15, 1);
  1242.     my $indb = 0;
  1243.  
  1244.     while(<F>)
  1245.     {
  1246.         s/\r//g;
  1247.         if(/<database>/i)                       { $indb = 1; }
  1248.         next unless($indb == 1);
  1249.         if(/<\/database>/i)                     { $indb = 0; last; }
  1250.         if(/<host>(.*)<\/host>/i)               { $host = $1; }
  1251.         elsif(/<username>(.*)<\/username>/i)    { $user = $1; }
  1252.         elsif(/<password>(.*)<\/password>/i)    { $pass = $1; }
  1253.         elsif(/<db>(.*)<\/db>/i)                { $db   = $1; }
  1254.     }
  1255.  
  1256.     # DATA SOURCE NAME
  1257.     my $dsn = "dbi:mysql:$db:localhost:3306";
  1258.     # PERL DBI CONNECT
  1259.     my $connect = DBI->connect($dsn, $user, $pass) or quest::gmsay("GM: sub LoadMySQLConnection() 'connect' FAILED !!!!", 15, 1);
  1260.     return $connect;
  1261. } # End LoadMySQLConnection()
  1262.  
  1263.  
  1264.  
  1265. sub EVENT_DISCONNECT {
  1266.     quest::stoptimer ("activitycheck$charid");
  1267. }
  1268.  
  1269. sub fixname {
  1270.    local $_  = shift;
  1271.    s/[^A-Za-z]+//g;
  1272.    return $_;
  1273. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement