Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #NOTE!
- #Sync this between treecontroller.pl and this file!!
- sub EVENT_CONNECT {
- if (($status == 1)) {
- quest::settimer("Leaderboard", 3);
- quest::setglobal("TokenCounter", 0, 5, "F");
- }
- if ($client->GetLanguageSkill(0) < 100) {
- quest::setlanguage(0, 100);
- }
- if ($client->GetSkill(40) < 200) {
- quest::setskill(40, 200);
- }
- if (plugin::HasItem(64513)) {
- plugin::Message("You still have some hot coffee, it will cool down soon!");
- quest::settimer("Cool13501", 900);
- }
- if (plugin::HasItem(4045)) {
- plugin::Message("The silver will harden soon.");
- quest::settimer("cool13529", 1800);
- }
- if (plugin::HasItem(4043)) {
- plugin::Message("The blazing embers will cool soon.");
- quest::settimer("cool4043", 900);
- }
- }
- sub EVENT_ZONE {
- if ($client->GetHP() < 1) {
- my @killverbs = ("slain","annihilated","destroyed","wrecked","laid to rest","vanquished","defeated","ended","totaled","killed","snuffed out","beaten","knocked off");
- quest::gmsay("Alas, $name has been ".$killverbs[quest::ChooseRandom(0..$#killverbs)]." by ".$client->GetTarget()->GetCleanName()."!", 335, 1, 0, 0);
- if (!defined $qglobals{"deaths"}) {
- quest::setglobal("deaths",1,5,"F");
- }
- else {
- quest::setglobal("deaths",$qglobals{"deaths"}+1,5,"F");
- }
- }
- }
- sub EVENT_TIMER {
- my @array = split(' ', $qglobals{"Alt Bind"});
- if ($timer eq "gotoclz") {
- quest::stoptimer ("gotoclz");
- $client->Message (12, "Please wait while you are moved.");
- quest::movepc(190,0,0,0,0);
- }
- elsif ($timer eq "gotojail") {
- quest::stoptimer ("gotojail");
- #$client->Message (12, "You are being moved due to suspect of running an incompatible and/or unpatched client!");
- #quest::movepc(45,0,0,0,220);
- }
- elsif ($timer eq "Zoned") {
- quest::stoptimer("Zoned");
- if ($zonesn=~/Nexus/i && !defined $qglobals{"NexusBind"}) {
- quest::selfcast(35);
- quest::setglobal("NexusBind", 1, 5, "F");
- }
- }
- elsif ($timer eq "Leaderboard") {
- quest::stoptimer("Leaderboard");
- my %hash = plugin::LeaderboardTypeHash();
- foreach my $type (sort {$a cmp $b} keys %hash) {
- $client->Message(315, quest::saylink("#leaderboard $type", 1, "Top 10 Players in $type"));
- }
- if ($status < 100) {
- plugin::GetLeaderboard(%qglobals);
- }
- quest::settimer("Leaderboard", 3600);
- }
- elsif ($timer eq "Cool13501") {
- my $amount = plugin::CountItem(64513);
- quest::stoptimer("Cool13501");
- plugin::Message("Your coffee has cooled down and turned into " . quest::varlink(3239) . "!");
- plugin::DeleteItem(64513, $amount);
- quest::summonitem(3239, $amount);
- }
- elsif ($timer eq "cool4043") {
- my $amount = plugin::CountItem(4043);
- quest::stoptimer("cool4043");
- plugin::Message("The embers stop burning.");
- plugin::DeleteItem(4043, $amount);
- quest::summonitem(4044, $amount);
- }
- elsif ($timer eq "cool13529") {
- my $amount = plugin::CountItem(4045);
- quest::stoptimer("cool13529");
- plugin::Message("The silver hardens.");
- plugin::DeleteItem(4045, $amount);
- quest::summonitem(33789, $amount);
- }
- if ($timer eq "TokenTimer") {
- quest::setglobal("TokenCounter", ($qglobals{"TokenCounter"} + 1), 5, "F");
- 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
- if ( $qglobals{"TokenCounter"} == 60 ) {
- $client->AddCrystals(1, 0);
- $client->Message (15, "You've earned a loyalty token!");
- quest::setglobal("TokenCounter", 0, 4, "F");
- }
- }
- elsif ($timer =~ /WardTimer/i) { #Ward Timer for placable object
- #We don't stop this timer unless the object ceases to exist
- my @arg = split('WardTimer', $timer);
- my $id = $arg[1];
- #quest::gmsay("tick tock $id", 15);
- $object = $entity_list->GetObjectByID($client->GetEntityVariable("WardID" . $id));
- if(defined($object) && plugin::HasRadius($id))
- {
- my $triggered = 0;
- if(plugin::GetRadiusData($id, "npcflag"))
- {
- #do stuff
- my @npcs = $entity_list->GetNPCList();
- foreach my $singlenpc (@npcs)
- {
- my $rad = plugin::GetRadiusData($id, "radius");
- if(int($object->GetX()) > int($singlenpc->GetX())-$rad && int($object->GetX()) < int($singlenpc->GetX())+$rad &&
- int($object->GetY()) > int($singlenpc->GetY())-$rad && int($object->GetY()) < int($singlenpc->GetY())+$rad && !$singlenpc->IsPet())
- {
- if(plugin::GetRadiusData($id, "remove"))
- {
- $triggered = 1;
- }
- if(plugin::GetRadiusData($id, "spell_id"))
- {
- $client->SpellFinished(plugin::GetRadiusData($id, "spell_id"), $singlenpc);
- }
- if(plugin::GetRadiusData($id, "spell_id2"))
- {
- $client->SpellFinished(plugin::GetRadiusData($id, "spell_id2"), $singlenpc);
- }
- if(plugin::GetRadiusData($id, "spell_id3"))
- {
- $client->SpellFinished(plugin::GetRadiusData($id, "spell_id3"), $singlenpc);
- }
- }
- else
- {
- # quest::gmsay("No radius!", 15);
- }
- }
- }
- else
- {
- my @clients = $entity_list->GetClientList();
- foreach my $singleclient (@clients)
- {
- my $rad = plugin::GetRadiusData($id, "radius");
- if(int($object->GetX()) > int($singleclient->GetX())-$rad && int($object->GetX()) < int($singleclient->GetX())+$rad &&
- int($object->GetY()) > int($singleclient->GetY())-$rad && int($object->GetY()) < int($singleclient->GetY())+$rad)
- {
- if(plugin::GetRadiusData($id, "remove"))
- {
- $triggered = 1;
- }
- if(plugin::GetRadiusData($id, "spell_id"))
- {
- $client->SpellFinished(plugin::GetRadiusData($id, "spell_id"), $singleclient);
- }
- if(plugin::GetRadiusData($id, "spell_id2"))
- {
- $client->SpellFinished(plugin::GetRadiusData($id, "spell_id2"), $singleclient);
- }
- if(plugin::GetRadiusData($id, "spell_id3"))
- {
- $client->SpellFinished(plugin::GetRadiusData($id, "spell_id3"), $singleclient);
- }
- }
- else
- {
- #quest::gmsay("No radius!", 15);
- }
- }
- }
- if($triggered)
- {
- $object->Depop();
- quest::stoptimer($timer);
- }
- }
- else #stop the timer
- {
- #quest::gmsay("No Timer!", 15);
- quest::stoptimer($timer);
- }
- }
- }
- sub EVENT_DISCOVER_ITEM {
- if ($status < 150) {
- quest::gmsay("$name has discovered " . quest::varlink($itemid) . ".", 335, 1, 0, 0);
- }
- if (!defined $qglobals{"discovereditems"}) {
- quest::setglobal("discovereditems",1,5,"F");
- }
- else {
- quest::setglobal("discovereditems",$qglobals{"discovereditems"}+1,5,"F");
- }
- }
- sub EVENT_FORAGE_FAILURE {
- if (!defined $qglobals{"foragefails"}) {
- quest::setglobal("foragefails",1,5,"F");
- }
- else {
- quest::setglobal("foragefails",$qglobals{"foragefails"}+1,5,"F");
- }
- }
- sub EVENT_FORAGE_SUCCESS {
- if (!defined $qglobals{"foragesuccesses"}) {
- quest::setglobal("foragesuccesses",1,5,"F");
- }
- else {
- quest::setglobal("foragesuccesses",$qglobals{"foragesuccesses"}+1,5,"F");
- }
- }
- sub EVENT_DUEL_LOSE {
- if (!defined $qglobals{"duelslost"}) {
- quest::setglobal("duelslost",1,5,"F");
- }
- else {
- quest::setglobal("duelslost",$qglobals{"duelslost"}+1,5,"F");
- }
- }
- sub EVENT_DUEL_WIN {
- if (!defined $qglobals{"duelswon"}) {
- quest::setglobal("duelswon",1,5,"F");
- }
- else {
- quest::setglobal("duelswon",$qglobals{"duelswon"}+1,5,"F");
- }
- }
- sub EVENT_COMBINE_SUCCESS {
- my @skillidarray = (59,60,61,63,64,65,68,69);
- my @skillnames = ("Alchemy","Cooking","Tailoring","Blacksmithing","Woodworking","Brewing","Jewelcrafting","Crafting");
- my $counter = 0;
- foreach $individualskill (@skillidarray) {
- $skillglobal = "skill".$individualskill."";
- if (!defined $qglobals{$skillglobal}) {
- quest::setglobal($skillglobal, $client->GetRawSkill($individualskill), 5, "F");
- }
- else {
- if ($client->GetRawSkill($individualskill) > $qglobals{$skillglobal}) {
- quest::setglobal($skillglobal, $client->GetRawSkill($individualskill), 5, "F");
- if (($client->GetRawSkill($individualskill) % 10) == 0) {
- quest::gmsay("After much work, $name has obtained a skill level of ".$client->GetRawSkill($individualskill)." in ".$skillnames[$counter]."!", 335, 1, 0, 0);
- }
- }
- elsif ($client->GetRawSkill($individualskill) < $qglobals{$skillglobal}) {
- #$client->Message (15, "ERROR: We've lost QGLOBAL record of your ".$skillnames[$counter]." skill level! Resynchronizing...");
- quest::setglobal($skillglobal, $client->GetRawSkill($individualskill), 5, "F");
- }
- }
- $counter++;
- }
- if ($status < 150) {
- my $savevalue = "".$recipe_name.$recipe_id."";
- if (!defined $qglobals{$savevalue}) {
- quest::gmsay("$name has discovered the recipe for '$recipe_name'.", 335, 1, 0, 0);
- quest::targlobal($savevalue, $charid, "F", 0, 0, 0);
- }
- }
- if ($recipe_id == 13501) {
- plugin::Message("Drink your coffee before it gets cold!");
- quest::settimer("Cool13501", 900);
- }
- if ($recipe_id == 13529) {
- plugin::Message("The silver will harden soon.");
- quest::settimer("cool13529", 1800);
- }
- if (!defined $qglobals{"tscombines"}) {
- quest::setglobal("tscombines",1,5,"F");
- }
- else {
- quest::setglobal("tscombines",$qglobals{"tscombines"}+1,5,"F");
- }
- @row = plugin::GetRecipeTrivial($recipe_id);
- if($client->GetSkill($row[1]) < $row[0])
- {
- if (($class eq "Warrior") && ($clientdeity == 205))
- {
- $client->SetEXP($client->GetEXP() + (2 x $client->CalcEXP(18)), $client->GetAAEXP() )
- }
- else
- {
- $client->SetEXP($client->GetEXP() + $client->CalcEXP(18), $client->GetAAExp() );
- }
- }
- if(plugin::HasRecipe($recipe_id))
- {
- my $randomreturn = plugin::RandomRange(0, 200);
- my $rare = 0;
- if(plugin::GetRecipeData($recipe_id, "legendaryresult") && $rare == 0)
- {
- if($randomreturn < plugin::GetRecipeData($recipe_id, "legendarychance") * 2)
- {
- $client->Message(15, "Great! You find " . plugin::GetRecipeData($recipe_id, "legendaryqty") . " " . plugin::GetRecipeData($recipe_id, "legendarytext") . "!");
- $client->SummonItem(plugin::GetRecipeData($recipe_id, "legendaryresult"), plugin::GetRecipeData($recipe_id, "legendaryqty"));
- $rare = 1;
- }
- }
- if(plugin::GetRecipeData($recipe_id, "epicresult") && $rare == 0)
- {
- if($randomreturn < plugin::GetRecipeData($recipe_id, "uncommonchance") * 2)
- {
- $client->Message(15, "Amazing discovery! You find " . plugin::GetRecipeData($recipe_id, "epicqty") . " " . plugin::GetRecipeData($recipe_id, "epictext") . "!");
- $client->SummonItem(plugin::GetRecipeData($recipe_id, "epicresult"), plugin::GetRecipeData($recipe_id, "epicqty"));
- $rare = 1;
- }
- }
- if(plugin::GetRecipeData($recipe_id, "urareresult") && $rare == 0)
- {
- if($randomreturn < plugin::GetRecipeData($recipe_id, "urarechance") * 2)
- {
- $client->Message(15, "Wow! You find " . plugin::GetRecipeData($recipe_id, "urareqty") . " " . plugin::GetRecipeData($recipe_id, "uraretext") . "!");
- $client->SummonItem(plugin::GetRecipeData($recipe_id, "urareresult"), plugin::GetRecipeData($recipe_id, "urareqty"));
- $rare = 1;
- }
- }
- if(plugin::GetRecipeData($recipe_id, "rareresult") && $rare == 0)
- {
- if($randomreturn < plugin::GetRecipeData($recipe_id, "rarechance") * 2)
- {
- $client->Message(15, "You find " . plugin::GetRecipeData($recipe_id, "rareqty") . " " . plugin::GetRecipeData($recipe_id, "raretext") . "!");
- $client->SummonItem(plugin::GetRecipeData($recipe_id, "rareresult"), plugin::GetRecipeData($recipe_id, "rareqty"));
- $rare = 1;
- }
- }
- if(plugin::GetRecipeData($recipe_id, "uncommonresult") && $rare == 0)
- {
- if($randomreturn < plugin::GetRecipeData($recipe_id, "uncommonchance") * 2)
- {
- $client->Message(15, "You find... " . plugin::GetRecipeData($recipe_id, "uncommonqty") . " " . plugin::GetRecipeData($recipe_id, "uncommontext") . "!");
- $client->SummonItem(plugin::GetRecipeData($recipe_id, "uncommonresult"), plugin::GetRecipeData($recipe_id, "uncommonqty"));
- $rare = 1;
- }
- }
- if($rare == 0)
- {
- $client->Message(15, "Nice! You find " . plugin::GetRecipeData($recipe_id, "qty") . " " . plugin::GetRecipeData($recipe_id, "text") . "!");
- $client->SummonItem(plugin::GetRecipeData($recipe_id, "result"), plugin::GetRecipeData($recipe_id, "qty"));
- }
- }
- }
- sub EVENT_COMBINE_FAILURE {
- my @skillidarray = (59,60,61,63,64,65,68,69);
- my @skillnames = ("Alchemy","Cooking","Tailoring","Blacksmithing","Woodworking","Brewing","Jewelcrafting","Pottery");
- my $counter = 0;
- foreach $individualskill (@skillidarray) {
- $skillglobal = "skill".$individualskill."";
- if (!defined $qglobals{$skillglobal}) {
- quest::setglobal($skillglobal, $client->GetRawSkill($individualskill), 5, "F");
- }
- else {
- if ($client->GetRawSkill($individualskill) > $qglobals{$skillglobal}) {
- quest::setglobal($skillglobal, $client->GetRawSkill($individualskill), 5, "F");
- if (($client->GetRawSkill($individualskill) % 10) == 0) {
- quest::gmsay("After much work, $name has obtained a skill level of ".$client->GetRawSkill($individualskill)." in ".$skillnames[$counter]."!", 335, 1, 0, 0);
- }
- }
- elsif ($client->GetRawSkill($individualskill) < $qglobals{$skillglobal}) {
- #$client->Message (15, "ERROR: We've lost QGLOBAL record of your ".$skillnames[$counter]." skill level! Resynchronizing...");
- quest::setglobal($skillglobal, $client->GetRawSkill($individualskill), 5, "F");
- }
- }
- $counter++;
- }
- if (!defined $qglobals{"tsfailures"}) {
- quest::setglobal("tsfailures",1,5,"F");
- }
- else {
- quest::setglobal("tfailures",$qglobals{"tsfailures"}+1,5,"F");
- }
- }
- sub EVENT_ENTERZONE {
- quest::settimer("Zoned", 5);
- quest::settimer ("TokenTimer", 60); ## Token Timer
- my @approvedzonelist = ( "xuolia", "nexus", "saquia", "marblepalace", "malefix", "airplane", "drybone",
- "shipmvu", "cemetary", "sewers", "enochia", "malsyrian", "miserymire","daggerdepth",
- "maridmanor","sleeper","qeynos","mmca","innothuleb","airplane","chapel",
- "chapeldark","citymist","firiona","gukd","qcat");
- my @startingzonelist = ("clz", "theater", "purgatory");
- my $gm_status = $client->GetGM();
- if ((!$gm_status) && ($status < 80)) {
- if (!defined $qglobals{$zonesn}) {
- #quest::gmsay("$name has discovered the zone $zoneln.", 335, 1, 0, 0);
- quest::targlobal($zonesn, 1, "F", 0, 0, 0);
- }
- if ($zonesn ~~ @approvedzonelist) {
- if ((defined $qglobals{"newtoon"}) && ($qglobals{"newtoon"} == 1) ) {
- quest::settimer("gotoclz", 2);
- }
- }
- elsif ($zonesn eq "kerraridge") {
- quest::movepc(247,260.98,-448.03,3.75,64.5);
- }
- elsif (!($zonesn ~~ @startingzonelist)) {
- quest::settimer("gotojail",2);
- }
- }
- else {
- #$client->Message (15, "NOTICE: Staff member detected. Ignoring zone rules.");
- }
- if(!defined($qglobals{"HasScribedUse"}))
- {
- quest::setglobal("HasScribedUse", 1, 5, "F");
- if(!$client->HasSpellScribed(7651))
- {
- $client->ScribeSpell(7651, $client->GetFreeSpellBookSlot());
- }
- quest::traindisc(132313);
- }
- if(!$entity_list->GetNPCByNPCTypeID(1000503))
- {
- quest::spawn2(1000503, 0, 0, 0, 0, 0, 0);
- }
- }
- sub EVENT_CLICKDOOR {
- if($status >= 80){
- plugin::Doors_Manipulation_EVENT_CLICKDOOR(); # Door Manipulation Plugin
- }
- }
- sub EVENT_SAY {
- @args = split(' ', $text);
- if ($status >= 80) {
- plugin::Doors_Manipulation_EVENT_SAY(); # Door Shit
- #@args = split(' ', $text);
- if ($text=~/#dis/i) {
- $client->Message (15, "Distance from " . $client->GetTarget()->GetCleanName() . " to you.");
- $client->Message (15, "X: " . ($client->GetTarget()->GetX() - $client->GetX()) . " Y: " . ($client->GetTarget()->GetY() - $client->GetY()) . " Z: " . ($client->GetTarget()->GetZ() - $client->GetZ()));
- }
- elsif ($text=~/#stats/i) {
- $client->Message (15, "MinDMG: ".$client->GetTarget()->CastToNPC()->GetMinDMG()." -- MaxDMG: ".$client->GetTarget()->CastToNPC()->GetMaxDMG()."");
- $client->Message (15, "Beard Color: ".$client->GetTarget()->GetBeardColor()." -- Bodytype: ".$client->GetTarget()->GetBodyType()." -- Eye 1 Color ".$client->GetTarget()->GetEyeColor1()." -- Eye 2 Color: ".$client->GetTarget()->GetEyeColor2()."");
- $client->Message (15, "Luclin Face Type: ".$client->GetTarget()->GetLuclinFace()."");
- }
- elsif ($text=~/#gmcon/i) {
- $client->Message (15, "DEBUG: ".$client->CalcEXP(4)."");
- ## $pc->GetLevelCon($npc->GetLevel())
- }
- elsif($args[0]=~/#groundspawn/i){
- if ($args[1]) {
- my $itemdrop = $args[1];
- my $CX = $client->GetX();
- my $CY = $client->GetY();
- my $CZ = $client->GetZ();
- my $CH = $client->GetHeading();
- $connect = plugin::LoadMysql();
- $sth = $connect->prepare("SELECT idfile FROM items WHERE id = $itemdrop");
- $sth->execute();
- my $graphic = $sth->fetchrow_array();
- $sth = $connect->do("INSERT INTO `ground_spawns` VALUES ('', $zoneid, 0, $CX, $CY, $CZ, $CX, $CY, $CH, '".$graphic."_ACTORDEF', $itemdrop, 1, 'Auto', 300000)");
- $client->Message(315, "Groundspawn added to $zonesn!");
- }
- else { $client->Message(315,"Groundspawn: Item ID required!"); }
- }
- elsif($args[0]=~/#treespawn/i && $status > 150){
- if ($args[1] && $args[2] && $args[3] && $args[4]) {
- plugin::InsertStaticTreeProcedure($text, $client);
- $client->Message(13, "TreeSpawn added to $zonesn at your location!");
- }
- else { $client->Message(13,"Format: #treespawn itemid respawntimer basegrowth addsize"); }
- }
- elsif (($text=~/#gmwho/i) && ($status >= 250)) {
- my %classhash = (
- 1 => "Warrior",
- 2 => "Cleric",
- 3 => "Paladin",
- 4 => "Ranger",
- 5 => "Shadow Knight",
- 6 => "Druid",
- 7 => "Monk",
- 8 => "Bard",
- 9 => "Rogue",
- 10 => "Shaman",
- 11 => "Necromancer",
- 12 => "Wizard",
- 13 => "Magician",
- 14 => "Enchanter",
- 15 => "Beastlord",
- 16 => "Berserker",
- );
- my %racehash = (
- 1 => "Human",
- 2 => "Babarian",
- 3 => "Erudite",
- 4 => "Wood Elf",
- 5 => "High Elf",
- 6 => "Dark Elf",
- 7 => "Half Elf",
- 8 => "Dwarf",
- 9 => "Troll",
- 10 => "Ogre",
- 11 => "Halfling",
- 12 => "Gnome",
- 128 => "Iksar",
- 130 => "Vah Shir",
- 330 => "Froglok",
- );
- my @clientsarray = $entity_list->GetClientList();
- $client->Message (11, "(GM List) Players in Zone:");
- $client->Message (11, "----------------------------------");
- foreach my $singleclient (@clientsarray) {
- my $clientguildname;
- my $longip = $singleclient->GetIP();
- $firstoctet = $longip % 256;
- $longip -= $firstoctet;
- $longip /= 256;
- $secondoctet = $longip % 256;
- $longip -= $secondoctet;
- $longip /= 256;
- $thirdoctet = $longip % 256;
- $longip -= $thirdoctet;
- $longip /= 256;
- if (quest::getguildnamebyid($singleclient->GuildID())) {
- $clientguildname = "".quest::getguildnamebyid($singleclient->GuildID())."";
- } else { $clientguildname = "UNGUILDED"; }
- my $dottedip = "$firstoctet.$secondoctet.$thirdoctet.$longip";
- my $wholist = "[".$singleclient->GetLevel()." ".plugin::customclass($singleclient->GetClass(),$singleclient->GetDeity()).
- "] ".$singleclient->GetName()." (".$classhash{$singleclient->GetClass()}.") (".
- $racehash{$singleclient->GetRace()}.") <".$clientguildname."> [IP: ".$dottedip."]";
- $client->Message (11, "".$wholist."");
- }
- $client->Message (11, "There are ".scalar (@clientsarray)." players in zone!");
- }
- }
- if ($text=~/^#Update/i && $status < 100) {
- plugin::GetLeaderboard(%qglobals);
- plugin::ShowLeaderboard("HP");
- }
- if ($args[0]=~/#Leaderboard/i) {
- if(!defined($args[1]))
- {
- my %hash = plugin::LeaderboardTypeHash();
- foreach my $type (sort {$a cmp $b} keys %hash) {
- $client->Message(315, quest::saylink("#leaderboard $type", 1, "Top 10 Players in $type"));
- }
- }
- elsif($args[1] =~ /update/i && $status < 100)
- {
- plugin::GetLeaderboard(%qglobals);
- }
- plugin::ShowLeaderboard(substr($text, 13));
- }
- if($args[0] =~/^#house/i)
- {
- if($args[1] =~ /check/i)
- {
- $client->SetEntityVariable("DoorCommand", "Info");
- quest::signalwith(1000505, $client->GetID());
- }
- if($args[1] =~ /buy/i)
- {
- $client->SetEntityVariable("DoorCommand", "BuyHouse");
- quest::signalwith(1000505, $client->GetID());
- }
- if($args[1] =~ /purchase/i)
- {
- $client->SetEntityVariable("DoorCommand", "PurchaseHouse");
- quest::signalwith(1000505, $client->GetID());
- }
- if($args[1] =~ /sell/i)
- {
- $client->SetEntityVariable("DoorCommand", "SellHouse");
- quest::signalwith(1000505, $client->GetID());
- }
- if($args[1] =~ /relinquish/i)
- {
- $client->SetEntityVariable("DoorCommand", "RelinquishHouse");
- quest::signalwith(1000505, $client->GetID());
- }
- if($args[1] =~ /payrent/i)
- {
- $client->SetEntityVariable("DoorCommand", "PayRent");
- quest::signalwith(1000505, $client->GetID());
- }
- }
- if($args[0] =~/^#object/i)
- {
- if(defined($args[3]) && defined($args[2]) && defined($args[1]))
- {
- $client->SetEntityVariable("DoorCommand", $args[0] . " " . $args[1] . " " . $args[2] . " " . $args[3]);
- }
- elsif(defined($args[1]) && defined($args[2]))
- {
- $client->SetEntityVariable("DoorCommand", $args[0] . " " . $args[1] . " " . $args[2]);
- }
- elsif(defined($args[1]))
- {
- $client->SetEntityVariable("DoorCommand", $args[0] . " " . $args[1]);
- }
- else
- {
- $client->SetEntityVariable("DoorCommand", $args[0]);
- }
- quest::signalwith(1000505, $client->GetID());
- }
- if ($args[0] eq "#tree") {
- if($args[1] =~ /harvest/i)
- {
- $object = $entity_list->GetObjectByID($client->GetEntityVariable("TreeID"));
- if(defined($object))
- {
- if($zonesn eq "neighborhood" && !$object->GetEntityVariable("IsStaticTree"))
- {
- $client->SetEntityVariable("DoorCommand", "HarvestItem");
- quest::signalwith(1000505, $client->GetID());
- }
- else
- {
- if(plugin::IsTree($object->GetItemID()))
- {
- my $randomroll = plugin::RandomRange($object->GetEntityVariable("TreeGrowth") / 40, $object->GetEntityVariable("TreeGrowth") / 15);
- my $randomreturn = plugin::RandomRange(0, 200);
- if($randomroll < 1)
- {
- $client->Message(15, "You feel like you're a poor excuse for a gardener. You get your seed back.");
- $client->SummonItem($object->GetItemID(), 1);
- }
- else
- {
- my $rare = 0;
- if(plugin::GetTreeData($object->GetItemID(), "rareresult"))
- {
- if($randomreturn < plugin::GetTreeData($object->GetItemID(), "rarechance") * 2)
- {
- $client->Message(15, "[RARE] You find $randomroll " . plugin::GetTreeData($object->GetItemID(), "raretext") . " in addition to your yield!");
- $client->SummonItem(plugin::GetTreeData($object->GetItemID(), "rareresult"), $randomroll);
- $rare = 1;
- }
- }
- if(plugin::GetTreeData($object->GetItemID(), "uncommonresult") && $rare == 0)
- {
- if($randomreturn < plugin::GetTreeData($object->GetItemID(), "uncommonchance") * 2)
- {
- $client->Message(15, "[UNCOMMON] You find $randomroll " . plugin::GetTreeData($object->GetItemID(), "uncommontext") . " in addition to your yield!");
- $client->SummonItem(plugin::GetTreeData($object->GetItemID(), "uncommonresult"), $randomroll);
- $rare = 1;
- }
- }
- if($rare == 0)
- {
- $client->Message(15, "[COMMON] You harvest the " . plugin::GetTreeData($object->GetItemID(), "plant") .". You gain $randomroll " . plugin::GetTreeData($object->GetItemID(), "text") . " from your yield.");
- $client->SummonItem(plugin::GetTreeData($object->GetItemID(), "result"), $randomroll);
- }
- if($object->GetEntityVariable("TreeGrowth") >= $randomreturn)
- {
- $client->Message(15, "You dig amongst the dirt and find something extra. It's a miracle of growth!");
- $client->SummonItem($object->GetItemID(), 1);
- }
- }
- if(!$object->GetEntityVariable("IsStaticTree"))
- {
- plugin::DeleteTreeProcedure($object);
- }
- else
- {
- quest::signalwith(1000503, $object->GetID());
- }
- }
- else
- {
- $client->Message(13, "That's not a tree..");
- }
- }
- }
- else
- {
- $client->Message(13, "Please select a plant to harvest.");
- }
- }
- if($args[1] =~ /pickup/i)
- {
- $object = $entity_list->GetObjectByID($client->GetEntityVariable("TreeID"));
- if(defined($object))
- {
- if($zonesn eq "neighborhood")
- {
- $client->SetEntityVariable("DoorCommand", "PickupItem");
- quest::signalwith(1000505, $client->GetID());
- }
- else
- {
- # if($object->GetEntityVariable("Owner") != $client->AccountID() && !$client->GetGM())
- # {
- # $client->Message(13, "Hmm, you think it'd be wise to not mess with another person's property..");
- # }
- if(!plugin::IsTree($object->GetItemID()))
- {
- $client->Message(15, "You pick up the house item laying on the ground.");
- quest::summonitem($object->GetItemID(), 1);
- plugin::DeleteTreeProcedure($object);
- }
- else
- {
- $client->Message(13, "That's a plant. Try harvesting it.");
- }
- }
- }
- else
- {
- $client->Message(13, "Please select a plant to harvest.");
- }
- }
- elsif($args[1] =~ /check/i)
- {
- $object = $entity_list->GetObjectByID($client->GetEntityVariable("TreeID"));
- if(defined($object))
- {
- $client->Message(15, "You tend to your plant.");
- $client->Message(15, " :: Water:" . $object->GetEntityVariable("TreeWater"));
- $client->Message(15, " :: Growth:" . $object->GetEntityVariable("TreeGrowth"));
- }
- else
- {
- $client->Message(13, "Please select a plant to check.");
- }
- }
- elsif($args[1] =~ /clickeffect/i)
- {
- $object = $entity_list->GetObjectByID($client->GetEntityVariable("TreeID"));
- if(defined($object))
- {
- if($client->AccountID() == $object->GetEntityVariable("Owner"))
- {
- if(plugin::HasEffect($object->GetItemID()) || $object->GetEntityVariable("ClickEffect"))
- {
- if(plugin::HasEffect($object->GetItemID()) && defined $qglobals{"Reuse" . $object->GetItemID()})
- {
- if(plugin::GetEffectData($object->GetItemID(), "reuse"))
- {
- if(time() - $qglobals{"Reuse" . $object->GetItemID()} < plugin::GetEffectData($object->GetItemID(), "reuse"))
- {
- $client->Message(13, "Reuse timer not expired for the effect " . plugin::GetEffectData($object->GetItemID(), "text") . ".");
- return 0;
- }
- }
- }
- $client->Message(15, "You activate the ability " . (plugin::HasEffect($object->GetItemID()) ? plugin::GetEffectData($object->GetItemID(), "text") : "that is on" . " on the object!"));
- #$client->Message(15, plugin::HasEffect($object->GetItemID()) ? plugin::GetEffectData($object->GetItemID(), "spell_id") : (defined($object->GetEntityVariable("ClickEffect")) ? $object->GetEntityVariable("ClickEffect") : 0));
- $client->SpellFinished(plugin::HasEffect($object->GetItemID()) ? plugin::GetEffectData($object->GetItemID(), "spell_id") : (defined($object->GetEntityVariable("ClickEffect")) ? $object->GetEntityVariable("ClickEffect") : 0), $client);
- if(plugin::HasEffect($object->GetItemID()))
- {
- if(defined(plugin::GetEffectData($object->GetItemID(), "reuse")))
- {
- quest::setglobal("Reuse" . $object->GetItemID(), time(), 5, "F");
- }
- }
- }
- }
- else
- {
- $client->Message(13, "This isn't yours to activate! Please select an object to activate that is on your plot.")
- }
- }
- else
- {
- $client->Message(13, "Please select an object to activate that is on your plot.");
- }
- }
- elsif($args[1] =~ /water/i)
- {
- $object = $entity_list->GetObjectByID($client->GetEntityVariable("TreeID"));
- if(defined($object))
- {
- $client->Message(15, "You kneel beside the plant to water it...");
- $slot = plugin::check_hasitem_inslot($client, 2046);
- if($slot != 65535)
- {
- $client->DeleteItemInInventory($slot, 1, 1);
- $client->SummonItem(16598, 1);
- $total = $object->GetEntityVariable("TreeWater") + 1;
- $client->Message(15, "... and the soil absorbs the water thirstily! Moisture Content: $total");
- $object->SetEntityVariable("TreeWater", $object->GetEntityVariable("TreeWater") + 1);
- plugin::UpdateTreeProcedure($object);
- }
- else
- {
- $client->Message(15, "... but you don't have a bottle of water!");
- }
- }
- else
- {
- $client->Message(13, "Please select a plant to check.");
- }
- }
- }
- if($text=~/#gmzone/i){
- plugin::SendToInstance("public", "overthere", 1, 1836, 3098, -50, "GM_Zone3", 604800); # Send to Overthere for Weapons/Spells Preview
- }
- if ($text =~/^#Online Month$/i)
- {
- my $GET_SECONDS = (60 * 60 * 24 * 30); # 1 Month (Minutes)
- my $GET_MINUTES = $GET_SECONDS / 60; # 1 Month (Seconds)
- my $GET_ONLINE_IP = GET_IP_ONLINE($GET_MINUTES);
- my $GET_ONLINE_CHAR = GET_PLAYERS_ONLINE($GET_SECONDS);
- #$client->Message(2, "IP Log Online Month: $GET_ONLINE_IP");
- $client->Message(2, "Players online this month: $GET_ONLINE_CHAR");
- }
- if ($text =~/^#Online Week$/i)
- {
- my $GET_SECONDS = (60 * 60 * 24 * 7); # 1 Week (Minutes)
- my $GET_MINUTES = $GET_SECONDS / 60; # 1 Week (Seconds)
- my $GET_ONLINE_IP = GET_IP_ONLINE($GET_MINUTES);
- my $GET_ONLINE_CHAR = GET_PLAYERS_ONLINE($GET_SECONDS);
- #$client->Message(2, "IP Log Online Week: $GET_ONLINE_IP");
- $client->Message(2, "Players online this week: $GET_ONLINE_CHAR");
- }
- if ($text =~/^#Online Today$/i)
- {
- my $GET_SECONDS = (60 * 60 * 24 * 1); # 1 Day (Minutes)
- my $GET_MINUTES = $GET_SECONDS / 60; # 1 Day (Seconds)
- my $GET_ONLINE_IP = GET_IP_ONLINE($GET_MINUTES);
- my $GET_ONLINE_CHAR = GET_PLAYERS_ONLINE($GET_SECONDS);
- #$client->Message(2, "IP Log Online Today: $GET_ONLINE_IP");
- $client->Message(2, "Players online today: $GET_ONLINE_CHAR");
- }
- if ($text =~/^#Online 30$/i)
- {
- my $GET_SECONDS = (30 * 60 * 1 * 1); # 30 Minutes (Minutes)
- my $GET_MINUTES = $GET_SECONDS / 60; # 30 Minutes (Seconds)
- my $GET_ONLINE_IP = GET_IP_ONLINE($GET_MINUTES);
- my $GET_ONLINE_CHAR = GET_PLAYERS_ONLINE($GET_SECONDS);
- #$client->Message(2, "IP Log Online 30 Minutes: $GET_ONLINE_IP");
- $client->Message(2, "Players online in the last 30 minutes: $GET_ONLINE_CHAR");
- }
- if ($text=~/#namepet/i) {
- my $pet_ent = $entity_list->GetMobByID($client->GetPetID());
- my @arg = split(" ", $text);
- my $pet_name = fixname($arg[1]);
- if (length($pet_name) > 10 || length($pet_name) < 3) {
- $client->Message(13, "Pet name invalid!");
- return;
- }
- if ($pet_ent) {
- $pet_ent->TempName($pet_name);
- }
- }
- if ($text =~/#wiki/i)
- {
- $client->SendWebLink("https://wiki.eqemulator.org/");
- }
- }
- sub EVENT_LOOT {
- if ($looted_id == 4043) {
- quest::settimer("cool4043", 900);
- }
- if (!defined $qglobals{"looteditems"}) {
- quest::setglobal("looteditems",1,5,"F");
- }
- else {
- quest::setglobal("looteditems",$qglobals{"looteditems"}+1,5,"F");
- }
- }
- sub EVENT_LEVEL_UP {
- if ($status < 150) {
- if ((defined $qglobals{"noobie"}) && ($qglobals{"noobie"} >= 1)) {
- quest::gmsay( "Rejoice, $name is now a level $ulevel ".plugin::customclass($client->GetClass(),$client->GetDeity()).
- "!", 335, 1, 0, 0);
- }
- }
- }
- sub EVENT_TRADE {
- if (!defined $qglobals{"tradeditems"}) {
- quest::setglobal("tradeditems",1,5,"F");
- }
- else {
- quest::setglobal("tradeditems",$qglobals{"tradeditems"}+1,5,"F");
- }
- }
- sub EVENT_SIGNAL {
- if ($signal == 4398) {
- quest::popup ("Blank Map",
- "<br> <br>You unroll your map and look down at it. Would you like to mark your location?<br>
- <br> <br>",50010,1); ## global player signals begin with 500 to avoid conflict with zone specific player.pl
- }
- }
- sub EVENT_POPUPRESPONSE {
- my $space = " ";
- my $xvar = int($client->GetX());
- my $x = int($client->GetX());
- my $yvar = int($client->GetY());
- my $y = int($client->GetY());
- my $zvar = int($client->GetZ());
- my $z = int($client->GetZ());
- $global = "$xvar$space$yvar$space$zvar$space$zoneid";
- if ($popupid == 50010) {
- $client->Message(15,"You mark a large red X on your map.");
- $client->SetGlobal("Alt Bind", $global, 5, "F");
- plugin::DeleteItem(4398);
- quest::summonitem(4149);
- }
- }
- sub EVENT_PLAYER_PICKUP
- {
- $object = $entity_list->GetObjectByID($picked_up_entity_id);
- if($client->GetGM())
- {
- $client->Message(15, "[GM] This is model " . $object->GetModelName());
- }
- if(plugin::IsTree($object->GetItemID()))
- {
- #$object = $entity_list->GetObjectByID($picked_up_entity_id);
- if(defined($object))
- {
- $client->Message(15, "This is a " . plugin::GetTreeData($object->GetItemID(), "plant") . " plant. What would you like to do with it?");
- $client->Message(15, quest::saylink("#tree harvest", 1, " ::Harvest"));
- $client->Message(15, quest::saylink("#tree check", 1, " ::Check"));
- $client->Message(15, quest::saylink("#tree water", 1, " ::Water"));
- $client->SetEntityVariable("TreeID", $object->GetID());
- }
- return 1;
- }
- elsif(plugin::HasRadius($object->GetItemID()))
- {
- $client->Message(15, "This is a " . plugin::GetRadiusData($object->GetItemID(), "name") . ".");
- if($object->GetEntityVariable("WardOwner"))
- {
- if(!$entity_list->GetClientByID($object->GetEntityVariable("WardOwner")))
- {
- $object->Depop();
- }
- }
- return 1;
- }
- elsif(defined($object->GetEntityVariable("DBID")) && !defined($object->GetEntityVariable("UpLevel")))
- {
- $client->Message(15, "This is a house item. What would you like to do with it?");
- $client->Message(15, quest::saylink("#tree pickup", 1, " ::Pickup"));
- if(plugin::HasEffect($object->GetItemID()) || $object->GetEntityVariable("ClickEffect"))
- {
- $client->Message(15, quest::saylink("#tree clickeffect", 1, " ::Activate Effect"));
- }
- $client->SetEntityVariable("TreeID", $object->GetID());
- $client->SetEntityVariable("Effect", $object->GetID());
- if($zonesn eq "neighborhood" && $object->GetItemID() != 1801)
- {
- $client->Message(15, quest::saylink("#object", 1, " ::Neighborhood Object Commands"));
- }
- return 1;
- }
- #$client->Message(13, "Is your client locking up?");
- return 0;
- }
- sub EVENT_CAST
- {
- if($spell_id == 7651)
- {
- if($zonesn eq "neighborhood" && !plugin::HasRadius($client->GetEntityVariable("PlacingItemID")))
- {
- if($client->GetEntityVariable("PlacingItemID") != 12673)
- {
- $client->SetEntityVariable("DoorCommand", "PlaceItem");
- quest::signalwith(1000505, $client->GetID());
- }
- }
- else
- {
- if(plugin::HasRadius($client->GetEntityVariable("PlacingItemID")))
- {
- my $object = $entity_list->GetObjectByID($client->GetEntityVariable("WardID" . $client->GetEntityVariable("PlacingItemID")));
- my $radiusobj = $client->GetEntityVariable("PlacingItemID");
- if(plugin::GetRadiusData($radiusobj, "reqclass") != 0 && plugin::GetRadiusData($radiusobj, "reqclass") != $client->GetClass())
- {
- if(plugin::GetRadiusData($radiusobj, "errmsgclass") && plugin::GetRadiusData($radiusobj, "errmsgclass") ne "")
- {
- $client->Message(15, plugin::GetRadiusData($radiusobj, "errmsgclass"));
- }
- }
- elsif(plugin::GetRadiusData($radiusobj, "reqdeity") != 0 && plugin::GetRadiusData($radiusobj, "reqdeity") != $client->GetDeity())
- {
- if(plugin::GetRadiusData($radiusobj, "errmsgdeity") && plugin::GetRadiusData($radiusobj, "errmsgdeity") ne "")
- {
- $client->Message(15, plugin::GetRadiusData($radiusobj, "errmsgdeity"));
- }
- }
- elsif(plugin::GetRadiusData($radiusobj, "reqlevel") != 0 && $client->GetLevel() < plugin::GetRadiusData($radiusobj, "reqlevel"))
- {
- if(plugin::GetRadiusData($radiusobj, "errmsglevel") && plugin::GetRadiusData($radiusobj, "errmsglevel") ne "")
- {
- $client->Message(15, plugin::GetRadiusData($radiusobj, "errmsglevel"));
- }
- }
- elsif(defined($object))
- {
- if(plugin::GetRadiusData($radiusobj, "errmsgplaced") && plugin::GetRadiusData($radiusobj, "errmsgplaced") ne "")
- {
- $client->Message(15, plugin::GetRadiusData($radiusobj, "errmsgplaced"));
- }
- }
- else
- {
- $slot = plugin::check_hasitem_inslot($client, $client->GetEntityVariable("PlacingItemID"));
- if($slot != 65535)
- {
- $client->DeleteItemInInventory($slot, 1, 1);
- $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
- $object = $entity_list->GetObjectByID($spawnid);
- $object->SetEntityVariable("WardOwner", $client->GetID());
- $object->SetSize($client->GetEntityVariable("PlacingSize") ? $client->GetEntityVariable("PlacingSize") : 100);
- quest::settimer("WardTimer" . $client->GetEntityVariable("PlacingItemID"), plugin::GetRadiusData($radiusobj, "timer")); #Starts a timer with string "WardTimer" as $timer
- my $triggered = 0;
- if(plugin::GetRadiusData($radiusobj, "npcflag"))
- {
- #do stuff
- my @npcs = $entity_list->GetNPCList();
- foreach my $singlenpc (@npcs)
- {
- my $rad = plugin::GetRadiusData($radiusobj, "radius");
- if(int($object->GetX()) > int($singlenpc->GetX())-$rad && int($object->GetX()) < int($singlenpc->GetX())+$rad &&
- int($object->GetY()) > int($singlenpc->GetY())-$rad && int($object->GetY()) < int($singlenpc->GetY())+$rad)
- {
- if(plugin::GetRadiusData($radiusobj, "remove"))
- {
- $triggered = 1;
- }
- if(plugin::GetRadiusData($radiusobj, "spell_id"))
- {
- $client->SpellFinished(plugin::GetRadiusData($radiusobj, "spell_id"), $singlenpc);
- }
- if(plugin::GetRadiusData($radiusobj, "spell_id2"))
- {
- $client->SpellFinished(plugin::GetRadiusData($radiusobj, "spell_id2"), $singlenpc);
- }
- if(plugin::GetRadiusData($radiusobj, "spell_id3"))
- {
- $client->SpellFinished(plugin::GetRadiusData($radiusobj, "spell_id3"), $singlenpc);
- }
- }
- else
- {
- # quest::gmsay("No radius!", 15);
- }
- }
- }
- else
- {
- my @clients = $entity_list->GetClientList();
- foreach my $singleclient (@clients)
- {
- my $rad = plugin::GetRadiusData($radiusobj, "radius");
- if(int($object->GetX()) > int($singleclient->GetX())-$rad && int($object->GetX()) < int($singleclient->GetX())+$rad &&
- int($object->GetY()) > int($singleclient->GetY())-$rad && int($object->GetY()) < int($singleclient->GetY())+$rad)
- {
- if(plugin::GetRadiusData($radiusobj, "remove"))
- {
- $triggered = 1;
- }
- if(plugin::GetRadiusData($radiusobj, "spell_id"))
- {
- $client->SpellFinished(plugin::GetRadiusData($radiusobj, "spell_id"), $singleclient);
- }
- if(plugin::GetRadiusData($radiusobj, "spell_id2"))
- {
- $client->SpellFinished(plugin::GetRadiusData($radiusobj, "spell_id2"), $singleclient);
- }
- if(plugin::GetRadiusData($radiusobj, "spell_id3"))
- {
- $client->SpellFinished(plugin::GetRadiusData($radiusobj, "spell_id3"), $singleclient);
- }
- }
- else
- {
- #quest::gmsay("No radius!", 15);
- }
- }
- }
- if($triggered)
- {
- $object->Depop();
- quest::stoptimer("WardTimer" . $client->GetEntityVariable("PlacingItemID"));
- }
- $client->SetEntityVariable("WardID" . $client->GetEntityVariable("PlacingItemID"), $spawnid);
- }
- else
- {
- $client->Message(15, "You have run out of " . plugin::GetRadiusData($radiusobj, "name"). "!");
- }
- }
- }
- else
- {
- if(!defined($client->GetEntityVariable("PlacingItemID")))
- {
- $client->Message(15, "Please select an item to use in the world before casting this ability.");
- }
- else
- {
- $slot = plugin::check_hasitem_inslot($client, $client->GetEntityVariable("PlacingItemID"));
- if (plugin::CheckTreeRadius($client->GetTargetRingX(), $client->GetTargetRingY())) {
- $client->Message(15, "There is an object too close, choose another location.");
- return;
- }
- if($slot != 65535)
- {
- $client->DeleteItemInInventory($slot, 1, 1);
- $spawnid = quest::creategroundobject($client->GetEntityVariable("PlacingItemID"), $client->GetTargetRingX(), $client->GetTargetRingY(), $client->GetTargetRingZ(), $client->GetHeading(), 0); #62671 original ID
- #quest::gmsay("SpawnID is $spawnid", 15);
- $object = $entity_list->GetObjectByID($spawnid);
- $object->SetSize(($client->GetEntityVariable("PlacingGrowth") / 5) + $client->GetEntityVariable("PlacingSize"));
- $object->SetSolidType(0);
- $object->SetEntityVariable("TreeGrowth", $client->GetEntityVariable("PlacingGrowth") / 5);
- $object->SetEntityVariable("TreeWater", 0);
- $object->SetEntityVariable("TreeDisease", 0);
- $object->SetEntityVariable("TreeSize", $client->GetEntityVariable("PlacingSize"));
- $object->SetEntityVariable("PlacingEffect", (plugin::HasEffect($object->GetItemID()) ? plugin::GetEffectData($object->GetItemID(), "spell_id") : (defined($object->GetEntityVariable("ClickEffect")) ? $object->GetEntityVariable("ClickEffect") : 0)));
- $object->SetEntityVariable("Owner", $client->AccountID());
- plugin::InsertTreeProcedure($object);
- quest::signalwith(1000503,$spawnid);
- }
- else
- {
- $client->Message(15, "You need to highlight a useable item!");
- }
- }
- }
- }
- }
- }
- sub GET_PLAYERS_ONLINE
- {
- my $GET_ONLINE = 0;
- my $connect = LoadMySQLConnection();
- my $query = "
- SELECT count(last_login)
- FROM character_data
- WHERE UNIX_TIMESTAMP() - ($_[0]) < last_login
- ";
- # $client->Message(7, "$query");
- my $query_handle = $connect->prepare($query);
- $query_handle->execute();
- if ($query_handle->rows)
- {
- my $ref = $query_handle->fetchrow_hashref();
- $GET_ONLINE = $ref->{'count(last_login)'};
- }
- $query_handle->finish();
- $connect->disconnect();
- return $GET_ONLINE;
- } # End GET_PLAYERS_ONLINE
- sub GET_IP_ONLINE
- {
- my $GET_ONLINE = 0;
- my $connect = LoadMySQLConnection();
- my $query = "
- SELECT count(lastused)
- FROM account_ip
- WHERE TIMESTAMPDIFF(MINUTE, lastused, NOW()) < $_[0]
- ";
- # $client->Message(7, "$query");
- my $query_handle = $connect->prepare($query);
- $query_handle->execute();
- if ($query_handle->rows)
- {
- my $ref = $query_handle->fetchrow_hashref();
- $GET_ONLINE = $ref->{'count(lastused)'};
- }
- $query_handle->finish();
- $connect->disconnect();
- return $GET_ONLINE;
- } # End GET_IP_ONLINE
- sub LoadMySQLConnection
- {
- use DBI;
- use DBD::mysql;
- # GET DB, USER, AND PASS FROM CONFIG FILE
- my $confile = "eqemu_config.xml"; #default config file
- # open(F, "<$confile") or die "Unable to open config: $confile\n";
- open(F, "<$confile") or quest::gmsay("GM: sub LoadMySQLConnection() 'open' FAILED !!!!", 15, 1);
- my $indb = 0;
- while(<F>)
- {
- s/\r//g;
- if(/<database>/i) { $indb = 1; }
- next unless($indb == 1);
- if(/<\/database>/i) { $indb = 0; last; }
- if(/<host>(.*)<\/host>/i) { $host = $1; }
- elsif(/<username>(.*)<\/username>/i) { $user = $1; }
- elsif(/<password>(.*)<\/password>/i) { $pass = $1; }
- elsif(/<db>(.*)<\/db>/i) { $db = $1; }
- }
- # DATA SOURCE NAME
- my $dsn = "dbi:mysql:$db:localhost:3306";
- # PERL DBI CONNECT
- my $connect = DBI->connect($dsn, $user, $pass) or quest::gmsay("GM: sub LoadMySQLConnection() 'connect' FAILED !!!!", 15, 1);
- return $connect;
- } # End LoadMySQLConnection()
- sub EVENT_DISCONNECT {
- quest::stoptimer ("activitycheck$charid");
- }
- sub fixname {
- local $_ = shift;
- s/[^A-Za-z]+//g;
- return $_;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement